-
Notifications
You must be signed in to change notification settings - Fork 0
/
process.js
38 lines (33 loc) · 961 Bytes
/
process.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(function (root, factory) {
if (typeof define === "function" && define.amd) {
define([], factory);
} else if (typeof module === "object" && module.exports) {
module.exports = factory();
} else {
root["mu-create/process"] = factory();
}
})(this, function () {
var array = Array.prototype;
var slice = array.slice;
var concat = array.concat;
return function () {
var self = this;
var rules = concat.apply(array, arguments);
return function (input) {
var skip = false;
var args = slice.call(arguments, 1);
return rules.reduce(function (output, rule) {
var created = skip ? output : rule.apply(self, [output].concat(args));
if (created !== undefined) {
if (created === false) {
skip = true;
}
else {
output = created;
}
}
return output;
}, input);
}
}
});