deku 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/Gemfile +5 -0
- data/LICENSE +25 -0
- data/README.md +28 -0
- data/Rakefile +1 -0
- data/deku.gemspec +23 -0
- data/deps/node_modules/deku.js +2 -0
- data/deps/node_modules/deku/.editorconfig +16 -0
- data/deps/node_modules/deku/.zuul.yml +15 -0
- data/deps/node_modules/deku/History.md +290 -0
- data/deps/node_modules/deku/LICENSE.md +7 -0
- data/deps/node_modules/deku/Makefile +91 -0
- data/deps/node_modules/deku/README.md +293 -0
- data/deps/node_modules/deku/index.js +4072 -0
- data/deps/node_modules/deku/lib/application.js +85 -0
- data/deps/node_modules/deku/lib/index.js +28 -0
- data/deps/node_modules/deku/lib/render.js +1300 -0
- data/deps/node_modules/deku/lib/stringify.js +105 -0
- data/deps/node_modules/deku/lib/svg.js +107 -0
- data/deps/node_modules/deku/lib/utils.js +18 -0
- data/deps/node_modules/deku/lib/virtual.js +247 -0
- data/deps/node_modules/deku/node_modules/array-flatten/LICENSE +21 -0
- data/deps/node_modules/deku/node_modules/array-flatten/README.md +43 -0
- data/deps/node_modules/deku/node_modules/array-flatten/array-flatten.js +57 -0
- data/deps/node_modules/deku/node_modules/array-flatten/package.json +62 -0
- data/deps/node_modules/deku/node_modules/component-emitter/History.md +63 -0
- data/deps/node_modules/deku/node_modules/component-emitter/LICENSE +24 -0
- data/deps/node_modules/deku/node_modules/component-emitter/Readme.md +74 -0
- data/deps/node_modules/deku/node_modules/component-emitter/index.js +161 -0
- data/deps/node_modules/deku/node_modules/component-emitter/package.json +174 -0
- data/deps/node_modules/deku/node_modules/component-raf/.npmignore +2 -0
- data/deps/node_modules/deku/node_modules/component-raf/History.md +26 -0
- data/deps/node_modules/deku/node_modules/component-raf/Makefile +11 -0
- data/deps/node_modules/deku/node_modules/component-raf/Readme.md +46 -0
- data/deps/node_modules/deku/node_modules/component-raf/component.json +16 -0
- data/deps/node_modules/deku/node_modules/component-raf/example.html +43 -0
- data/deps/node_modules/deku/node_modules/component-raf/index.js +34 -0
- data/deps/node_modules/deku/node_modules/component-raf/package.json +164 -0
- data/deps/node_modules/deku/node_modules/component-type/.npmignore +3 -0
- data/deps/node_modules/deku/node_modules/component-type/Makefile +14 -0
- data/deps/node_modules/deku/node_modules/component-type/Readme.md +37 -0
- data/deps/node_modules/deku/node_modules/component-type/component.json +13 -0
- data/deps/node_modules/deku/node_modules/component-type/index.js +34 -0
- data/deps/node_modules/deku/node_modules/component-type/package.json +120 -0
- data/deps/node_modules/deku/node_modules/component-type/test/index.html +17 -0
- data/deps/node_modules/deku/node_modules/component-type/test/mocha.css +231 -0
- data/deps/node_modules/deku/node_modules/component-type/test/mocha.js +5340 -0
- data/deps/node_modules/deku/node_modules/component-type/test/tests.js +72 -0
- data/deps/node_modules/deku/node_modules/dom-pool/.npmignore +1 -0
- data/deps/node_modules/deku/node_modules/dom-pool/Pool.js +52 -0
- data/deps/node_modules/deku/node_modules/dom-pool/README.md +42 -0
- data/deps/node_modules/deku/node_modules/dom-pool/authors.txt +4 -0
- data/deps/node_modules/deku/node_modules/dom-pool/bower.json +26 -0
- data/deps/node_modules/deku/node_modules/dom-pool/package.json +46 -0
- data/deps/node_modules/deku/node_modules/dom-pool/tests.html +16 -0
- data/deps/node_modules/deku/node_modules/dom-pool/tests.js +102 -0
- data/deps/node_modules/deku/node_modules/dom-walk/.npmignore +3 -0
- data/deps/node_modules/deku/node_modules/dom-walk/LICENCE +19 -0
- data/deps/node_modules/deku/node_modules/dom-walk/Makefile +2 -0
- data/deps/node_modules/deku/node_modules/dom-walk/README.md +23 -0
- data/deps/node_modules/deku/node_modules/dom-walk/example/index.js +5 -0
- data/deps/node_modules/deku/node_modules/dom-walk/example/static/bundle.js +211 -0
- data/deps/node_modules/deku/node_modules/dom-walk/example/static/index.html +16 -0
- data/deps/node_modules/deku/node_modules/dom-walk/index.js +24 -0
- data/deps/node_modules/deku/node_modules/dom-walk/package.json +57 -0
- data/deps/node_modules/deku/node_modules/fast.js/.jshintignore +7 -0
- data/deps/node_modules/deku/node_modules/fast.js/.jshintrc +80 -0
- data/deps/node_modules/deku/node_modules/fast.js/.npmignore +6 -0
- data/deps/node_modules/deku/node_modules/fast.js/.travis.yml +3 -0
- data/deps/node_modules/deku/node_modules/fast.js/LICENSE.md +21 -0
- data/deps/node_modules/deku/node_modules/fast.js/README.md +552 -0
- data/deps/node_modules/deku/node_modules/fast.js/array/clone.js +21 -0
- data/deps/node_modules/deku/node_modules/fast.js/array/concat.js +32 -0
- data/deps/node_modules/deku/node_modules/fast.js/array/every.js +25 -0
- data/deps/node_modules/deku/node_modules/fast.js/array/fill.js +29 -0
- data/deps/node_modules/deku/node_modules/fast.js/array/filter.js +26 -0
- data/deps/node_modules/deku/node_modules/fast.js/array/forEach.js +21 -0
- data/deps/node_modules/deku/node_modules/fast.js/array/index.js +15 -0
- data/deps/node_modules/deku/node_modules/fast.js/array/indexOf.js +33 -0
- data/deps/node_modules/deku/node_modules/fast.js/array/lastIndexOf.js +29 -0
- data/deps/node_modules/deku/node_modules/fast.js/array/map.js +24 -0
- data/deps/node_modules/deku/node_modules/fast.js/array/pluck.js +24 -0
- data/deps/node_modules/deku/node_modules/fast.js/array/reduce.js +35 -0
- data/deps/node_modules/deku/node_modules/fast.js/array/reduceRight.js +35 -0
- data/deps/node_modules/deku/node_modules/fast.js/array/some.js +25 -0
- data/deps/node_modules/deku/node_modules/fast.js/bower.json +28 -0
- data/deps/node_modules/deku/node_modules/fast.js/clone.js +27 -0
- data/deps/node_modules/deku/node_modules/fast.js/dist/bench.html +15 -0
- data/deps/node_modules/deku/node_modules/fast.js/dist/bench.js +19900 -0
- data/deps/node_modules/deku/node_modules/fast.js/dist/fast.js +1450 -0
- data/deps/node_modules/deku/node_modules/fast.js/dist/fast.min.js +1 -0
- data/deps/node_modules/deku/node_modules/fast.js/filter.js +23 -0
- data/deps/node_modules/deku/node_modules/fast.js/forEach.js +22 -0
- data/deps/node_modules/deku/node_modules/fast.js/function/apply.js +19 -0
- data/deps/node_modules/deku/node_modules/fast.js/function/applyNoContext.js +29 -0
- data/deps/node_modules/deku/node_modules/fast.js/function/applyWithContext.js +29 -0
- data/deps/node_modules/deku/node_modules/fast.js/function/bind.js +71 -0
- data/deps/node_modules/deku/node_modules/fast.js/function/bindInternal3.js +11 -0
- data/deps/node_modules/deku/node_modules/fast.js/function/bindInternal4.js +11 -0
- data/deps/node_modules/deku/node_modules/fast.js/function/index.js +7 -0
- data/deps/node_modules/deku/node_modules/fast.js/function/partial.js +42 -0
- data/deps/node_modules/deku/node_modules/fast.js/function/partialConstructor.js +45 -0
- data/deps/node_modules/deku/node_modules/fast.js/function/try.js +35 -0
- data/deps/node_modules/deku/node_modules/fast.js/index.js +241 -0
- data/deps/node_modules/deku/node_modules/fast.js/map.js +23 -0
- data/deps/node_modules/deku/node_modules/fast.js/object/assign.js +34 -0
- data/deps/node_modules/deku/node_modules/fast.js/object/clone.js +25 -0
- data/deps/node_modules/deku/node_modules/fast.js/object/filter.js +28 -0
- data/deps/node_modules/deku/node_modules/fast.js/object/forEach.js +23 -0
- data/deps/node_modules/deku/node_modules/fast.js/object/index.js +11 -0
- data/deps/node_modules/deku/node_modules/fast.js/object/keys.js +17 -0
- data/deps/node_modules/deku/node_modules/fast.js/object/map.js +26 -0
- data/deps/node_modules/deku/node_modules/fast.js/object/reduce.js +37 -0
- data/deps/node_modules/deku/node_modules/fast.js/object/reduceRight.js +37 -0
- data/deps/node_modules/deku/node_modules/fast.js/object/values.js +20 -0
- data/deps/node_modules/deku/node_modules/fast.js/package.json +73 -0
- data/deps/node_modules/deku/node_modules/fast.js/reduce.js +24 -0
- data/deps/node_modules/deku/node_modules/fast.js/reduceRight.js +24 -0
- data/deps/node_modules/deku/node_modules/fast.js/string/index.js +3 -0
- data/deps/node_modules/deku/node_modules/fast.js/string/intern.js +56 -0
- data/deps/node_modules/deku/node_modules/get-uid/README.md +44 -0
- data/deps/node_modules/deku/node_modules/get-uid/index.js +6 -0
- data/deps/node_modules/deku/node_modules/get-uid/package.json +56 -0
- data/deps/node_modules/deku/node_modules/is-dom/HISTORY.md +2 -0
- data/deps/node_modules/deku/node_modules/is-dom/LICENSE +21 -0
- data/deps/node_modules/deku/node_modules/is-dom/README.md +32 -0
- data/deps/node_modules/deku/node_modules/is-dom/index.js +15 -0
- data/deps/node_modules/deku/node_modules/is-dom/package.json +62 -0
- data/deps/node_modules/deku/node_modules/object-path/.npmignore +7 -0
- data/deps/node_modules/deku/node_modules/object-path/.travis.yml +6 -0
- data/deps/node_modules/deku/node_modules/object-path/LICENSE +21 -0
- data/deps/node_modules/deku/node_modules/object-path/README.md +96 -0
- data/deps/node_modules/deku/node_modules/object-path/bower.json +17 -0
- data/deps/node_modules/deku/node_modules/object-path/component.json +22 -0
- data/deps/node_modules/deku/node_modules/object-path/index.js +269 -0
- data/deps/node_modules/deku/node_modules/object-path/package.json +89 -0
- data/deps/node_modules/deku/node_modules/object-path/test.js +510 -0
- data/deps/node_modules/deku/node_modules/per-frame/.npmignore +68 -0
- data/deps/node_modules/deku/node_modules/per-frame/History.md +32 -0
- data/deps/node_modules/deku/node_modules/per-frame/README.md +44 -0
- data/deps/node_modules/deku/node_modules/per-frame/component.json +13 -0
- data/deps/node_modules/deku/node_modules/per-frame/index.js +37 -0
- data/deps/node_modules/deku/node_modules/per-frame/package.json +143 -0
- data/deps/node_modules/deku/node_modules/per-frame/test/test.js +94 -0
- data/deps/node_modules/deku/node_modules/sliced/.npmignore +2 -0
- data/deps/node_modules/deku/node_modules/sliced/.travis.yml +4 -0
- data/deps/node_modules/deku/node_modules/sliced/History.md +30 -0
- data/deps/node_modules/deku/node_modules/sliced/LICENSE +22 -0
- data/deps/node_modules/deku/node_modules/sliced/Makefile +5 -0
- data/deps/node_modules/deku/node_modules/sliced/README.md +62 -0
- data/deps/node_modules/deku/node_modules/sliced/bench.js +95 -0
- data/deps/node_modules/deku/node_modules/sliced/component.json +14 -0
- data/deps/node_modules/deku/node_modules/sliced/index.js +1 -0
- data/deps/node_modules/deku/node_modules/sliced/lib/sliced.js +33 -0
- data/deps/node_modules/deku/node_modules/sliced/package.json +52 -0
- data/deps/node_modules/deku/node_modules/sliced/test/index.js +80 -0
- data/deps/node_modules/deku/package.json +67 -0
- data/lib/deku.rb +11 -0
- data/lib/deku/application.rb +16 -0
- data/lib/deku/component.rb +36 -0
- data/lib/deku/context.rb +38 -0
- data/lib/deku/element_node.rb +17 -0
- data/lib/deku/version.rb +4 -0
- metadata +278 -0
|
@@ -0,0 +1,1450 @@
|
|
|
1
|
+
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.fast=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* # Clone Array
|
|
6
|
+
*
|
|
7
|
+
* Clone an array or array like object (e.g. `arguments`).
|
|
8
|
+
* This is the equivalent of calling `Array.prototype.slice.call(arguments)`, but
|
|
9
|
+
* significantly faster.
|
|
10
|
+
*
|
|
11
|
+
* @param {Array} input The array or array-like object to clone.
|
|
12
|
+
* @return {Array} The cloned array.
|
|
13
|
+
*/
|
|
14
|
+
module.exports = function fastCloneArray (input) {
|
|
15
|
+
var length = input.length,
|
|
16
|
+
sliced = new Array(length),
|
|
17
|
+
i;
|
|
18
|
+
for (i = 0; i < length; i++) {
|
|
19
|
+
sliced[i] = input[i];
|
|
20
|
+
}
|
|
21
|
+
return sliced;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
},{}],2:[function(_dereq_,module,exports){
|
|
25
|
+
'use strict';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* # Concat
|
|
29
|
+
*
|
|
30
|
+
* Concatenate multiple arrays.
|
|
31
|
+
*
|
|
32
|
+
* > Note: This function is effectively identical to `Array.prototype.concat()`.
|
|
33
|
+
*
|
|
34
|
+
*
|
|
35
|
+
* @param {Array|mixed} item, ... The item(s) to concatenate.
|
|
36
|
+
* @return {Array} The array containing the concatenated items.
|
|
37
|
+
*/
|
|
38
|
+
module.exports = function fastConcat () {
|
|
39
|
+
var length = arguments.length,
|
|
40
|
+
arr = [],
|
|
41
|
+
i, item, childLength, j;
|
|
42
|
+
|
|
43
|
+
for (i = 0; i < length; i++) {
|
|
44
|
+
item = arguments[i];
|
|
45
|
+
if (Array.isArray(item)) {
|
|
46
|
+
childLength = item.length;
|
|
47
|
+
for (j = 0; j < childLength; j++) {
|
|
48
|
+
arr.push(item[j]);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
arr.push(item);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return arr;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
},{}],3:[function(_dereq_,module,exports){
|
|
59
|
+
'use strict';
|
|
60
|
+
|
|
61
|
+
var bindInternal3 = _dereq_('../function/bindInternal3');
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* # Every
|
|
65
|
+
*
|
|
66
|
+
* A fast `.every()` implementation.
|
|
67
|
+
*
|
|
68
|
+
* @param {Array} subject The array (or array-like) to iterate over.
|
|
69
|
+
* @param {Function} fn The visitor function.
|
|
70
|
+
* @param {Object} thisContext The context for the visitor.
|
|
71
|
+
* @return {Boolean} true if all items in the array passes the truth test.
|
|
72
|
+
*/
|
|
73
|
+
module.exports = function fastEvery (subject, fn, thisContext) {
|
|
74
|
+
var length = subject.length,
|
|
75
|
+
iterator = thisContext !== undefined ? bindInternal3(fn, thisContext) : fn,
|
|
76
|
+
i;
|
|
77
|
+
for (i = 0; i < length; i++) {
|
|
78
|
+
if (!iterator(subject[i], i, subject)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
},{"../function/bindInternal3":22}],4:[function(_dereq_,module,exports){
|
|
86
|
+
'use strict';
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* # Fill
|
|
90
|
+
* Fill an array with values, optionally starting and stopping at a given index.
|
|
91
|
+
*
|
|
92
|
+
* > Note: unlike the specced Array.prototype.fill(), this version does not support
|
|
93
|
+
* > negative start / end arguments.
|
|
94
|
+
*
|
|
95
|
+
* @param {Array} subject The array to fill.
|
|
96
|
+
* @param {mixed} value The value to insert.
|
|
97
|
+
* @param {Integer} start The start position, defaults to 0.
|
|
98
|
+
* @param {Integer} end The end position, defaults to subject.length
|
|
99
|
+
* @return {Array} The now filled subject.
|
|
100
|
+
*/
|
|
101
|
+
module.exports = function fastFill (subject, value, start, end) {
|
|
102
|
+
var length = subject.length,
|
|
103
|
+
i;
|
|
104
|
+
if (start === undefined) {
|
|
105
|
+
start = 0;
|
|
106
|
+
}
|
|
107
|
+
if (end === undefined) {
|
|
108
|
+
end = length;
|
|
109
|
+
}
|
|
110
|
+
for (i = start; i < end; i++) {
|
|
111
|
+
subject[i] = value;
|
|
112
|
+
}
|
|
113
|
+
return subject;
|
|
114
|
+
};
|
|
115
|
+
},{}],5:[function(_dereq_,module,exports){
|
|
116
|
+
'use strict';
|
|
117
|
+
|
|
118
|
+
var bindInternal3 = _dereq_('../function/bindInternal3');
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* # Filter
|
|
122
|
+
*
|
|
123
|
+
* A fast `.filter()` implementation.
|
|
124
|
+
*
|
|
125
|
+
* @param {Array} subject The array (or array-like) to filter.
|
|
126
|
+
* @param {Function} fn The filter function.
|
|
127
|
+
* @param {Object} thisContext The context for the filter.
|
|
128
|
+
* @return {Array} The array containing the results.
|
|
129
|
+
*/
|
|
130
|
+
module.exports = function fastFilter (subject, fn, thisContext) {
|
|
131
|
+
var length = subject.length,
|
|
132
|
+
result = [],
|
|
133
|
+
iterator = thisContext !== undefined ? bindInternal3(fn, thisContext) : fn,
|
|
134
|
+
i;
|
|
135
|
+
for (i = 0; i < length; i++) {
|
|
136
|
+
if (iterator(subject[i], i, subject)) {
|
|
137
|
+
result.push(subject[i]);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
},{"../function/bindInternal3":22}],6:[function(_dereq_,module,exports){
|
|
144
|
+
'use strict';
|
|
145
|
+
|
|
146
|
+
var bindInternal3 = _dereq_('../function/bindInternal3');
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* # For Each
|
|
150
|
+
*
|
|
151
|
+
* A fast `.forEach()` implementation.
|
|
152
|
+
*
|
|
153
|
+
* @param {Array} subject The array (or array-like) to iterate over.
|
|
154
|
+
* @param {Function} fn The visitor function.
|
|
155
|
+
* @param {Object} thisContext The context for the visitor.
|
|
156
|
+
*/
|
|
157
|
+
module.exports = function fastForEach (subject, fn, thisContext) {
|
|
158
|
+
var length = subject.length,
|
|
159
|
+
iterator = thisContext !== undefined ? bindInternal3(fn, thisContext) : fn,
|
|
160
|
+
i;
|
|
161
|
+
for (i = 0; i < length; i++) {
|
|
162
|
+
iterator(subject[i], i, subject);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
},{"../function/bindInternal3":22}],7:[function(_dereq_,module,exports){
|
|
167
|
+
'use strict';
|
|
168
|
+
|
|
169
|
+
exports.clone = _dereq_('./clone');
|
|
170
|
+
exports.concat = _dereq_('./concat');
|
|
171
|
+
exports.every = _dereq_('./every');
|
|
172
|
+
exports.filter = _dereq_('./filter');
|
|
173
|
+
exports.forEach = _dereq_('./forEach');
|
|
174
|
+
exports.indexOf = _dereq_('./indexOf');
|
|
175
|
+
exports.lastIndexOf = _dereq_('./lastIndexOf');
|
|
176
|
+
exports.map = _dereq_('./map');
|
|
177
|
+
exports.pluck = _dereq_('./pluck');
|
|
178
|
+
exports.reduce = _dereq_('./reduce');
|
|
179
|
+
exports.reduceRight = _dereq_('./reduceRight');
|
|
180
|
+
exports.some = _dereq_('./some');
|
|
181
|
+
exports.fill = _dereq_('./fill');
|
|
182
|
+
},{"./clone":1,"./concat":2,"./every":3,"./fill":4,"./filter":5,"./forEach":6,"./indexOf":8,"./lastIndexOf":9,"./map":10,"./pluck":11,"./reduce":12,"./reduceRight":13,"./some":14}],8:[function(_dereq_,module,exports){
|
|
183
|
+
'use strict';
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* # Index Of
|
|
187
|
+
*
|
|
188
|
+
* A faster `Array.prototype.indexOf()` implementation.
|
|
189
|
+
*
|
|
190
|
+
* @param {Array} subject The array (or array-like) to search within.
|
|
191
|
+
* @param {mixed} target The target item to search for.
|
|
192
|
+
* @param {Number} fromIndex The position to start searching from, if known.
|
|
193
|
+
* @return {Number} The position of the target in the subject, or -1 if it does not exist.
|
|
194
|
+
*/
|
|
195
|
+
module.exports = function fastIndexOf (subject, target, fromIndex) {
|
|
196
|
+
var length = subject.length,
|
|
197
|
+
i = 0;
|
|
198
|
+
|
|
199
|
+
if (typeof fromIndex === 'number') {
|
|
200
|
+
i = fromIndex;
|
|
201
|
+
if (i < 0) {
|
|
202
|
+
i += length;
|
|
203
|
+
if (i < 0) {
|
|
204
|
+
i = 0;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
for (; i < length; i++) {
|
|
210
|
+
if (subject[i] === target) {
|
|
211
|
+
return i;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return -1;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
},{}],9:[function(_dereq_,module,exports){
|
|
218
|
+
'use strict';
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* # Last Index Of
|
|
222
|
+
*
|
|
223
|
+
* A faster `Array.prototype.lastIndexOf()` implementation.
|
|
224
|
+
*
|
|
225
|
+
* @param {Array} subject The array (or array-like) to search within.
|
|
226
|
+
* @param {mixed} target The target item to search for.
|
|
227
|
+
* @param {Number} fromIndex The position to start searching backwards from, if known.
|
|
228
|
+
* @return {Number} The last position of the target in the subject, or -1 if it does not exist.
|
|
229
|
+
*/
|
|
230
|
+
module.exports = function fastLastIndexOf (subject, target, fromIndex) {
|
|
231
|
+
var length = subject.length,
|
|
232
|
+
i = length - 1;
|
|
233
|
+
|
|
234
|
+
if (typeof fromIndex === 'number') {
|
|
235
|
+
i = fromIndex;
|
|
236
|
+
if (i < 0) {
|
|
237
|
+
i += length;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
for (; i >= 0; i--) {
|
|
241
|
+
if (subject[i] === target) {
|
|
242
|
+
return i;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return -1;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
},{}],10:[function(_dereq_,module,exports){
|
|
249
|
+
'use strict';
|
|
250
|
+
|
|
251
|
+
var bindInternal3 = _dereq_('../function/bindInternal3');
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* # Map
|
|
255
|
+
*
|
|
256
|
+
* A fast `.map()` implementation.
|
|
257
|
+
*
|
|
258
|
+
* @param {Array} subject The array (or array-like) to map over.
|
|
259
|
+
* @param {Function} fn The mapper function.
|
|
260
|
+
* @param {Object} thisContext The context for the mapper.
|
|
261
|
+
* @return {Array} The array containing the results.
|
|
262
|
+
*/
|
|
263
|
+
module.exports = function fastMap (subject, fn, thisContext) {
|
|
264
|
+
var length = subject.length,
|
|
265
|
+
result = new Array(length),
|
|
266
|
+
iterator = thisContext !== undefined ? bindInternal3(fn, thisContext) : fn,
|
|
267
|
+
i;
|
|
268
|
+
for (i = 0; i < length; i++) {
|
|
269
|
+
result[i] = iterator(subject[i], i, subject);
|
|
270
|
+
}
|
|
271
|
+
return result;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
},{"../function/bindInternal3":22}],11:[function(_dereq_,module,exports){
|
|
275
|
+
'use strict';
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* # Pluck
|
|
279
|
+
* Pluck the property with the given name from an array of objects.
|
|
280
|
+
*
|
|
281
|
+
* @param {Array} input The values to pluck from.
|
|
282
|
+
* @param {String} field The name of the field to pluck.
|
|
283
|
+
* @return {Array} The plucked array of values.
|
|
284
|
+
*/
|
|
285
|
+
module.exports = function fastPluck (input, field) {
|
|
286
|
+
var length = input.length,
|
|
287
|
+
plucked = [],
|
|
288
|
+
count = 0,
|
|
289
|
+
value, i;
|
|
290
|
+
|
|
291
|
+
for (i = 0; i < length; i++) {
|
|
292
|
+
value = input[i];
|
|
293
|
+
if (value != null && value[field] !== undefined) {
|
|
294
|
+
plucked[count++] = value[field];
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return plucked;
|
|
298
|
+
};
|
|
299
|
+
},{}],12:[function(_dereq_,module,exports){
|
|
300
|
+
'use strict';
|
|
301
|
+
|
|
302
|
+
var bindInternal4 = _dereq_('../function/bindInternal4');
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* # Reduce
|
|
306
|
+
*
|
|
307
|
+
* A fast `.reduce()` implementation.
|
|
308
|
+
*
|
|
309
|
+
* @param {Array} subject The array (or array-like) to reduce.
|
|
310
|
+
* @param {Function} fn The reducer function.
|
|
311
|
+
* @param {mixed} initialValue The initial value for the reducer, defaults to subject[0].
|
|
312
|
+
* @param {Object} thisContext The context for the reducer.
|
|
313
|
+
* @return {mixed} The final result.
|
|
314
|
+
*/
|
|
315
|
+
module.exports = function fastReduce (subject, fn, initialValue, thisContext) {
|
|
316
|
+
var length = subject.length,
|
|
317
|
+
iterator = thisContext !== undefined ? bindInternal4(fn, thisContext) : fn,
|
|
318
|
+
i, result;
|
|
319
|
+
|
|
320
|
+
if (initialValue === undefined) {
|
|
321
|
+
i = 1;
|
|
322
|
+
result = subject[0];
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
i = 0;
|
|
326
|
+
result = initialValue;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
for (; i < length; i++) {
|
|
330
|
+
result = iterator(result, subject[i], i, subject);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return result;
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
},{"../function/bindInternal4":23}],13:[function(_dereq_,module,exports){
|
|
337
|
+
'use strict';
|
|
338
|
+
|
|
339
|
+
var bindInternal4 = _dereq_('../function/bindInternal4');
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* # Reduce Right
|
|
343
|
+
*
|
|
344
|
+
* A fast `.reduceRight()` implementation.
|
|
345
|
+
*
|
|
346
|
+
* @param {Array} subject The array (or array-like) to reduce.
|
|
347
|
+
* @param {Function} fn The reducer function.
|
|
348
|
+
* @param {mixed} initialValue The initial value for the reducer, defaults to subject[0].
|
|
349
|
+
* @param {Object} thisContext The context for the reducer.
|
|
350
|
+
* @return {mixed} The final result.
|
|
351
|
+
*/
|
|
352
|
+
module.exports = function fastReduce (subject, fn, initialValue, thisContext) {
|
|
353
|
+
var length = subject.length,
|
|
354
|
+
iterator = thisContext !== undefined ? bindInternal4(fn, thisContext) : fn,
|
|
355
|
+
i, result;
|
|
356
|
+
|
|
357
|
+
if (initialValue === undefined) {
|
|
358
|
+
i = length - 2;
|
|
359
|
+
result = subject[length - 1];
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
i = length - 1;
|
|
363
|
+
result = initialValue;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
for (; i >= 0; i--) {
|
|
367
|
+
result = iterator(result, subject[i], i, subject);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return result;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
},{"../function/bindInternal4":23}],14:[function(_dereq_,module,exports){
|
|
374
|
+
'use strict';
|
|
375
|
+
|
|
376
|
+
var bindInternal3 = _dereq_('../function/bindInternal3');
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* # Some
|
|
380
|
+
*
|
|
381
|
+
* A fast `.some()` implementation.
|
|
382
|
+
*
|
|
383
|
+
* @param {Array} subject The array (or array-like) to iterate over.
|
|
384
|
+
* @param {Function} fn The visitor function.
|
|
385
|
+
* @param {Object} thisContext The context for the visitor.
|
|
386
|
+
* @return {Boolean} true if at least one item in the array passes the truth test.
|
|
387
|
+
*/
|
|
388
|
+
module.exports = function fastSome (subject, fn, thisContext) {
|
|
389
|
+
var length = subject.length,
|
|
390
|
+
iterator = thisContext !== undefined ? bindInternal3(fn, thisContext) : fn,
|
|
391
|
+
i;
|
|
392
|
+
for (i = 0; i < length; i++) {
|
|
393
|
+
if (iterator(subject[i], i, subject)) {
|
|
394
|
+
return true;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return false;
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
},{"../function/bindInternal3":22}],15:[function(_dereq_,module,exports){
|
|
401
|
+
'use strict';
|
|
402
|
+
|
|
403
|
+
var cloneArray = _dereq_('./array/clone');
|
|
404
|
+
var cloneObject = _dereq_('./object/clone');
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* # Clone
|
|
408
|
+
*
|
|
409
|
+
* Clone an item. Primitive values will be returned directly,
|
|
410
|
+
* arrays and objects will be shallow cloned. If you know the
|
|
411
|
+
* type of input you're dealing with, call `.cloneArray()` or `.cloneObject()`
|
|
412
|
+
* instead.
|
|
413
|
+
*
|
|
414
|
+
* @param {mixed} input The input to clone.
|
|
415
|
+
* @return {mixed} The cloned input.
|
|
416
|
+
*/
|
|
417
|
+
module.exports = function clone (input) {
|
|
418
|
+
if (!input || typeof input !== 'object') {
|
|
419
|
+
return input;
|
|
420
|
+
}
|
|
421
|
+
else if (Array.isArray(input)) {
|
|
422
|
+
return cloneArray(input);
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
return cloneObject(input);
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
},{"./array/clone":1,"./object/clone":31}],16:[function(_dereq_,module,exports){
|
|
430
|
+
'use strict';
|
|
431
|
+
|
|
432
|
+
var filterArray = _dereq_('./array/filter'),
|
|
433
|
+
filterObject = _dereq_('./object/filter');
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* # Filter
|
|
437
|
+
*
|
|
438
|
+
* A fast `.filter()` implementation.
|
|
439
|
+
*
|
|
440
|
+
* @param {Array|Object} subject The array or object to filter.
|
|
441
|
+
* @param {Function} fn The filter function.
|
|
442
|
+
* @param {Object} thisContext The context for the filter.
|
|
443
|
+
* @return {Array|Object} The array or object containing the filtered results.
|
|
444
|
+
*/
|
|
445
|
+
module.exports = function fastFilter (subject, fn, thisContext) {
|
|
446
|
+
if (subject instanceof Array) {
|
|
447
|
+
return filterArray(subject, fn, thisContext);
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
return filterObject(subject, fn, thisContext);
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
},{"./array/filter":5,"./object/filter":32}],17:[function(_dereq_,module,exports){
|
|
454
|
+
'use strict';
|
|
455
|
+
|
|
456
|
+
var forEachArray = _dereq_('./array/forEach'),
|
|
457
|
+
forEachObject = _dereq_('./object/forEach');
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* # ForEach
|
|
461
|
+
*
|
|
462
|
+
* A fast `.forEach()` implementation.
|
|
463
|
+
*
|
|
464
|
+
* @param {Array|Object} subject The array or object to iterate over.
|
|
465
|
+
* @param {Function} fn The visitor function.
|
|
466
|
+
* @param {Object} thisContext The context for the visitor.
|
|
467
|
+
*/
|
|
468
|
+
module.exports = function fastForEach (subject, fn, thisContext) {
|
|
469
|
+
if (subject instanceof Array) {
|
|
470
|
+
return forEachArray(subject, fn, thisContext);
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
return forEachObject(subject, fn, thisContext);
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
},{"./array/forEach":6,"./object/forEach":33}],18:[function(_dereq_,module,exports){
|
|
477
|
+
'use strict';
|
|
478
|
+
|
|
479
|
+
var applyWithContext = _dereq_('./applyWithContext');
|
|
480
|
+
var applyNoContext = _dereq_('./applyNoContext');
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* # Apply
|
|
484
|
+
*
|
|
485
|
+
* Faster version of `Function::apply()`, optimised for 8 arguments or fewer.
|
|
486
|
+
*
|
|
487
|
+
*
|
|
488
|
+
* @param {Function} subject The function to apply.
|
|
489
|
+
* @param {Object} thisContext The context for the function, set to undefined or null if no context is required.
|
|
490
|
+
* @param {Array} args The arguments for the function.
|
|
491
|
+
* @return {mixed} The result of the function invocation.
|
|
492
|
+
*/
|
|
493
|
+
module.exports = function fastApply (subject, thisContext, args) {
|
|
494
|
+
return thisContext !== undefined ? applyWithContext(subject, thisContext, args) : applyNoContext(subject, args);
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
},{"./applyNoContext":19,"./applyWithContext":20}],19:[function(_dereq_,module,exports){
|
|
498
|
+
'use strict';
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Internal helper for applying a function without a context.
|
|
502
|
+
*/
|
|
503
|
+
module.exports = function applyNoContext (subject, args) {
|
|
504
|
+
switch (args.length) {
|
|
505
|
+
case 0:
|
|
506
|
+
return subject();
|
|
507
|
+
case 1:
|
|
508
|
+
return subject(args[0]);
|
|
509
|
+
case 2:
|
|
510
|
+
return subject(args[0], args[1]);
|
|
511
|
+
case 3:
|
|
512
|
+
return subject(args[0], args[1], args[2]);
|
|
513
|
+
case 4:
|
|
514
|
+
return subject(args[0], args[1], args[2], args[3]);
|
|
515
|
+
case 5:
|
|
516
|
+
return subject(args[0], args[1], args[2], args[3], args[4]);
|
|
517
|
+
case 6:
|
|
518
|
+
return subject(args[0], args[1], args[2], args[3], args[4], args[5]);
|
|
519
|
+
case 7:
|
|
520
|
+
return subject(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
521
|
+
case 8:
|
|
522
|
+
return subject(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
|
|
523
|
+
default:
|
|
524
|
+
return subject.apply(undefined, args);
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
},{}],20:[function(_dereq_,module,exports){
|
|
529
|
+
'use strict';
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Internal helper for applying a function with a context.
|
|
533
|
+
*/
|
|
534
|
+
module.exports = function applyWithContext (subject, thisContext, args) {
|
|
535
|
+
switch (args.length) {
|
|
536
|
+
case 0:
|
|
537
|
+
return subject.call(thisContext);
|
|
538
|
+
case 1:
|
|
539
|
+
return subject.call(thisContext, args[0]);
|
|
540
|
+
case 2:
|
|
541
|
+
return subject.call(thisContext, args[0], args[1]);
|
|
542
|
+
case 3:
|
|
543
|
+
return subject.call(thisContext, args[0], args[1], args[2]);
|
|
544
|
+
case 4:
|
|
545
|
+
return subject.call(thisContext, args[0], args[1], args[2], args[3]);
|
|
546
|
+
case 5:
|
|
547
|
+
return subject.call(thisContext, args[0], args[1], args[2], args[3], args[4]);
|
|
548
|
+
case 6:
|
|
549
|
+
return subject.call(thisContext, args[0], args[1], args[2], args[3], args[4], args[5]);
|
|
550
|
+
case 7:
|
|
551
|
+
return subject.call(thisContext, args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
552
|
+
case 8:
|
|
553
|
+
return subject.call(thisContext, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
|
|
554
|
+
default:
|
|
555
|
+
return subject.apply(thisContext, args);
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
},{}],21:[function(_dereq_,module,exports){
|
|
560
|
+
'use strict';
|
|
561
|
+
|
|
562
|
+
var applyWithContext = _dereq_('./applyWithContext');
|
|
563
|
+
var applyNoContext = _dereq_('./applyNoContext');
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* # Bind
|
|
567
|
+
* Analogue of `Function::bind()`.
|
|
568
|
+
*
|
|
569
|
+
* ```js
|
|
570
|
+
* var bind = require('fast.js').bind;
|
|
571
|
+
* var bound = bind(myfunc, this, 1, 2, 3);
|
|
572
|
+
*
|
|
573
|
+
* bound(4);
|
|
574
|
+
* ```
|
|
575
|
+
*
|
|
576
|
+
*
|
|
577
|
+
* @param {Function} fn The function which should be bound.
|
|
578
|
+
* @param {Object} thisContext The context to bind the function to.
|
|
579
|
+
* @param {mixed} args, ... Additional arguments to pre-bind.
|
|
580
|
+
* @return {Function} The bound function.
|
|
581
|
+
*/
|
|
582
|
+
module.exports = function fastBind (fn, thisContext) {
|
|
583
|
+
var boundLength = arguments.length - 2,
|
|
584
|
+
boundArgs;
|
|
585
|
+
|
|
586
|
+
if (boundLength > 0) {
|
|
587
|
+
boundArgs = new Array(boundLength);
|
|
588
|
+
for (var i = 0; i < boundLength; i++) {
|
|
589
|
+
boundArgs[i] = arguments[i + 2];
|
|
590
|
+
}
|
|
591
|
+
if (thisContext !== undefined) {
|
|
592
|
+
return function () {
|
|
593
|
+
var length = arguments.length,
|
|
594
|
+
args = new Array(boundLength + length),
|
|
595
|
+
i;
|
|
596
|
+
for (i = 0; i < boundLength; i++) {
|
|
597
|
+
args[i] = boundArgs[i];
|
|
598
|
+
}
|
|
599
|
+
for (i = 0; i < length; i++) {
|
|
600
|
+
args[boundLength + i] = arguments[i];
|
|
601
|
+
}
|
|
602
|
+
return applyWithContext(fn, thisContext, args);
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
return function () {
|
|
607
|
+
var length = arguments.length,
|
|
608
|
+
args = new Array(boundLength + length),
|
|
609
|
+
i;
|
|
610
|
+
for (i = 0; i < boundLength; i++) {
|
|
611
|
+
args[i] = boundArgs[i];
|
|
612
|
+
}
|
|
613
|
+
for (i = 0; i < length; i++) {
|
|
614
|
+
args[boundLength + i] = arguments[i];
|
|
615
|
+
}
|
|
616
|
+
return applyNoContext(fn, args);
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
if (thisContext !== undefined) {
|
|
621
|
+
return function () {
|
|
622
|
+
return applyWithContext(fn, thisContext, arguments);
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
else {
|
|
626
|
+
return function () {
|
|
627
|
+
return applyNoContext(fn, arguments);
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
},{"./applyNoContext":19,"./applyWithContext":20}],22:[function(_dereq_,module,exports){
|
|
633
|
+
'use strict';
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Internal helper to bind a function known to have 3 arguments
|
|
637
|
+
* to a given context.
|
|
638
|
+
*/
|
|
639
|
+
module.exports = function bindInternal3 (func, thisContext) {
|
|
640
|
+
return function (a, b, c) {
|
|
641
|
+
return func.call(thisContext, a, b, c);
|
|
642
|
+
};
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
},{}],23:[function(_dereq_,module,exports){
|
|
646
|
+
'use strict';
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Internal helper to bind a function known to have 4 arguments
|
|
650
|
+
* to a given context.
|
|
651
|
+
*/
|
|
652
|
+
module.exports = function bindInternal4 (func, thisContext) {
|
|
653
|
+
return function (a, b, c, d) {
|
|
654
|
+
return func.call(thisContext, a, b, c, d);
|
|
655
|
+
};
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
},{}],24:[function(_dereq_,module,exports){
|
|
659
|
+
'use strict';
|
|
660
|
+
|
|
661
|
+
exports.apply = _dereq_('./apply');
|
|
662
|
+
exports.bind = _dereq_('./bind');
|
|
663
|
+
exports.partial = _dereq_('./partial');
|
|
664
|
+
exports.partialConstructor = _dereq_('./partialConstructor');
|
|
665
|
+
exports.try = _dereq_('./try');
|
|
666
|
+
|
|
667
|
+
},{"./apply":18,"./bind":21,"./partial":25,"./partialConstructor":26,"./try":27}],25:[function(_dereq_,module,exports){
|
|
668
|
+
'use strict';
|
|
669
|
+
|
|
670
|
+
var applyWithContext = _dereq_('./applyWithContext');
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* # Partial Application
|
|
674
|
+
*
|
|
675
|
+
* Partially apply a function. This is similar to `.bind()`,
|
|
676
|
+
* but with one important difference - the returned function is not bound
|
|
677
|
+
* to a particular context. This makes it easy to add partially
|
|
678
|
+
* applied methods to objects. If you need to bind to a context,
|
|
679
|
+
* use `.bind()` instead.
|
|
680
|
+
*
|
|
681
|
+
* > Note: This function does not support partial application for
|
|
682
|
+
* constructors, for that see `partialConstructor()`
|
|
683
|
+
*
|
|
684
|
+
*
|
|
685
|
+
* @param {Function} fn The function to partially apply.
|
|
686
|
+
* @param {mixed} args, ... Arguments to pre-bind.
|
|
687
|
+
* @return {Function} The partially applied function.
|
|
688
|
+
*/
|
|
689
|
+
module.exports = function fastPartial (fn) {
|
|
690
|
+
var boundLength = arguments.length - 1,
|
|
691
|
+
boundArgs;
|
|
692
|
+
|
|
693
|
+
boundArgs = new Array(boundLength);
|
|
694
|
+
for (var i = 0; i < boundLength; i++) {
|
|
695
|
+
boundArgs[i] = arguments[i + 1];
|
|
696
|
+
}
|
|
697
|
+
return function () {
|
|
698
|
+
var length = arguments.length,
|
|
699
|
+
args = new Array(boundLength + length),
|
|
700
|
+
i;
|
|
701
|
+
for (i = 0; i < boundLength; i++) {
|
|
702
|
+
args[i] = boundArgs[i];
|
|
703
|
+
}
|
|
704
|
+
for (i = 0; i < length; i++) {
|
|
705
|
+
args[boundLength + i] = arguments[i];
|
|
706
|
+
}
|
|
707
|
+
return applyWithContext(fn, this, args);
|
|
708
|
+
};
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
},{"./applyWithContext":20}],26:[function(_dereq_,module,exports){
|
|
712
|
+
'use strict';
|
|
713
|
+
|
|
714
|
+
var applyWithContext = _dereq_('./applyWithContext');
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* # Partial Constructor
|
|
718
|
+
*
|
|
719
|
+
* Partially apply a constructor function. The returned function
|
|
720
|
+
* will work with or without the `new` keyword.
|
|
721
|
+
*
|
|
722
|
+
*
|
|
723
|
+
* @param {Function} fn The constructor function to partially apply.
|
|
724
|
+
* @param {mixed} args, ... Arguments to pre-bind.
|
|
725
|
+
* @return {Function} The partially applied constructor.
|
|
726
|
+
*/
|
|
727
|
+
module.exports = function fastPartialConstructor (fn) {
|
|
728
|
+
var boundLength = arguments.length - 1,
|
|
729
|
+
boundArgs;
|
|
730
|
+
|
|
731
|
+
boundArgs = new Array(boundLength);
|
|
732
|
+
for (var i = 0; i < boundLength; i++) {
|
|
733
|
+
boundArgs[i] = arguments[i + 1];
|
|
734
|
+
}
|
|
735
|
+
return function partialed () {
|
|
736
|
+
var length = arguments.length,
|
|
737
|
+
args = new Array(boundLength + length),
|
|
738
|
+
i;
|
|
739
|
+
for (i = 0; i < boundLength; i++) {
|
|
740
|
+
args[i] = boundArgs[i];
|
|
741
|
+
}
|
|
742
|
+
for (i = 0; i < length; i++) {
|
|
743
|
+
args[boundLength + i] = arguments[i];
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
var thisContext = Object.create(fn.prototype),
|
|
747
|
+
result = applyWithContext(fn, thisContext, args);
|
|
748
|
+
|
|
749
|
+
if (result != null && (typeof result === 'object' || typeof result === 'function')) {
|
|
750
|
+
return result;
|
|
751
|
+
}
|
|
752
|
+
else {
|
|
753
|
+
return thisContext;
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
},{"./applyWithContext":20}],27:[function(_dereq_,module,exports){
|
|
759
|
+
'use strict';
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* # Try
|
|
763
|
+
*
|
|
764
|
+
* Allows functions to be optimised by isolating `try {} catch (e) {}` blocks
|
|
765
|
+
* outside the function declaration. Returns either the result of the function or an Error
|
|
766
|
+
* object if one was thrown. The caller should then check for `result instanceof Error`.
|
|
767
|
+
*
|
|
768
|
+
* ```js
|
|
769
|
+
* var result = fast.try(myFunction);
|
|
770
|
+
* if (result instanceof Error) {
|
|
771
|
+
* console.log('something went wrong');
|
|
772
|
+
* }
|
|
773
|
+
* else {
|
|
774
|
+
* console.log('result:', result);
|
|
775
|
+
* }
|
|
776
|
+
* ```
|
|
777
|
+
*
|
|
778
|
+
* @param {Function} fn The function to invoke.
|
|
779
|
+
* @return {mixed} The result of the function, or an `Error` object.
|
|
780
|
+
*/
|
|
781
|
+
module.exports = function fastTry (fn) {
|
|
782
|
+
try {
|
|
783
|
+
return fn();
|
|
784
|
+
}
|
|
785
|
+
catch (e) {
|
|
786
|
+
if (!(e instanceof Error)) {
|
|
787
|
+
return new Error(e);
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
return e;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
},{}],28:[function(_dereq_,module,exports){
|
|
796
|
+
'use strict';
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* # Constructor
|
|
800
|
+
*
|
|
801
|
+
* Provided as a convenient wrapper around Fast functions.
|
|
802
|
+
*
|
|
803
|
+
* ```js
|
|
804
|
+
* var arr = fast([1,2,3,4,5,6]);
|
|
805
|
+
*
|
|
806
|
+
* var result = arr.filter(function (item) {
|
|
807
|
+
* return item % 2 === 0;
|
|
808
|
+
* });
|
|
809
|
+
*
|
|
810
|
+
* result instanceof Fast; // true
|
|
811
|
+
* result.length; // 3
|
|
812
|
+
* ```
|
|
813
|
+
*
|
|
814
|
+
*
|
|
815
|
+
* @param {Array} value The value to wrap.
|
|
816
|
+
*/
|
|
817
|
+
function Fast (value) {
|
|
818
|
+
if (!(this instanceof Fast)) {
|
|
819
|
+
return new Fast(value);
|
|
820
|
+
}
|
|
821
|
+
this.value = value || [];
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
module.exports = exports = Fast;
|
|
825
|
+
|
|
826
|
+
Fast.array = _dereq_('./array');
|
|
827
|
+
Fast['function'] = Fast.fn = _dereq_('./function');
|
|
828
|
+
Fast.object = _dereq_('./object');
|
|
829
|
+
Fast.string = _dereq_('./string');
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
Fast.apply = Fast['function'].apply;
|
|
833
|
+
Fast.bind = Fast['function'].bind;
|
|
834
|
+
Fast.partial = Fast['function'].partial;
|
|
835
|
+
Fast.partialConstructor = Fast['function'].partialConstructor;
|
|
836
|
+
Fast['try'] = Fast.attempt = Fast['function']['try'];
|
|
837
|
+
|
|
838
|
+
Fast.assign = Fast.object.assign;
|
|
839
|
+
Fast.cloneObject = Fast.object.clone; // @deprecated use fast.object.clone()
|
|
840
|
+
Fast.keys = Fast.object.keys;
|
|
841
|
+
Fast.values = Fast.object.values;
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
Fast.clone = _dereq_('./clone');
|
|
845
|
+
Fast.map = _dereq_('./map');
|
|
846
|
+
Fast.filter = _dereq_('./filter');
|
|
847
|
+
Fast.forEach = _dereq_('./forEach');
|
|
848
|
+
Fast.reduce = _dereq_('./reduce');
|
|
849
|
+
Fast.reduceRight = _dereq_('./reduceRight');
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
Fast.cloneArray = Fast.array.clone; // @deprecated use fast.array.clone()
|
|
853
|
+
|
|
854
|
+
Fast.concat = Fast.array.concat;
|
|
855
|
+
Fast.some = Fast.array.some;
|
|
856
|
+
Fast.every = Fast.array.every;
|
|
857
|
+
Fast.indexOf = Fast.array.indexOf;
|
|
858
|
+
Fast.lastIndexOf = Fast.array.lastIndexOf;
|
|
859
|
+
Fast.pluck = Fast.array.pluck;
|
|
860
|
+
Fast.fill = Fast.array.fill;
|
|
861
|
+
|
|
862
|
+
Fast.intern = Fast.string.intern;
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* # Concat
|
|
867
|
+
*
|
|
868
|
+
* Concatenate multiple arrays.
|
|
869
|
+
*
|
|
870
|
+
* @param {Array|mixed} item, ... The item(s) to concatenate.
|
|
871
|
+
* @return {Fast} A new Fast object, containing the results.
|
|
872
|
+
*/
|
|
873
|
+
Fast.prototype.concat = function Fast$concat () {
|
|
874
|
+
var length = this.value.length,
|
|
875
|
+
arr = new Array(length),
|
|
876
|
+
i, item, childLength, j;
|
|
877
|
+
|
|
878
|
+
for (i = 0; i < length; i++) {
|
|
879
|
+
arr[i] = this.value[i];
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
length = arguments.length;
|
|
883
|
+
for (i = 0; i < length; i++) {
|
|
884
|
+
item = arguments[i];
|
|
885
|
+
if (Array.isArray(item)) {
|
|
886
|
+
childLength = item.length;
|
|
887
|
+
for (j = 0; j < childLength; j++) {
|
|
888
|
+
arr.push(item[j]);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
else {
|
|
892
|
+
arr.push(item);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
return new Fast(arr);
|
|
896
|
+
};
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Fast Map
|
|
900
|
+
*
|
|
901
|
+
* @param {Function} fn The visitor function.
|
|
902
|
+
* @param {Object} thisContext The context for the visitor, if any.
|
|
903
|
+
* @return {Fast} A new Fast object, containing the results.
|
|
904
|
+
*/
|
|
905
|
+
Fast.prototype.map = function Fast$map (fn, thisContext) {
|
|
906
|
+
return new Fast(Fast.map(this.value, fn, thisContext));
|
|
907
|
+
};
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* Fast Filter
|
|
911
|
+
*
|
|
912
|
+
* @param {Function} fn The filter function.
|
|
913
|
+
* @param {Object} thisContext The context for the filter function, if any.
|
|
914
|
+
* @return {Fast} A new Fast object, containing the results.
|
|
915
|
+
*/
|
|
916
|
+
Fast.prototype.filter = function Fast$filter (fn, thisContext) {
|
|
917
|
+
return new Fast(Fast.filter(this.value, fn, thisContext));
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* Fast Reduce
|
|
922
|
+
*
|
|
923
|
+
* @param {Function} fn The reducer function.
|
|
924
|
+
* @param {mixed} initialValue The initial value, if any.
|
|
925
|
+
* @param {Object} thisContext The context for the reducer, if any.
|
|
926
|
+
* @return {mixed} The final result.
|
|
927
|
+
*/
|
|
928
|
+
Fast.prototype.reduce = function Fast$reduce (fn, initialValue, thisContext) {
|
|
929
|
+
return Fast.reduce(this.value, fn, initialValue, thisContext);
|
|
930
|
+
};
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* Fast Reduce Right
|
|
935
|
+
*
|
|
936
|
+
* @param {Function} fn The reducer function.
|
|
937
|
+
* @param {mixed} initialValue The initial value, if any.
|
|
938
|
+
* @param {Object} thisContext The context for the reducer, if any.
|
|
939
|
+
* @return {mixed} The final result.
|
|
940
|
+
*/
|
|
941
|
+
Fast.prototype.reduceRight = function Fast$reduceRight (fn, initialValue, thisContext) {
|
|
942
|
+
return Fast.reduceRight(this.value, fn, initialValue, thisContext);
|
|
943
|
+
};
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Fast For Each
|
|
947
|
+
*
|
|
948
|
+
* @param {Function} fn The visitor function.
|
|
949
|
+
* @param {Object} thisContext The context for the visitor, if any.
|
|
950
|
+
* @return {Fast} The Fast instance.
|
|
951
|
+
*/
|
|
952
|
+
Fast.prototype.forEach = function Fast$forEach (fn, thisContext) {
|
|
953
|
+
Fast.forEach(this.value, fn, thisContext);
|
|
954
|
+
return this;
|
|
955
|
+
};
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* Fast Some
|
|
959
|
+
*
|
|
960
|
+
* @param {Function} fn The matcher predicate.
|
|
961
|
+
* @param {Object} thisContext The context for the matcher, if any.
|
|
962
|
+
* @return {Boolean} True if at least one element matches.
|
|
963
|
+
*/
|
|
964
|
+
Fast.prototype.some = function Fast$some (fn, thisContext) {
|
|
965
|
+
return Fast.some(this.value, fn, thisContext);
|
|
966
|
+
};
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* Fast Every
|
|
970
|
+
*
|
|
971
|
+
* @param {Function} fn The matcher predicate.
|
|
972
|
+
* @param {Object} thisContext The context for the matcher, if any.
|
|
973
|
+
* @return {Boolean} True if at all elements match.
|
|
974
|
+
*/
|
|
975
|
+
Fast.prototype.every = function Fast$every (fn, thisContext) {
|
|
976
|
+
return Fast.some(this.value, fn, thisContext);
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* Fast Index Of
|
|
981
|
+
*
|
|
982
|
+
* @param {mixed} target The target to lookup.
|
|
983
|
+
* @param {Number} fromIndex The index to start searching from, if known.
|
|
984
|
+
* @return {Number} The index of the item, or -1 if no match found.
|
|
985
|
+
*/
|
|
986
|
+
Fast.prototype.indexOf = function Fast$indexOf (target, fromIndex) {
|
|
987
|
+
return Fast.indexOf(this.value, target, fromIndex);
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* Fast Last Index Of
|
|
993
|
+
*
|
|
994
|
+
* @param {mixed} target The target to lookup.
|
|
995
|
+
* @param {Number} fromIndex The index to start searching from, if known.
|
|
996
|
+
* @return {Number} The last index of the item, or -1 if no match found.
|
|
997
|
+
*/
|
|
998
|
+
Fast.prototype.lastIndexOf = function Fast$lastIndexOf (target, fromIndex) {
|
|
999
|
+
return Fast.lastIndexOf(this.value, target, fromIndex);
|
|
1000
|
+
};
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Reverse
|
|
1004
|
+
*
|
|
1005
|
+
* @return {Fast} A new Fast instance, with the contents reversed.
|
|
1006
|
+
*/
|
|
1007
|
+
Fast.prototype.reverse = function Fast$reverse () {
|
|
1008
|
+
return new Fast(this.value.reverse());
|
|
1009
|
+
};
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* Value Of
|
|
1013
|
+
*
|
|
1014
|
+
* @return {Array} The wrapped value.
|
|
1015
|
+
*/
|
|
1016
|
+
Fast.prototype.valueOf = function Fast$valueOf () {
|
|
1017
|
+
return this.value;
|
|
1018
|
+
};
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* To JSON
|
|
1022
|
+
*
|
|
1023
|
+
* @return {Array} The wrapped value.
|
|
1024
|
+
*/
|
|
1025
|
+
Fast.prototype.toJSON = function Fast$toJSON () {
|
|
1026
|
+
return this.value;
|
|
1027
|
+
};
|
|
1028
|
+
|
|
1029
|
+
/**
|
|
1030
|
+
* Item Length
|
|
1031
|
+
*/
|
|
1032
|
+
Object.defineProperty(Fast.prototype, 'length', {
|
|
1033
|
+
get: function () {
|
|
1034
|
+
return this.value.length;
|
|
1035
|
+
}
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1038
|
+
},{"./array":7,"./clone":15,"./filter":16,"./forEach":17,"./function":24,"./map":29,"./object":34,"./reduce":40,"./reduceRight":41,"./string":42}],29:[function(_dereq_,module,exports){
|
|
1039
|
+
'use strict';
|
|
1040
|
+
|
|
1041
|
+
var mapArray = _dereq_('./array/map'),
|
|
1042
|
+
mapObject = _dereq_('./object/map');
|
|
1043
|
+
|
|
1044
|
+
/**
|
|
1045
|
+
* # Map
|
|
1046
|
+
*
|
|
1047
|
+
* A fast `.map()` implementation.
|
|
1048
|
+
*
|
|
1049
|
+
* @param {Array|Object} subject The array or object to map over.
|
|
1050
|
+
* @param {Function} fn The mapper function.
|
|
1051
|
+
* @param {Object} thisContext The context for the mapper.
|
|
1052
|
+
* @return {Array|Object} The array or object containing the results.
|
|
1053
|
+
*/
|
|
1054
|
+
module.exports = function fastMap (subject, fn, thisContext) {
|
|
1055
|
+
if (subject instanceof Array) {
|
|
1056
|
+
return mapArray(subject, fn, thisContext);
|
|
1057
|
+
}
|
|
1058
|
+
else {
|
|
1059
|
+
return mapObject(subject, fn, thisContext);
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
},{"./array/map":10,"./object/map":36}],30:[function(_dereq_,module,exports){
|
|
1063
|
+
'use strict';
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* Analogue of Object.assign().
|
|
1067
|
+
* Copies properties from one or more source objects to
|
|
1068
|
+
* a target object. Existing keys on the target object will be overwritten.
|
|
1069
|
+
*
|
|
1070
|
+
* > Note: This differs from spec in some important ways:
|
|
1071
|
+
* > 1. Will throw if passed non-objects, including `undefined` or `null` values.
|
|
1072
|
+
* > 2. Does not support the curious Exception handling behavior, exceptions are thrown immediately.
|
|
1073
|
+
* > For more details, see:
|
|
1074
|
+
* > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
1075
|
+
*
|
|
1076
|
+
*
|
|
1077
|
+
*
|
|
1078
|
+
* @param {Object} target The target object to copy properties to.
|
|
1079
|
+
* @param {Object} source, ... The source(s) to copy properties from.
|
|
1080
|
+
* @return {Object} The updated target object.
|
|
1081
|
+
*/
|
|
1082
|
+
module.exports = function fastAssign (target) {
|
|
1083
|
+
var totalArgs = arguments.length,
|
|
1084
|
+
source, i, totalKeys, keys, key, j;
|
|
1085
|
+
|
|
1086
|
+
for (i = 1; i < totalArgs; i++) {
|
|
1087
|
+
source = arguments[i];
|
|
1088
|
+
keys = Object.keys(source);
|
|
1089
|
+
totalKeys = keys.length;
|
|
1090
|
+
for (j = 0; j < totalKeys; j++) {
|
|
1091
|
+
key = keys[j];
|
|
1092
|
+
target[key] = source[key];
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
return target;
|
|
1096
|
+
};
|
|
1097
|
+
|
|
1098
|
+
},{}],31:[function(_dereq_,module,exports){
|
|
1099
|
+
'use strict';
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* # Clone Object
|
|
1103
|
+
*
|
|
1104
|
+
* Shallow clone a simple object.
|
|
1105
|
+
*
|
|
1106
|
+
* > Note: Prototypes and non-enumerable properties will not be copied!
|
|
1107
|
+
*
|
|
1108
|
+
* @param {Object} input The object to clone.
|
|
1109
|
+
* @return {Object} The cloned object.
|
|
1110
|
+
*/
|
|
1111
|
+
module.exports = function fastCloneObject (input) {
|
|
1112
|
+
var keys = Object.keys(input),
|
|
1113
|
+
total = keys.length,
|
|
1114
|
+
cloned = {},
|
|
1115
|
+
i, key;
|
|
1116
|
+
|
|
1117
|
+
for (i = 0; i < total; i++) {
|
|
1118
|
+
key = keys[i];
|
|
1119
|
+
cloned[key] = input[key];
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
return cloned;
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
},{}],32:[function(_dereq_,module,exports){
|
|
1126
|
+
'use strict';
|
|
1127
|
+
|
|
1128
|
+
var bindInternal3 = _dereq_('../function/bindInternal3');
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* # Filter
|
|
1132
|
+
*
|
|
1133
|
+
* A fast object `.filter()` implementation.
|
|
1134
|
+
*
|
|
1135
|
+
* @param {Object} subject The object to filter.
|
|
1136
|
+
* @param {Function} fn The filter function.
|
|
1137
|
+
* @param {Object} thisContext The context for the filter.
|
|
1138
|
+
* @return {Object} The new object containing the filtered results.
|
|
1139
|
+
*/
|
|
1140
|
+
module.exports = function fastFilterObject (subject, fn, thisContext) {
|
|
1141
|
+
var keys = Object.keys(subject),
|
|
1142
|
+
length = keys.length,
|
|
1143
|
+
result = {},
|
|
1144
|
+
iterator = thisContext !== undefined ? bindInternal3(fn, thisContext) : fn,
|
|
1145
|
+
i, key;
|
|
1146
|
+
for (i = 0; i < length; i++) {
|
|
1147
|
+
key = keys[i];
|
|
1148
|
+
if (iterator(subject[key], key, subject)) {
|
|
1149
|
+
result[key] = subject[key];
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
return result;
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
},{"../function/bindInternal3":22}],33:[function(_dereq_,module,exports){
|
|
1156
|
+
'use strict';
|
|
1157
|
+
|
|
1158
|
+
var bindInternal3 = _dereq_('../function/bindInternal3');
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* # For Each
|
|
1162
|
+
*
|
|
1163
|
+
* A fast object `.forEach()` implementation.
|
|
1164
|
+
*
|
|
1165
|
+
* @param {Object} subject The object to iterate over.
|
|
1166
|
+
* @param {Function} fn The visitor function.
|
|
1167
|
+
* @param {Object} thisContext The context for the visitor.
|
|
1168
|
+
*/
|
|
1169
|
+
module.exports = function fastForEachObject (subject, fn, thisContext) {
|
|
1170
|
+
var keys = Object.keys(subject),
|
|
1171
|
+
length = keys.length,
|
|
1172
|
+
iterator = thisContext !== undefined ? bindInternal3(fn, thisContext) : fn,
|
|
1173
|
+
key, i;
|
|
1174
|
+
for (i = 0; i < length; i++) {
|
|
1175
|
+
key = keys[i];
|
|
1176
|
+
iterator(subject[key], key, subject);
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
|
|
1180
|
+
},{"../function/bindInternal3":22}],34:[function(_dereq_,module,exports){
|
|
1181
|
+
'use strict';
|
|
1182
|
+
|
|
1183
|
+
exports.assign = _dereq_('./assign');
|
|
1184
|
+
exports.clone = _dereq_('./clone');
|
|
1185
|
+
exports.filter = _dereq_('./filter');
|
|
1186
|
+
exports.forEach = _dereq_('./forEach');
|
|
1187
|
+
exports.map = _dereq_('./map');
|
|
1188
|
+
exports.reduce = _dereq_('./reduce');
|
|
1189
|
+
exports.reduceRight = _dereq_('./reduceRight');
|
|
1190
|
+
exports.keys = _dereq_('./keys');
|
|
1191
|
+
exports.values = _dereq_('./values');
|
|
1192
|
+
},{"./assign":30,"./clone":31,"./filter":32,"./forEach":33,"./keys":35,"./map":36,"./reduce":37,"./reduceRight":38,"./values":39}],35:[function(_dereq_,module,exports){
|
|
1193
|
+
'use strict';
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* Object.keys() shim for ES3 environments.
|
|
1197
|
+
*
|
|
1198
|
+
* @param {Object} obj The object to get keys for.
|
|
1199
|
+
* @return {Array} The array of keys.
|
|
1200
|
+
*/
|
|
1201
|
+
module.exports = typeof Object.keys === "function" ? Object.keys : /* istanbul ignore next */ function fastKeys (obj) {
|
|
1202
|
+
var keys = [];
|
|
1203
|
+
for (var key in obj) {
|
|
1204
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1205
|
+
keys.push(key);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
return keys;
|
|
1209
|
+
};
|
|
1210
|
+
},{}],36:[function(_dereq_,module,exports){
|
|
1211
|
+
'use strict';
|
|
1212
|
+
|
|
1213
|
+
var bindInternal3 = _dereq_('../function/bindInternal3');
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* # Map
|
|
1217
|
+
*
|
|
1218
|
+
* A fast object `.map()` implementation.
|
|
1219
|
+
*
|
|
1220
|
+
* @param {Object} subject The object to map over.
|
|
1221
|
+
* @param {Function} fn The mapper function.
|
|
1222
|
+
* @param {Object} thisContext The context for the mapper.
|
|
1223
|
+
* @return {Object} The new object containing the results.
|
|
1224
|
+
*/
|
|
1225
|
+
module.exports = function fastMapObject (subject, fn, thisContext) {
|
|
1226
|
+
var keys = Object.keys(subject),
|
|
1227
|
+
length = keys.length,
|
|
1228
|
+
result = {},
|
|
1229
|
+
iterator = thisContext !== undefined ? bindInternal3(fn, thisContext) : fn,
|
|
1230
|
+
i, key;
|
|
1231
|
+
for (i = 0; i < length; i++) {
|
|
1232
|
+
key = keys[i];
|
|
1233
|
+
result[key] = iterator(subject[key], key, subject);
|
|
1234
|
+
}
|
|
1235
|
+
return result;
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
},{"../function/bindInternal3":22}],37:[function(_dereq_,module,exports){
|
|
1239
|
+
'use strict';
|
|
1240
|
+
|
|
1241
|
+
var bindInternal4 = _dereq_('../function/bindInternal4');
|
|
1242
|
+
|
|
1243
|
+
/**
|
|
1244
|
+
* # Reduce
|
|
1245
|
+
*
|
|
1246
|
+
* A fast object `.reduce()` implementation.
|
|
1247
|
+
*
|
|
1248
|
+
* @param {Object} subject The object to reduce over.
|
|
1249
|
+
* @param {Function} fn The reducer function.
|
|
1250
|
+
* @param {mixed} initialValue The initial value for the reducer, defaults to subject[0].
|
|
1251
|
+
* @param {Object} thisContext The context for the reducer.
|
|
1252
|
+
* @return {mixed} The final result.
|
|
1253
|
+
*/
|
|
1254
|
+
module.exports = function fastReduceObject (subject, fn, initialValue, thisContext) {
|
|
1255
|
+
var keys = Object.keys(subject),
|
|
1256
|
+
length = keys.length,
|
|
1257
|
+
iterator = thisContext !== undefined ? bindInternal4(fn, thisContext) : fn,
|
|
1258
|
+
i, key, result;
|
|
1259
|
+
|
|
1260
|
+
if (initialValue === undefined) {
|
|
1261
|
+
i = 1;
|
|
1262
|
+
result = subject[keys[0]];
|
|
1263
|
+
}
|
|
1264
|
+
else {
|
|
1265
|
+
i = 0;
|
|
1266
|
+
result = initialValue;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
for (; i < length; i++) {
|
|
1270
|
+
key = keys[i];
|
|
1271
|
+
result = iterator(result, subject[key], key, subject);
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
return result;
|
|
1275
|
+
};
|
|
1276
|
+
|
|
1277
|
+
},{"../function/bindInternal4":23}],38:[function(_dereq_,module,exports){
|
|
1278
|
+
'use strict';
|
|
1279
|
+
|
|
1280
|
+
var bindInternal4 = _dereq_('../function/bindInternal4');
|
|
1281
|
+
|
|
1282
|
+
/**
|
|
1283
|
+
* # Reduce
|
|
1284
|
+
*
|
|
1285
|
+
* A fast object `.reduce()` implementation.
|
|
1286
|
+
*
|
|
1287
|
+
* @param {Object} subject The object to reduce over.
|
|
1288
|
+
* @param {Function} fn The reducer function.
|
|
1289
|
+
* @param {mixed} initialValue The initial value for the reducer, defaults to subject[0].
|
|
1290
|
+
* @param {Object} thisContext The context for the reducer.
|
|
1291
|
+
* @return {mixed} The final result.
|
|
1292
|
+
*/
|
|
1293
|
+
module.exports = function fastReduceRightObject (subject, fn, initialValue, thisContext) {
|
|
1294
|
+
var keys = Object.keys(subject),
|
|
1295
|
+
length = keys.length,
|
|
1296
|
+
iterator = thisContext !== undefined ? bindInternal4(fn, thisContext) : fn,
|
|
1297
|
+
i, key, result;
|
|
1298
|
+
|
|
1299
|
+
if (initialValue === undefined) {
|
|
1300
|
+
i = length - 2;
|
|
1301
|
+
result = subject[keys[length - 1]];
|
|
1302
|
+
}
|
|
1303
|
+
else {
|
|
1304
|
+
i = length - 1;
|
|
1305
|
+
result = initialValue;
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
for (; i >= 0; i--) {
|
|
1309
|
+
key = keys[i];
|
|
1310
|
+
result = iterator(result, subject[key], key, subject);
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
return result;
|
|
1314
|
+
};
|
|
1315
|
+
|
|
1316
|
+
},{"../function/bindInternal4":23}],39:[function(_dereq_,module,exports){
|
|
1317
|
+
'use strict';
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* # Values
|
|
1321
|
+
* Return all the (enumerable) property values for an object.
|
|
1322
|
+
* Like Object.keys() but for values.
|
|
1323
|
+
*
|
|
1324
|
+
* @param {Object} obj The object to retrieve values from.
|
|
1325
|
+
* @return {Array} An array containing property values.
|
|
1326
|
+
*/
|
|
1327
|
+
module.exports = function fastValues (obj) {
|
|
1328
|
+
var keys = Object.keys(obj),
|
|
1329
|
+
length = keys.length,
|
|
1330
|
+
values = new Array(length);
|
|
1331
|
+
|
|
1332
|
+
for (var i = 0; i < length; i++) {
|
|
1333
|
+
values[i] = obj[keys[i]];
|
|
1334
|
+
}
|
|
1335
|
+
return values;
|
|
1336
|
+
};
|
|
1337
|
+
},{}],40:[function(_dereq_,module,exports){
|
|
1338
|
+
'use strict';
|
|
1339
|
+
|
|
1340
|
+
var reduceArray = _dereq_('./array/reduce'),
|
|
1341
|
+
reduceObject = _dereq_('./object/reduce');
|
|
1342
|
+
|
|
1343
|
+
/**
|
|
1344
|
+
* # Reduce
|
|
1345
|
+
*
|
|
1346
|
+
* A fast `.reduce()` implementation.
|
|
1347
|
+
*
|
|
1348
|
+
* @param {Array|Object} subject The array or object to reduce over.
|
|
1349
|
+
* @param {Function} fn The reducer function.
|
|
1350
|
+
* @param {mixed} initialValue The initial value for the reducer, defaults to subject[0].
|
|
1351
|
+
* @param {Object} thisContext The context for the reducer.
|
|
1352
|
+
* @return {Array|Object} The array or object containing the results.
|
|
1353
|
+
*/
|
|
1354
|
+
module.exports = function fastReduce (subject, fn, initialValue, thisContext) {
|
|
1355
|
+
if (subject instanceof Array) {
|
|
1356
|
+
return reduceArray(subject, fn, initialValue, thisContext);
|
|
1357
|
+
}
|
|
1358
|
+
else {
|
|
1359
|
+
return reduceObject(subject, fn, initialValue, thisContext);
|
|
1360
|
+
}
|
|
1361
|
+
};
|
|
1362
|
+
},{"./array/reduce":12,"./object/reduce":37}],41:[function(_dereq_,module,exports){
|
|
1363
|
+
'use strict';
|
|
1364
|
+
|
|
1365
|
+
var reduceRightArray = _dereq_('./array/reduceRight'),
|
|
1366
|
+
reduceRightObject = _dereq_('./object/reduceRight');
|
|
1367
|
+
|
|
1368
|
+
/**
|
|
1369
|
+
* # Reduce Right
|
|
1370
|
+
*
|
|
1371
|
+
* A fast `.reduceRight()` implementation.
|
|
1372
|
+
*
|
|
1373
|
+
* @param {Array|Object} subject The array or object to reduce over.
|
|
1374
|
+
* @param {Function} fn The reducer function.
|
|
1375
|
+
* @param {mixed} initialValue The initial value for the reducer, defaults to subject[0].
|
|
1376
|
+
* @param {Object} thisContext The context for the reducer.
|
|
1377
|
+
* @return {Array|Object} The array or object containing the results.
|
|
1378
|
+
*/
|
|
1379
|
+
module.exports = function fastReduceRight (subject, fn, initialValue, thisContext) {
|
|
1380
|
+
if (subject instanceof Array) {
|
|
1381
|
+
return reduceRightArray(subject, fn, initialValue, thisContext);
|
|
1382
|
+
}
|
|
1383
|
+
else {
|
|
1384
|
+
return reduceRightObject(subject, fn, initialValue, thisContext);
|
|
1385
|
+
}
|
|
1386
|
+
};
|
|
1387
|
+
},{"./array/reduceRight":13,"./object/reduceRight":38}],42:[function(_dereq_,module,exports){
|
|
1388
|
+
'use strict';
|
|
1389
|
+
|
|
1390
|
+
exports.intern = _dereq_('./intern');
|
|
1391
|
+
},{"./intern":43}],43:[function(_dereq_,module,exports){
|
|
1392
|
+
'use strict';
|
|
1393
|
+
|
|
1394
|
+
// Compilers such as V8 use string interning to make string comparison very fast and efficient,
|
|
1395
|
+
// as efficient as comparing two references to the same object.
|
|
1396
|
+
//
|
|
1397
|
+
//
|
|
1398
|
+
// V8 does its best to intern strings automatically where it can, for instance:
|
|
1399
|
+
// ```js
|
|
1400
|
+
// var greeting = "hello world";
|
|
1401
|
+
// ```
|
|
1402
|
+
// With this, comparison will be very fast:
|
|
1403
|
+
// ```js
|
|
1404
|
+
// if (greeting === "hello world") {}
|
|
1405
|
+
// ```
|
|
1406
|
+
// However, there are several cases where V8 cannot intern the string, and instead
|
|
1407
|
+
// must resort to byte-wise comparison. This can be signficantly slower for long strings.
|
|
1408
|
+
// The most common example is string concatenation:
|
|
1409
|
+
// ```js
|
|
1410
|
+
// function subject () { return "world"; };
|
|
1411
|
+
// var greeting = "hello " + subject();
|
|
1412
|
+
// ```
|
|
1413
|
+
// In this case, V8 cannot intern the string. So this comparison is *much* slower:
|
|
1414
|
+
// ```js
|
|
1415
|
+
// if (greeting === "hello world") {}
|
|
1416
|
+
// ```
|
|
1417
|
+
|
|
1418
|
+
|
|
1419
|
+
|
|
1420
|
+
// At the moment, the fastest, safe way of interning a string is to
|
|
1421
|
+
// use it as a key in an object, and then use that key.
|
|
1422
|
+
//
|
|
1423
|
+
// Note: This technique comes courtesy of Petka Antonov - http://jsperf.com/istrn/11
|
|
1424
|
+
//
|
|
1425
|
+
// We create a container object in hash mode.
|
|
1426
|
+
// Most strings being interned will not be valid fast property names,
|
|
1427
|
+
// so we ensure hash mode now to avoid transitioning the object mode at runtime.
|
|
1428
|
+
var container = {'- ': true};
|
|
1429
|
+
delete container['- '];
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
/**
|
|
1433
|
+
* Intern a string to make comparisons faster.
|
|
1434
|
+
*
|
|
1435
|
+
* > Note: This is a relatively expensive operation, you
|
|
1436
|
+
* shouldn't usually do the actual interning at runtime, instead
|
|
1437
|
+
* use this at compile time to make future work faster.
|
|
1438
|
+
*
|
|
1439
|
+
* @param {String} string The string to intern.
|
|
1440
|
+
* @return {String} The interned string.
|
|
1441
|
+
*/
|
|
1442
|
+
module.exports = function fastIntern (string) {
|
|
1443
|
+
container[string] = true;
|
|
1444
|
+
var interned = Object.keys(container)[0];
|
|
1445
|
+
delete container[interned];
|
|
1446
|
+
return interned;
|
|
1447
|
+
};
|
|
1448
|
+
},{}]},{},[28])
|
|
1449
|
+
(28)
|
|
1450
|
+
});
|