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.
Files changed (167) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +6 -0
  5. data/Gemfile +5 -0
  6. data/LICENSE +25 -0
  7. data/README.md +28 -0
  8. data/Rakefile +1 -0
  9. data/deku.gemspec +23 -0
  10. data/deps/node_modules/deku.js +2 -0
  11. data/deps/node_modules/deku/.editorconfig +16 -0
  12. data/deps/node_modules/deku/.zuul.yml +15 -0
  13. data/deps/node_modules/deku/History.md +290 -0
  14. data/deps/node_modules/deku/LICENSE.md +7 -0
  15. data/deps/node_modules/deku/Makefile +91 -0
  16. data/deps/node_modules/deku/README.md +293 -0
  17. data/deps/node_modules/deku/index.js +4072 -0
  18. data/deps/node_modules/deku/lib/application.js +85 -0
  19. data/deps/node_modules/deku/lib/index.js +28 -0
  20. data/deps/node_modules/deku/lib/render.js +1300 -0
  21. data/deps/node_modules/deku/lib/stringify.js +105 -0
  22. data/deps/node_modules/deku/lib/svg.js +107 -0
  23. data/deps/node_modules/deku/lib/utils.js +18 -0
  24. data/deps/node_modules/deku/lib/virtual.js +247 -0
  25. data/deps/node_modules/deku/node_modules/array-flatten/LICENSE +21 -0
  26. data/deps/node_modules/deku/node_modules/array-flatten/README.md +43 -0
  27. data/deps/node_modules/deku/node_modules/array-flatten/array-flatten.js +57 -0
  28. data/deps/node_modules/deku/node_modules/array-flatten/package.json +62 -0
  29. data/deps/node_modules/deku/node_modules/component-emitter/History.md +63 -0
  30. data/deps/node_modules/deku/node_modules/component-emitter/LICENSE +24 -0
  31. data/deps/node_modules/deku/node_modules/component-emitter/Readme.md +74 -0
  32. data/deps/node_modules/deku/node_modules/component-emitter/index.js +161 -0
  33. data/deps/node_modules/deku/node_modules/component-emitter/package.json +174 -0
  34. data/deps/node_modules/deku/node_modules/component-raf/.npmignore +2 -0
  35. data/deps/node_modules/deku/node_modules/component-raf/History.md +26 -0
  36. data/deps/node_modules/deku/node_modules/component-raf/Makefile +11 -0
  37. data/deps/node_modules/deku/node_modules/component-raf/Readme.md +46 -0
  38. data/deps/node_modules/deku/node_modules/component-raf/component.json +16 -0
  39. data/deps/node_modules/deku/node_modules/component-raf/example.html +43 -0
  40. data/deps/node_modules/deku/node_modules/component-raf/index.js +34 -0
  41. data/deps/node_modules/deku/node_modules/component-raf/package.json +164 -0
  42. data/deps/node_modules/deku/node_modules/component-type/.npmignore +3 -0
  43. data/deps/node_modules/deku/node_modules/component-type/Makefile +14 -0
  44. data/deps/node_modules/deku/node_modules/component-type/Readme.md +37 -0
  45. data/deps/node_modules/deku/node_modules/component-type/component.json +13 -0
  46. data/deps/node_modules/deku/node_modules/component-type/index.js +34 -0
  47. data/deps/node_modules/deku/node_modules/component-type/package.json +120 -0
  48. data/deps/node_modules/deku/node_modules/component-type/test/index.html +17 -0
  49. data/deps/node_modules/deku/node_modules/component-type/test/mocha.css +231 -0
  50. data/deps/node_modules/deku/node_modules/component-type/test/mocha.js +5340 -0
  51. data/deps/node_modules/deku/node_modules/component-type/test/tests.js +72 -0
  52. data/deps/node_modules/deku/node_modules/dom-pool/.npmignore +1 -0
  53. data/deps/node_modules/deku/node_modules/dom-pool/Pool.js +52 -0
  54. data/deps/node_modules/deku/node_modules/dom-pool/README.md +42 -0
  55. data/deps/node_modules/deku/node_modules/dom-pool/authors.txt +4 -0
  56. data/deps/node_modules/deku/node_modules/dom-pool/bower.json +26 -0
  57. data/deps/node_modules/deku/node_modules/dom-pool/package.json +46 -0
  58. data/deps/node_modules/deku/node_modules/dom-pool/tests.html +16 -0
  59. data/deps/node_modules/deku/node_modules/dom-pool/tests.js +102 -0
  60. data/deps/node_modules/deku/node_modules/dom-walk/.npmignore +3 -0
  61. data/deps/node_modules/deku/node_modules/dom-walk/LICENCE +19 -0
  62. data/deps/node_modules/deku/node_modules/dom-walk/Makefile +2 -0
  63. data/deps/node_modules/deku/node_modules/dom-walk/README.md +23 -0
  64. data/deps/node_modules/deku/node_modules/dom-walk/example/index.js +5 -0
  65. data/deps/node_modules/deku/node_modules/dom-walk/example/static/bundle.js +211 -0
  66. data/deps/node_modules/deku/node_modules/dom-walk/example/static/index.html +16 -0
  67. data/deps/node_modules/deku/node_modules/dom-walk/index.js +24 -0
  68. data/deps/node_modules/deku/node_modules/dom-walk/package.json +57 -0
  69. data/deps/node_modules/deku/node_modules/fast.js/.jshintignore +7 -0
  70. data/deps/node_modules/deku/node_modules/fast.js/.jshintrc +80 -0
  71. data/deps/node_modules/deku/node_modules/fast.js/.npmignore +6 -0
  72. data/deps/node_modules/deku/node_modules/fast.js/.travis.yml +3 -0
  73. data/deps/node_modules/deku/node_modules/fast.js/LICENSE.md +21 -0
  74. data/deps/node_modules/deku/node_modules/fast.js/README.md +552 -0
  75. data/deps/node_modules/deku/node_modules/fast.js/array/clone.js +21 -0
  76. data/deps/node_modules/deku/node_modules/fast.js/array/concat.js +32 -0
  77. data/deps/node_modules/deku/node_modules/fast.js/array/every.js +25 -0
  78. data/deps/node_modules/deku/node_modules/fast.js/array/fill.js +29 -0
  79. data/deps/node_modules/deku/node_modules/fast.js/array/filter.js +26 -0
  80. data/deps/node_modules/deku/node_modules/fast.js/array/forEach.js +21 -0
  81. data/deps/node_modules/deku/node_modules/fast.js/array/index.js +15 -0
  82. data/deps/node_modules/deku/node_modules/fast.js/array/indexOf.js +33 -0
  83. data/deps/node_modules/deku/node_modules/fast.js/array/lastIndexOf.js +29 -0
  84. data/deps/node_modules/deku/node_modules/fast.js/array/map.js +24 -0
  85. data/deps/node_modules/deku/node_modules/fast.js/array/pluck.js +24 -0
  86. data/deps/node_modules/deku/node_modules/fast.js/array/reduce.js +35 -0
  87. data/deps/node_modules/deku/node_modules/fast.js/array/reduceRight.js +35 -0
  88. data/deps/node_modules/deku/node_modules/fast.js/array/some.js +25 -0
  89. data/deps/node_modules/deku/node_modules/fast.js/bower.json +28 -0
  90. data/deps/node_modules/deku/node_modules/fast.js/clone.js +27 -0
  91. data/deps/node_modules/deku/node_modules/fast.js/dist/bench.html +15 -0
  92. data/deps/node_modules/deku/node_modules/fast.js/dist/bench.js +19900 -0
  93. data/deps/node_modules/deku/node_modules/fast.js/dist/fast.js +1450 -0
  94. data/deps/node_modules/deku/node_modules/fast.js/dist/fast.min.js +1 -0
  95. data/deps/node_modules/deku/node_modules/fast.js/filter.js +23 -0
  96. data/deps/node_modules/deku/node_modules/fast.js/forEach.js +22 -0
  97. data/deps/node_modules/deku/node_modules/fast.js/function/apply.js +19 -0
  98. data/deps/node_modules/deku/node_modules/fast.js/function/applyNoContext.js +29 -0
  99. data/deps/node_modules/deku/node_modules/fast.js/function/applyWithContext.js +29 -0
  100. data/deps/node_modules/deku/node_modules/fast.js/function/bind.js +71 -0
  101. data/deps/node_modules/deku/node_modules/fast.js/function/bindInternal3.js +11 -0
  102. data/deps/node_modules/deku/node_modules/fast.js/function/bindInternal4.js +11 -0
  103. data/deps/node_modules/deku/node_modules/fast.js/function/index.js +7 -0
  104. data/deps/node_modules/deku/node_modules/fast.js/function/partial.js +42 -0
  105. data/deps/node_modules/deku/node_modules/fast.js/function/partialConstructor.js +45 -0
  106. data/deps/node_modules/deku/node_modules/fast.js/function/try.js +35 -0
  107. data/deps/node_modules/deku/node_modules/fast.js/index.js +241 -0
  108. data/deps/node_modules/deku/node_modules/fast.js/map.js +23 -0
  109. data/deps/node_modules/deku/node_modules/fast.js/object/assign.js +34 -0
  110. data/deps/node_modules/deku/node_modules/fast.js/object/clone.js +25 -0
  111. data/deps/node_modules/deku/node_modules/fast.js/object/filter.js +28 -0
  112. data/deps/node_modules/deku/node_modules/fast.js/object/forEach.js +23 -0
  113. data/deps/node_modules/deku/node_modules/fast.js/object/index.js +11 -0
  114. data/deps/node_modules/deku/node_modules/fast.js/object/keys.js +17 -0
  115. data/deps/node_modules/deku/node_modules/fast.js/object/map.js +26 -0
  116. data/deps/node_modules/deku/node_modules/fast.js/object/reduce.js +37 -0
  117. data/deps/node_modules/deku/node_modules/fast.js/object/reduceRight.js +37 -0
  118. data/deps/node_modules/deku/node_modules/fast.js/object/values.js +20 -0
  119. data/deps/node_modules/deku/node_modules/fast.js/package.json +73 -0
  120. data/deps/node_modules/deku/node_modules/fast.js/reduce.js +24 -0
  121. data/deps/node_modules/deku/node_modules/fast.js/reduceRight.js +24 -0
  122. data/deps/node_modules/deku/node_modules/fast.js/string/index.js +3 -0
  123. data/deps/node_modules/deku/node_modules/fast.js/string/intern.js +56 -0
  124. data/deps/node_modules/deku/node_modules/get-uid/README.md +44 -0
  125. data/deps/node_modules/deku/node_modules/get-uid/index.js +6 -0
  126. data/deps/node_modules/deku/node_modules/get-uid/package.json +56 -0
  127. data/deps/node_modules/deku/node_modules/is-dom/HISTORY.md +2 -0
  128. data/deps/node_modules/deku/node_modules/is-dom/LICENSE +21 -0
  129. data/deps/node_modules/deku/node_modules/is-dom/README.md +32 -0
  130. data/deps/node_modules/deku/node_modules/is-dom/index.js +15 -0
  131. data/deps/node_modules/deku/node_modules/is-dom/package.json +62 -0
  132. data/deps/node_modules/deku/node_modules/object-path/.npmignore +7 -0
  133. data/deps/node_modules/deku/node_modules/object-path/.travis.yml +6 -0
  134. data/deps/node_modules/deku/node_modules/object-path/LICENSE +21 -0
  135. data/deps/node_modules/deku/node_modules/object-path/README.md +96 -0
  136. data/deps/node_modules/deku/node_modules/object-path/bower.json +17 -0
  137. data/deps/node_modules/deku/node_modules/object-path/component.json +22 -0
  138. data/deps/node_modules/deku/node_modules/object-path/index.js +269 -0
  139. data/deps/node_modules/deku/node_modules/object-path/package.json +89 -0
  140. data/deps/node_modules/deku/node_modules/object-path/test.js +510 -0
  141. data/deps/node_modules/deku/node_modules/per-frame/.npmignore +68 -0
  142. data/deps/node_modules/deku/node_modules/per-frame/History.md +32 -0
  143. data/deps/node_modules/deku/node_modules/per-frame/README.md +44 -0
  144. data/deps/node_modules/deku/node_modules/per-frame/component.json +13 -0
  145. data/deps/node_modules/deku/node_modules/per-frame/index.js +37 -0
  146. data/deps/node_modules/deku/node_modules/per-frame/package.json +143 -0
  147. data/deps/node_modules/deku/node_modules/per-frame/test/test.js +94 -0
  148. data/deps/node_modules/deku/node_modules/sliced/.npmignore +2 -0
  149. data/deps/node_modules/deku/node_modules/sliced/.travis.yml +4 -0
  150. data/deps/node_modules/deku/node_modules/sliced/History.md +30 -0
  151. data/deps/node_modules/deku/node_modules/sliced/LICENSE +22 -0
  152. data/deps/node_modules/deku/node_modules/sliced/Makefile +5 -0
  153. data/deps/node_modules/deku/node_modules/sliced/README.md +62 -0
  154. data/deps/node_modules/deku/node_modules/sliced/bench.js +95 -0
  155. data/deps/node_modules/deku/node_modules/sliced/component.json +14 -0
  156. data/deps/node_modules/deku/node_modules/sliced/index.js +1 -0
  157. data/deps/node_modules/deku/node_modules/sliced/lib/sliced.js +33 -0
  158. data/deps/node_modules/deku/node_modules/sliced/package.json +52 -0
  159. data/deps/node_modules/deku/node_modules/sliced/test/index.js +80 -0
  160. data/deps/node_modules/deku/package.json +67 -0
  161. data/lib/deku.rb +11 -0
  162. data/lib/deku/application.rb +16 -0
  163. data/lib/deku/component.rb +36 -0
  164. data/lib/deku/context.rb +38 -0
  165. data/lib/deku/element_node.rb +17 -0
  166. data/lib/deku/version.rb +4 -0
  167. metadata +278 -0
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var mapArray = require('./array/map'),
4
+ mapObject = require('./object/map');
5
+
6
+ /**
7
+ * # Map
8
+ *
9
+ * A fast `.map()` implementation.
10
+ *
11
+ * @param {Array|Object} subject The array or object to map over.
12
+ * @param {Function} fn The mapper function.
13
+ * @param {Object} thisContext The context for the mapper.
14
+ * @return {Array|Object} The array or object containing the results.
15
+ */
16
+ module.exports = function fastMap (subject, fn, thisContext) {
17
+ if (subject instanceof Array) {
18
+ return mapArray(subject, fn, thisContext);
19
+ }
20
+ else {
21
+ return mapObject(subject, fn, thisContext);
22
+ }
23
+ };
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Analogue of Object.assign().
5
+ * Copies properties from one or more source objects to
6
+ * a target object. Existing keys on the target object will be overwritten.
7
+ *
8
+ * > Note: This differs from spec in some important ways:
9
+ * > 1. Will throw if passed non-objects, including `undefined` or `null` values.
10
+ * > 2. Does not support the curious Exception handling behavior, exceptions are thrown immediately.
11
+ * > For more details, see:
12
+ * > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
13
+ *
14
+ *
15
+ *
16
+ * @param {Object} target The target object to copy properties to.
17
+ * @param {Object} source, ... The source(s) to copy properties from.
18
+ * @return {Object} The updated target object.
19
+ */
20
+ module.exports = function fastAssign (target) {
21
+ var totalArgs = arguments.length,
22
+ source, i, totalKeys, keys, key, j;
23
+
24
+ for (i = 1; i < totalArgs; i++) {
25
+ source = arguments[i];
26
+ keys = Object.keys(source);
27
+ totalKeys = keys.length;
28
+ for (j = 0; j < totalKeys; j++) {
29
+ key = keys[j];
30
+ target[key] = source[key];
31
+ }
32
+ }
33
+ return target;
34
+ };
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * # Clone Object
5
+ *
6
+ * Shallow clone a simple object.
7
+ *
8
+ * > Note: Prototypes and non-enumerable properties will not be copied!
9
+ *
10
+ * @param {Object} input The object to clone.
11
+ * @return {Object} The cloned object.
12
+ */
13
+ module.exports = function fastCloneObject (input) {
14
+ var keys = Object.keys(input),
15
+ total = keys.length,
16
+ cloned = {},
17
+ i, key;
18
+
19
+ for (i = 0; i < total; i++) {
20
+ key = keys[i];
21
+ cloned[key] = input[key];
22
+ }
23
+
24
+ return cloned;
25
+ };
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var bindInternal3 = require('../function/bindInternal3');
4
+
5
+ /**
6
+ * # Filter
7
+ *
8
+ * A fast object `.filter()` implementation.
9
+ *
10
+ * @param {Object} subject The object to filter.
11
+ * @param {Function} fn The filter function.
12
+ * @param {Object} thisContext The context for the filter.
13
+ * @return {Object} The new object containing the filtered results.
14
+ */
15
+ module.exports = function fastFilterObject (subject, fn, thisContext) {
16
+ var keys = Object.keys(subject),
17
+ length = keys.length,
18
+ result = {},
19
+ iterator = thisContext !== undefined ? bindInternal3(fn, thisContext) : fn,
20
+ i, key;
21
+ for (i = 0; i < length; i++) {
22
+ key = keys[i];
23
+ if (iterator(subject[key], key, subject)) {
24
+ result[key] = subject[key];
25
+ }
26
+ }
27
+ return result;
28
+ };
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var bindInternal3 = require('../function/bindInternal3');
4
+
5
+ /**
6
+ * # For Each
7
+ *
8
+ * A fast object `.forEach()` implementation.
9
+ *
10
+ * @param {Object} subject The object to iterate over.
11
+ * @param {Function} fn The visitor function.
12
+ * @param {Object} thisContext The context for the visitor.
13
+ */
14
+ module.exports = function fastForEachObject (subject, fn, thisContext) {
15
+ var keys = Object.keys(subject),
16
+ length = keys.length,
17
+ iterator = thisContext !== undefined ? bindInternal3(fn, thisContext) : fn,
18
+ key, i;
19
+ for (i = 0; i < length; i++) {
20
+ key = keys[i];
21
+ iterator(subject[key], key, subject);
22
+ }
23
+ };
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ exports.assign = require('./assign');
4
+ exports.clone = require('./clone');
5
+ exports.filter = require('./filter');
6
+ exports.forEach = require('./forEach');
7
+ exports.map = require('./map');
8
+ exports.reduce = require('./reduce');
9
+ exports.reduceRight = require('./reduceRight');
10
+ exports.keys = require('./keys');
11
+ exports.values = require('./values');
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Object.keys() shim for ES3 environments.
5
+ *
6
+ * @param {Object} obj The object to get keys for.
7
+ * @return {Array} The array of keys.
8
+ */
9
+ module.exports = typeof Object.keys === "function" ? Object.keys : /* istanbul ignore next */ function fastKeys (obj) {
10
+ var keys = [];
11
+ for (var key in obj) {
12
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
13
+ keys.push(key);
14
+ }
15
+ }
16
+ return keys;
17
+ };
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var bindInternal3 = require('../function/bindInternal3');
4
+
5
+ /**
6
+ * # Map
7
+ *
8
+ * A fast object `.map()` implementation.
9
+ *
10
+ * @param {Object} subject The object to map over.
11
+ * @param {Function} fn The mapper function.
12
+ * @param {Object} thisContext The context for the mapper.
13
+ * @return {Object} The new object containing the results.
14
+ */
15
+ module.exports = function fastMapObject (subject, fn, thisContext) {
16
+ var keys = Object.keys(subject),
17
+ length = keys.length,
18
+ result = {},
19
+ iterator = thisContext !== undefined ? bindInternal3(fn, thisContext) : fn,
20
+ i, key;
21
+ for (i = 0; i < length; i++) {
22
+ key = keys[i];
23
+ result[key] = iterator(subject[key], key, subject);
24
+ }
25
+ return result;
26
+ };
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ var bindInternal4 = require('../function/bindInternal4');
4
+
5
+ /**
6
+ * # Reduce
7
+ *
8
+ * A fast object `.reduce()` implementation.
9
+ *
10
+ * @param {Object} subject The object to reduce over.
11
+ * @param {Function} fn The reducer function.
12
+ * @param {mixed} initialValue The initial value for the reducer, defaults to subject[0].
13
+ * @param {Object} thisContext The context for the reducer.
14
+ * @return {mixed} The final result.
15
+ */
16
+ module.exports = function fastReduceObject (subject, fn, initialValue, thisContext) {
17
+ var keys = Object.keys(subject),
18
+ length = keys.length,
19
+ iterator = thisContext !== undefined ? bindInternal4(fn, thisContext) : fn,
20
+ i, key, result;
21
+
22
+ if (initialValue === undefined) {
23
+ i = 1;
24
+ result = subject[keys[0]];
25
+ }
26
+ else {
27
+ i = 0;
28
+ result = initialValue;
29
+ }
30
+
31
+ for (; i < length; i++) {
32
+ key = keys[i];
33
+ result = iterator(result, subject[key], key, subject);
34
+ }
35
+
36
+ return result;
37
+ };
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ var bindInternal4 = require('../function/bindInternal4');
4
+
5
+ /**
6
+ * # Reduce
7
+ *
8
+ * A fast object `.reduce()` implementation.
9
+ *
10
+ * @param {Object} subject The object to reduce over.
11
+ * @param {Function} fn The reducer function.
12
+ * @param {mixed} initialValue The initial value for the reducer, defaults to subject[0].
13
+ * @param {Object} thisContext The context for the reducer.
14
+ * @return {mixed} The final result.
15
+ */
16
+ module.exports = function fastReduceRightObject (subject, fn, initialValue, thisContext) {
17
+ var keys = Object.keys(subject),
18
+ length = keys.length,
19
+ iterator = thisContext !== undefined ? bindInternal4(fn, thisContext) : fn,
20
+ i, key, result;
21
+
22
+ if (initialValue === undefined) {
23
+ i = length - 2;
24
+ result = subject[keys[length - 1]];
25
+ }
26
+ else {
27
+ i = length - 1;
28
+ result = initialValue;
29
+ }
30
+
31
+ for (; i >= 0; i--) {
32
+ key = keys[i];
33
+ result = iterator(result, subject[key], key, subject);
34
+ }
35
+
36
+ return result;
37
+ };
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * # Values
5
+ * Return all the (enumerable) property values for an object.
6
+ * Like Object.keys() but for values.
7
+ *
8
+ * @param {Object} obj The object to retrieve values from.
9
+ * @return {Array} An array containing property values.
10
+ */
11
+ module.exports = function fastValues (obj) {
12
+ var keys = Object.keys(obj),
13
+ length = keys.length,
14
+ values = new Array(length);
15
+
16
+ for (var i = 0; i < length; i++) {
17
+ values[i] = obj[keys[i]];
18
+ }
19
+ return values;
20
+ };
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "fast.js",
3
+ "version": "0.1.1",
4
+ "description": "Faster user-land reimplementations of native functions with extra helpers.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "jshint": "jshint ./",
8
+ "pretest": "npm run jshint",
9
+ "test": "mocha",
10
+ "bench": "node ./bench/index.js",
11
+ "coverage": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha",
12
+ "install-sm": "wget http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/jsshell-linux-x86_64.zip -O ./ci/environments/sm/sm.zip; unzip -o -d ./ci/environments/sm ./ci/environments/sm/sm.zip",
13
+ "bench-sm": "browserify ./bench/index.js | cat ./ci/sm-shim.js - > ./ci/environments/sm/bench.js; ./ci/environments/sm/js -f ./ci/environments/sm/bench.js",
14
+ "install-v8": "sh ./ci/environments/v8/install.sh",
15
+ "bench-v8": "browserify ./bench/index.js | cat ./ci/v8-shim.js - > ./ci/environments/v8/bench.js; ./ci/environments/v8/v8-git-mirror/out/native/shell ./ci/environments/v8/bench.js",
16
+ "dist": "npm run dist-browser; npm run dist-minify; npm run dist-bench",
17
+ "dist-browser": "browserify -o dist/fast.js -s fast ./index.js",
18
+ "dist-minify": "uglifyjs -o ./dist/fast.min.js ./dist/fast.js --mangle --compress warnings=false",
19
+ "dist-bench": "browserify -o ./dist/bench.js ./bench/index.js"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "http://github.com/codemix/fast.js"
24
+ },
25
+ "keywords": [
26
+ "fast",
27
+ "native"
28
+ ],
29
+ "author": {
30
+ "name": "Charles Pick",
31
+ "email": "charles@codemix.com"
32
+ },
33
+ "license": "MIT",
34
+ "bugs": {
35
+ "url": "https://github.com/codemix/fast.js/issues"
36
+ },
37
+ "homepage": "https://github.com/codemix/fast.js",
38
+ "devDependencies": {
39
+ "expect.js": "~0.3.1",
40
+ "should": "~4.0.4",
41
+ "mocha": "~1.20.1",
42
+ "benchmark": "~1.0.0",
43
+ "microtime": "~0.6.0",
44
+ "istanbul": "~0.2.11",
45
+ "jshint": "~2.5.1",
46
+ "underscore": "git://github.com/jashkenas/underscore.git#master",
47
+ "lodash": "git://github.com/lodash/lodash.git#master",
48
+ "browserify": "~4.1.11",
49
+ "uglifyjs": "~2.3.6"
50
+ },
51
+ "gitHead": "46556d8e4dc9b8825b039f6d5532a90ccd2a4379",
52
+ "_id": "fast.js@0.1.1",
53
+ "_shasum": "7c024d55ae144882fbcee44b79005fe2dcabd9fe",
54
+ "_from": "fast.js@>=0.1.1 <0.2.0",
55
+ "_npmVersion": "1.4.28",
56
+ "_npmUser": {
57
+ "name": "codemix",
58
+ "email": "charles@codemix.com"
59
+ },
60
+ "maintainers": [
61
+ {
62
+ "name": "codemix",
63
+ "email": "charles@codemix.com"
64
+ }
65
+ ],
66
+ "dist": {
67
+ "shasum": "7c024d55ae144882fbcee44b79005fe2dcabd9fe",
68
+ "tarball": "http://registry.npmjs.org/fast.js/-/fast.js-0.1.1.tgz"
69
+ },
70
+ "directories": {},
71
+ "_resolved": "https://registry.npmjs.org/fast.js/-/fast.js-0.1.1.tgz",
72
+ "readme": "ERROR: No README data found!"
73
+ }
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var reduceArray = require('./array/reduce'),
4
+ reduceObject = require('./object/reduce');
5
+
6
+ /**
7
+ * # Reduce
8
+ *
9
+ * A fast `.reduce()` implementation.
10
+ *
11
+ * @param {Array|Object} subject The array or object to reduce over.
12
+ * @param {Function} fn The reducer function.
13
+ * @param {mixed} initialValue The initial value for the reducer, defaults to subject[0].
14
+ * @param {Object} thisContext The context for the reducer.
15
+ * @return {Array|Object} The array or object containing the results.
16
+ */
17
+ module.exports = function fastReduce (subject, fn, initialValue, thisContext) {
18
+ if (subject instanceof Array) {
19
+ return reduceArray(subject, fn, initialValue, thisContext);
20
+ }
21
+ else {
22
+ return reduceObject(subject, fn, initialValue, thisContext);
23
+ }
24
+ };
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var reduceRightArray = require('./array/reduceRight'),
4
+ reduceRightObject = require('./object/reduceRight');
5
+
6
+ /**
7
+ * # Reduce Right
8
+ *
9
+ * A fast `.reduceRight()` implementation.
10
+ *
11
+ * @param {Array|Object} subject The array or object to reduce over.
12
+ * @param {Function} fn The reducer function.
13
+ * @param {mixed} initialValue The initial value for the reducer, defaults to subject[0].
14
+ * @param {Object} thisContext The context for the reducer.
15
+ * @return {Array|Object} The array or object containing the results.
16
+ */
17
+ module.exports = function fastReduceRight (subject, fn, initialValue, thisContext) {
18
+ if (subject instanceof Array) {
19
+ return reduceRightArray(subject, fn, initialValue, thisContext);
20
+ }
21
+ else {
22
+ return reduceRightObject(subject, fn, initialValue, thisContext);
23
+ }
24
+ };
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ exports.intern = require('./intern');
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ // Compilers such as V8 use string interning to make string comparison very fast and efficient,
4
+ // as efficient as comparing two references to the same object.
5
+ //
6
+ //
7
+ // V8 does its best to intern strings automatically where it can, for instance:
8
+ // ```js
9
+ // var greeting = "hello world";
10
+ // ```
11
+ // With this, comparison will be very fast:
12
+ // ```js
13
+ // if (greeting === "hello world") {}
14
+ // ```
15
+ // However, there are several cases where V8 cannot intern the string, and instead
16
+ // must resort to byte-wise comparison. This can be signficantly slower for long strings.
17
+ // The most common example is string concatenation:
18
+ // ```js
19
+ // function subject () { return "world"; };
20
+ // var greeting = "hello " + subject();
21
+ // ```
22
+ // In this case, V8 cannot intern the string. So this comparison is *much* slower:
23
+ // ```js
24
+ // if (greeting === "hello world") {}
25
+ // ```
26
+
27
+
28
+
29
+ // At the moment, the fastest, safe way of interning a string is to
30
+ // use it as a key in an object, and then use that key.
31
+ //
32
+ // Note: This technique comes courtesy of Petka Antonov - http://jsperf.com/istrn/11
33
+ //
34
+ // We create a container object in hash mode.
35
+ // Most strings being interned will not be valid fast property names,
36
+ // so we ensure hash mode now to avoid transitioning the object mode at runtime.
37
+ var container = {'- ': true};
38
+ delete container['- '];
39
+
40
+
41
+ /**
42
+ * Intern a string to make comparisons faster.
43
+ *
44
+ * > Note: This is a relatively expensive operation, you
45
+ * shouldn't usually do the actual interning at runtime, instead
46
+ * use this at compile time to make future work faster.
47
+ *
48
+ * @param {String} string The string to intern.
49
+ * @return {String} The interned string.
50
+ */
51
+ module.exports = function fastIntern (string) {
52
+ container[string] = true;
53
+ var interned = Object.keys(container)[0];
54
+ delete container[interned];
55
+ return interned;
56
+ };