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,44 @@
1
+ # get-uid [![Build Status](https://travis-ci.org/dfcreative/get-uid.svg?branch=master)](https://travis-ci.org/dfcreative/get-uid) [![Code Climate](https://codeclimate.com/github/dfcreative/get-uid/badges/gpa.svg)](https://codeclimate.com/github/dfcreative/get-uid)
2
+
3
+ Simple random id generator.
4
+
5
+ `$ npm install get-uid`
6
+
7
+ ```js
8
+ var getUid = require('get-uid');
9
+
10
+ getUid(); //1178851014
11
+ getUid(); //811233864
12
+ ...
13
+ ```
14
+
15
+
16
+ Yet another one uid generator? There are already some:
17
+
18
+ * gen-uid
19
+ * unique
20
+ * uid
21
+ * uid2
22
+ * uid-util
23
+ * micro-uid
24
+ * component-uid
25
+ * j-uid
26
+ * unique-id
27
+ * uniqid
28
+ * short-uid
29
+ * puid
30
+ * amp-unique-id
31
+ * genuid
32
+ * simple-uid
33
+ * random-id
34
+ * smart-id
35
+ * uuid-pure
36
+ * simple-random-id
37
+ * nid
38
+
39
+ This one is just shorter and simpler, almost like `id++`, but with no bad side-effects. The technique is used innerly by [Financial Times’ WeakSet](https://github.com/Financial-Times/polyfill-service/blob/master/polyfills/WeakSet/polyfill.js), [Web-components’ WeakMap](https://github.com/webcomponents/webcomponentsjs/blob/master/src/WeakMap/WeakMap.js) and so on.
40
+
41
+
42
+ [![NPM](https://nodei.co/npm/get-uid.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/get-uid/)
43
+
44
+ <a href="UNLICENSE"><img src="http://upload.wikimedia.org/wikipedia/commons/6/62/PD-icon.svg" width="20"/></a>
@@ -0,0 +1,6 @@
1
+ /** generate unique id for selector */
2
+ var counter = Date.now() % 1e9;
3
+
4
+ module.exports = function getUid(){
5
+ return (Math.random() * 1e9 >>> 0) + (counter++);
6
+ };
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "get-uid",
3
+ "version": "1.0.1",
4
+ "description": "Generate unique integer id.",
5
+ "main": "index.js",
6
+ "files": [
7
+ "index.js"
8
+ ],
9
+ "scripts": {
10
+ "test": "node test.js"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/dfcreative/get-uid"
15
+ },
16
+ "keywords": [
17
+ "unique",
18
+ "get-uid",
19
+ "uid",
20
+ "unique-id",
21
+ "uniq-id",
22
+ "id",
23
+ "gen-uid",
24
+ "short-uid"
25
+ ],
26
+ "author": {
27
+ "name": "Deema Ywanov",
28
+ "email": "dfcreative@gmail.com"
29
+ },
30
+ "license": "Unlicensed",
31
+ "bugs": {
32
+ "url": "https://github.com/dfcreative/get-uid/issues"
33
+ },
34
+ "homepage": "https://github.com/dfcreative/get-uid",
35
+ "_id": "get-uid@1.0.1",
36
+ "dist": {
37
+ "shasum": "ac6d5695550cb6be371d5a79b0d968115f746a22",
38
+ "tarball": "http://registry.npmjs.org/get-uid/-/get-uid-1.0.1.tgz"
39
+ },
40
+ "_from": "get-uid@>=1.0.1 <2.0.0",
41
+ "_npmVersion": "1.3.24",
42
+ "_npmUser": {
43
+ "name": "dfcreative",
44
+ "email": "df.creative@gmail.com"
45
+ },
46
+ "maintainers": [
47
+ {
48
+ "name": "dfcreative",
49
+ "email": "df.creative@gmail.com"
50
+ }
51
+ ],
52
+ "directories": {},
53
+ "_shasum": "ac6d5695550cb6be371d5a79b0d968115f746a22",
54
+ "_resolved": "https://registry.npmjs.org/get-uid/-/get-uid-1.0.1.tgz",
55
+ "readme": "ERROR: No README data found!"
56
+ }
@@ -0,0 +1,2 @@
1
+ # 1.0.0 / 2014-09-05
2
+ - init
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,32 @@
1
+ # is-dom
2
+ [![NPM version][npm-image]][npm-url]
3
+ [![build status][travis-image]][travis-url]
4
+ [![Test coverage][coveralls-image]][coveralls-url]
5
+ [![Downloads][downloads-image]][downloads-url]
6
+
7
+ Check if the given object is a dom node.
8
+
9
+ ## Installation
10
+ ```bash
11
+ npm install is-dom
12
+ ```
13
+
14
+ ## Usage
15
+ ```js
16
+ var isDom = require('is-dom');
17
+
18
+ isDom(window.document);
19
+ // => true
20
+ ```
21
+
22
+ ## License
23
+ [MIT](https://tldrlegal.com/license/mit-license)
24
+
25
+ [npm-image]: https://img.shields.io/npm/v/is-dom.svg?style=flat-square
26
+ [npm-url]: https://npmjs.org/package/is-dom
27
+ [travis-image]: https://img.shields.io/travis/npm-dom/is-dom.svg?style=flat-square
28
+ [travis-url]: https://travis-ci.org/npm-dom/is-dom
29
+ [coveralls-image]: https://img.shields.io/coveralls/npm-dom/is-dom.svg?style=flat-square
30
+ [coveralls-url]: https://coveralls.io/r/npm-dom/is-dom?branch=master
31
+ [downloads-image]: http://img.shields.io/npm/dm/is-dom.svg?style=flat-square
32
+ [downloads-url]: https://npmjs.org/package/is-dom
@@ -0,0 +1,15 @@
1
+ /*global window*/
2
+
3
+ /**
4
+ * Check if object is dom node.
5
+ *
6
+ * @param {Object} val
7
+ * @return {Boolean}
8
+ * @api public
9
+ */
10
+
11
+ module.exports = function isNode(val){
12
+ if (!val || typeof val !== 'object') return false;
13
+ if (window && 'object' == typeof window.Node) return val instanceof window.Node;
14
+ return 'number' == typeof val.nodeType && 'string' == typeof val.nodeName;
15
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "is-dom",
3
+ "version": "1.0.5",
4
+ "description": "Check if the given object is a dom node",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "make test"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/npm-dom/is-dom"
12
+ },
13
+ "keywords": [
14
+ "dom",
15
+ "html",
16
+ "is dom",
17
+ "dom node",
18
+ "dom object"
19
+ ],
20
+ "license": "MIT",
21
+ "dependencies": {},
22
+ "devDependencies": {
23
+ "istanbul": "^0.3.2",
24
+ "jsdom": "^1.0.1",
25
+ "make-lint": "^1.0.1",
26
+ "mocha": "^1.21.4",
27
+ "should": "^4.0.4"
28
+ },
29
+ "files": [
30
+ "lib",
31
+ "LICENSE",
32
+ "index.js",
33
+ "HISTORY.md"
34
+ ],
35
+ "gitHead": "4d64aad99574d91408b5a2a9eee20ca2c6df70ce",
36
+ "bugs": {
37
+ "url": "https://github.com/npm-dom/is-dom/issues"
38
+ },
39
+ "homepage": "https://github.com/npm-dom/is-dom",
40
+ "_id": "is-dom@1.0.5",
41
+ "_shasum": "3b4f9eaa7a6014c010b276c645cad85bb3c7b1fd",
42
+ "_from": "is-dom@>=1.0.5 <2.0.0",
43
+ "_npmVersion": "2.4.1",
44
+ "_nodeVersion": "0.10.35",
45
+ "_npmUser": {
46
+ "name": "yoshuawuyts",
47
+ "email": "i@yoshuawuyts.com"
48
+ },
49
+ "maintainers": [
50
+ {
51
+ "name": "yoshuawuyts",
52
+ "email": "i@yoshuawuyts.com"
53
+ }
54
+ ],
55
+ "dist": {
56
+ "shasum": "3b4f9eaa7a6014c010b276c645cad85bb3c7b1fd",
57
+ "tarball": "http://registry.npmjs.org/is-dom/-/is-dom-1.0.5.tgz"
58
+ },
59
+ "directories": {},
60
+ "_resolved": "https://registry.npmjs.org/is-dom/-/is-dom-1.0.5.tgz",
61
+ "readme": "ERROR: No README data found!"
62
+ }
@@ -0,0 +1,7 @@
1
+ node_modules
2
+ .c9revisions
3
+ .settings
4
+ .idea
5
+ npm-debug.log
6
+ generated
7
+ coverage
@@ -0,0 +1,6 @@
1
+ language: node_js
2
+ node_js:
3
+ - "0.11"
4
+ - "0.10"
5
+ - "0.8"
6
+ after_success: "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Mario Casciaro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,96 @@
1
+
2
+
3
+ object-path
4
+ ===========
5
+
6
+ Access deep properties using a path
7
+
8
+ [![NPM version](https://badge.fury.io/js/object-path.png)](http://badge.fury.io/js/object-path)
9
+ [![Build Status](https://travis-ci.org/mariocasciaro/object-path.png)](https://travis-ci.org/mariocasciaro/object-path)
10
+ [![Coverage Status](https://coveralls.io/repos/mariocasciaro/object-path/badge.png)](https://coveralls.io/r/mariocasciaro/object-path)
11
+ [![devDependency Status](https://david-dm.org/mariocasciaro/object-path/dev-status.svg)](https://david-dm.org/mariocasciaro/object-path#info=devDependencies)
12
+ ![Downloads](http://img.shields.io/npm/dm/object-path.svg)
13
+
14
+ [![browser support](https://ci.testling.com/mariocasciaro/object-path.png)](https://ci.testling.com/mariocasciaro/object-path)
15
+
16
+ ## Install
17
+
18
+ ### Node.js
19
+
20
+ ```
21
+ npm install object-path
22
+ ```
23
+
24
+ ### Browser
25
+
26
+ ```
27
+ bower install object-path
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ```javascript
33
+
34
+ var obj = {
35
+ a: {
36
+ b: "d",
37
+ c: ["e", "f"]
38
+ }
39
+ };
40
+
41
+ var objectPath = require("object-path");
42
+
43
+ //get deep property
44
+ objectPath.get(obj, "a.b"); //returns "d"
45
+
46
+ //get the first non-undefined value
47
+ objectPath.coalesce(obj, ['a.z', 'a.d', ['a','b']], 'default');
48
+
49
+ //empty a given path (but do not delete it) depending on their type,so it retains reference to objects and arrays.
50
+ //functions that are not inherited from prototype are set to null.
51
+ //object instances are considered objects and just own property names are deleted
52
+ objectPath.empty(obj, 'a.b'); // obj.a.b is now ''
53
+ objectPath.empty(obj, 'a.c'); // obj.a.c is now []
54
+ objectPath.empty(obj, 'a'); // obj.a is now {}
55
+
56
+ //works also with arrays
57
+ objectPath.get(obj, "a.c.1"); //returns "f"
58
+ objectPath.get(obj, ["a","c","1"]); //returns "f"
59
+
60
+ //can return a default value with get
61
+ objectPath.get(obj, ["a.c.b"], "DEFAULT"); //returns "DEFAULT", since a.c.b path doesn't exists, if omitted, returns undefined
62
+
63
+ //set
64
+ objectPath.set(obj, "a.h", "m"); // or objectPath.set(obj, ["a","h"], "m");
65
+ objectPath.get(obj, "a.h"); //returns "m"
66
+
67
+ //set will create intermediate object/arrays
68
+ objectPath.set(obj, "a.j.0.f", "m");
69
+
70
+ //will insert values in array
71
+ objectPath.insert(obj, "a.c", "m", 1); // obj.a.c = ["e", "m", "f"]
72
+
73
+ //push into arrays (and create intermediate objects/arrays)
74
+ objectPath.push(obj, "a.k", "o");
75
+
76
+ //ensure a path exists (if it doesn't, set the default value you provide)
77
+ objectPath.ensureExists(obj, "a.k.1", "DEFAULT");
78
+
79
+ //deletes a path
80
+ objectPath.del(obj, "a.b"); // obj.a.b is now undefined
81
+ objectPath.del(obj, ["a","c",0]); // obj.a.c is now ['f']
82
+
83
+ //tests path existence
84
+ objectPath.has(obj, "a.b"); // true
85
+ objectPath.has(obj, ["a","d"]); // false
86
+
87
+ ```
88
+
89
+ ### Credits
90
+
91
+ * [Mario Casciaro](https://github.com/mariocasciaro) - Author
92
+ * [Paulo Cesar](https://github.com/pocesar) - Major contributor
93
+
94
+
95
+
96
+
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "object-path",
3
+ "version": "0.6.0",
4
+ "main": "index.js",
5
+ "keywords": [
6
+ "deep",
7
+ "path",
8
+ "access",
9
+ "bean",
10
+ "object"
11
+ ],
12
+ "ignore" : [
13
+ "test.js",
14
+ "coverage",
15
+ "*.yml"
16
+ ]
17
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "object-path",
3
+ "description": "Access deep properties using a path",
4
+ "version": "0.6.0",
5
+ "author": {
6
+ "name": "Mario Casciaro"
7
+ },
8
+ "homepage": "https://github.com/mariocasciaro/object-path",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git://github.com/mariocasciaro/object-path.git"
12
+ },
13
+ "main": "index.js",
14
+ "scripts": ["index.js"],
15
+ "keywords": [
16
+ "deep",
17
+ "path",
18
+ "access",
19
+ "bean"
20
+ ],
21
+ "license": "MIT"
22
+ }
@@ -0,0 +1,269 @@
1
+ (function (root, factory){
2
+ 'use strict';
3
+
4
+ /*istanbul ignore next:cant test*/
5
+ if (typeof module === 'object' && typeof module.exports === 'object') {
6
+ module.exports = factory();
7
+ } else if (typeof define === 'function' && define.amd) {
8
+ // AMD. Register as an anonymous module.
9
+ define([], factory);
10
+ } else {
11
+ // Browser globals
12
+ root.objectPath = factory();
13
+ }
14
+ })(this, function(){
15
+ 'use strict';
16
+
17
+ var
18
+ toStr = Object.prototype.toString,
19
+ _hasOwnProperty = Object.prototype.hasOwnProperty;
20
+
21
+ function isEmpty(value){
22
+ if (!value) {
23
+ return true;
24
+ }
25
+ if (isArray(value) && value.length === 0) {
26
+ return true;
27
+ } else {
28
+ for (var i in value) {
29
+ if (_hasOwnProperty.call(value, i)) {
30
+ return false;
31
+ }
32
+ }
33
+ return true;
34
+ }
35
+ }
36
+
37
+ function toString(type){
38
+ return toStr.call(type);
39
+ }
40
+
41
+ function isNumber(value){
42
+ return typeof value === 'number' || toString(value) === "[object Number]";
43
+ }
44
+
45
+ function isString(obj){
46
+ return typeof obj === 'string' || toString(obj) === "[object String]";
47
+ }
48
+
49
+ function isObject(obj){
50
+ return typeof obj === 'object' && toString(obj) === "[object Object]";
51
+ }
52
+
53
+ function isArray(obj){
54
+ return typeof obj === 'object' && typeof obj.length === 'number' && toString(obj) === '[object Array]';
55
+ }
56
+
57
+ function isBoolean(obj){
58
+ return typeof obj === 'boolean' || toString(obj) === '[object Boolean]';
59
+ }
60
+
61
+ function getKey(key){
62
+ var intKey = parseInt(key);
63
+ if (intKey.toString() === key) {
64
+ return intKey;
65
+ }
66
+ return key;
67
+ }
68
+
69
+ function set(obj, path, value, doNotReplace){
70
+ if (isNumber(path)) {
71
+ path = [path];
72
+ }
73
+ if (isEmpty(path)) {
74
+ return obj;
75
+ }
76
+ if (isString(path)) {
77
+ return set(obj, path.split('.').map(getKey), value, doNotReplace);
78
+ }
79
+ var currentPath = path[0];
80
+
81
+ if (path.length === 1) {
82
+ var oldVal = obj[currentPath];
83
+ if (oldVal === void 0 || !doNotReplace) {
84
+ obj[currentPath] = value;
85
+ }
86
+ return oldVal;
87
+ }
88
+
89
+ if (obj[currentPath] === void 0) {
90
+ //check if we assume an array
91
+ if(isNumber(path[1])) {
92
+ obj[currentPath] = [];
93
+ } else {
94
+ obj[currentPath] = {};
95
+ }
96
+ }
97
+
98
+ return set(obj[currentPath], path.slice(1), value, doNotReplace);
99
+ }
100
+
101
+ function del(obj, path) {
102
+ if (isNumber(path)) {
103
+ path = [path];
104
+ }
105
+
106
+ if (isEmpty(obj)) {
107
+ return void 0;
108
+ }
109
+
110
+ if (isEmpty(path)) {
111
+ return obj;
112
+ }
113
+ if(isString(path)) {
114
+ return del(obj, path.split('.'));
115
+ }
116
+
117
+ var currentPath = getKey(path[0]);
118
+ var oldVal = obj[currentPath];
119
+
120
+ if(path.length === 1) {
121
+ if (oldVal !== void 0) {
122
+ if (isArray(obj)) {
123
+ obj.splice(currentPath, 1);
124
+ } else {
125
+ delete obj[currentPath];
126
+ }
127
+ }
128
+ } else {
129
+ if (obj[currentPath] !== void 0) {
130
+ return del(obj[currentPath], path.slice(1));
131
+ }
132
+ }
133
+
134
+ return obj;
135
+ }
136
+
137
+ var objectPath = {};
138
+
139
+ objectPath.has = function (obj, path) {
140
+ if (isEmpty(obj)) {
141
+ return false;
142
+ }
143
+
144
+ if (isNumber(path)) {
145
+ path = [path];
146
+ } else if (isString(path)) {
147
+ path = path.split('.');
148
+ }
149
+
150
+ if (isEmpty(path) || path.length === 0) {
151
+ return false;
152
+ }
153
+
154
+ for (var i = 0; i < path.length; i++) {
155
+ var j = path[i];
156
+ if ((isObject(obj) || isArray(obj)) && _hasOwnProperty.call(obj, j)) {
157
+ obj = obj[j];
158
+ } else {
159
+ return false;
160
+ }
161
+ }
162
+
163
+ return true;
164
+ };
165
+
166
+ objectPath.ensureExists = function (obj, path, value){
167
+ return set(obj, path, value, true);
168
+ };
169
+
170
+ objectPath.set = function (obj, path, value, doNotReplace){
171
+ return set(obj, path, value, doNotReplace);
172
+ };
173
+
174
+ objectPath.insert = function (obj, path, value, at){
175
+ var arr = objectPath.get(obj, path);
176
+ at = ~~at;
177
+ if (!isArray(arr)) {
178
+ arr = [];
179
+ objectPath.set(obj, path, arr);
180
+ }
181
+ arr.splice(at, 0, value);
182
+ };
183
+
184
+ objectPath.empty = function(obj, path) {
185
+ if (isEmpty(path)) {
186
+ return obj;
187
+ }
188
+ if (isEmpty(obj)) {
189
+ return void 0;
190
+ }
191
+
192
+ var value, i;
193
+ if (!(value = objectPath.get(obj, path))) {
194
+ return obj;
195
+ }
196
+
197
+ if (isString(value)) {
198
+ return objectPath.set(obj, path, '');
199
+ } else if (isBoolean(value)) {
200
+ return objectPath.set(obj, path, false);
201
+ } else if (isNumber(value)) {
202
+ return objectPath.set(obj, path, 0);
203
+ } else if (isArray(value)) {
204
+ value.length = 0;
205
+ } else if (isObject(value)) {
206
+ for (i in value) {
207
+ if (_hasOwnProperty.call(value, i)) {
208
+ delete value[i];
209
+ }
210
+ }
211
+ } else {
212
+ return objectPath.set(obj, path, null);
213
+ }
214
+ };
215
+
216
+ objectPath.push = function (obj, path /*, values */){
217
+ var arr = objectPath.get(obj, path);
218
+ if (!isArray(arr)) {
219
+ arr = [];
220
+ objectPath.set(obj, path, arr);
221
+ }
222
+
223
+ arr.push.apply(arr, Array.prototype.slice.call(arguments, 2));
224
+ };
225
+
226
+ objectPath.coalesce = function (obj, paths, defaultValue) {
227
+ var value;
228
+
229
+ for (var i = 0, len = paths.length; i < len; i++) {
230
+ if ((value = objectPath.get(obj, paths[i])) !== void 0) {
231
+ return value;
232
+ }
233
+ }
234
+
235
+ return defaultValue;
236
+ };
237
+
238
+ objectPath.get = function (obj, path, defaultValue){
239
+ if (isNumber(path)) {
240
+ path = [path];
241
+ }
242
+ if (isEmpty(path)) {
243
+ return obj;
244
+ }
245
+ if (isEmpty(obj)) {
246
+ return defaultValue;
247
+ }
248
+ if (isString(path)) {
249
+ return objectPath.get(obj, path.split('.'), defaultValue);
250
+ }
251
+
252
+ var currentPath = getKey(path[0]);
253
+
254
+ if (path.length === 1) {
255
+ if (obj[currentPath] === void 0) {
256
+ return defaultValue;
257
+ }
258
+ return obj[currentPath];
259
+ }
260
+
261
+ return objectPath.get(obj[currentPath], path.slice(1), defaultValue);
262
+ };
263
+
264
+ objectPath.del = function(obj, path) {
265
+ return del(obj, path);
266
+ };
267
+
268
+ return objectPath;
269
+ });