77 lines
7.2 KiB
JSON
77 lines
7.2 KiB
JSON
{
|
|
"_args": [
|
|
[
|
|
{
|
|
"raw": "traverse@>=0.3.0 <0.4",
|
|
"scope": null,
|
|
"escapedName": "traverse",
|
|
"name": "traverse",
|
|
"rawSpec": ">=0.3.0 <0.4",
|
|
"spec": ">=0.3.0 <0.4.0",
|
|
"type": "range"
|
|
},
|
|
"/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/chainsaw"
|
|
]
|
|
],
|
|
"_defaultsLoaded": true,
|
|
"_engineSupported": true,
|
|
"_from": "traverse@>=0.3.0 <0.4.0",
|
|
"_id": "traverse@0.3.9",
|
|
"_inCache": true,
|
|
"_location": "/traverse",
|
|
"_nodeVersion": "v0.5.0-pre",
|
|
"_npmVersion": "1.0.10",
|
|
"_phantomChildren": {},
|
|
"_requested": {
|
|
"raw": "traverse@>=0.3.0 <0.4",
|
|
"scope": null,
|
|
"escapedName": "traverse",
|
|
"name": "traverse",
|
|
"rawSpec": ">=0.3.0 <0.4",
|
|
"spec": ">=0.3.0 <0.4.0",
|
|
"type": "range"
|
|
},
|
|
"_requiredBy": [
|
|
"/chainsaw"
|
|
],
|
|
"_resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz",
|
|
"_shasum": "717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9",
|
|
"_shrinkwrap": null,
|
|
"_spec": "traverse@>=0.3.0 <0.4",
|
|
"_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/chainsaw",
|
|
"author": {
|
|
"name": "James Halliday"
|
|
},
|
|
"bugs": {
|
|
"url": "https://github.com/substack/js-traverse/issues"
|
|
},
|
|
"dependencies": {},
|
|
"description": "Traverse and transform objects by visiting every node on a recursive walk",
|
|
"devDependencies": {
|
|
"expresso": "0.7.x"
|
|
},
|
|
"directories": {},
|
|
"dist": {
|
|
"shasum": "717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9",
|
|
"tarball": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz"
|
|
},
|
|
"engines": {
|
|
"node": "*"
|
|
},
|
|
"homepage": "https://github.com/substack/js-traverse#readme",
|
|
"license": "MIT/X11",
|
|
"main": "./index",
|
|
"name": "traverse",
|
|
"optionalDependencies": {},
|
|
"readme": "traverse\n========\n\nTraverse and transform objects by visiting every node on a recursive walk.\n\nexamples\n========\n\ntransform negative numbers in-place\n-----------------------------------\n\nnegative.js\n\n````javascript\nvar traverse = require('traverse');\nvar obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ];\n\ntraverse(obj).forEach(function (x) {\n if (x < 0) this.update(x + 128);\n});\n\nconsole.dir(obj);\n````\n\nOutput:\n\n [ 5, 6, 125, [ 7, 8, 126, 1 ], { f: 10, g: 115 } ]\n\ncollect leaf nodes\n------------------\n\nleaves.js\n\n````javascript\nvar traverse = require('traverse');\n\nvar obj = {\n a : [1,2,3],\n b : 4,\n c : [5,6],\n d : { e : [7,8], f : 9 },\n};\n\nvar leaves = traverse(obj).reduce(function (acc, x) {\n if (this.isLeaf) acc.push(x);\n return acc;\n}, []);\n\nconsole.dir(leaves);\n````\n\nOutput:\n\n [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]\n\ncontext\n=======\n\nEach method that takes a callback has a context (its `this` object) with these\nattributes:\n\nthis.node\n---------\n\nThe present node on the recursive walk\n\nthis.path\n---------\n\nAn array of string keys from the root to the present node\n\nthis.parent\n-----------\n\nThe context of the node's parent.\nThis is `undefined` for the root node.\n\nthis.key\n--------\n\nThe name of the key of the present node in its parent.\nThis is `undefined` for the root node.\n\nthis.isRoot, this.notRoot\n-------------------------\n\nWhether the present node is the root node\n\nthis.isLeaf, this.notLeaf\n-------------------------\n\nWhether or not the present node is a leaf node (has no children)\n\nthis.level\n----------\n\nDepth of the node within the traversal\n\nthis.circular\n-------------\n\nIf the node equals one of its parents, the `circular` attribute is set to the\ncontext of that parent and the traversal progresses no deeper.\n\nthis.update(value)\n------------------\n\nSet a new value for the present node.\n\nthis.remove()\n-------------\n\nRemove the current element from the output. If the node is in an Array it will\nbe spliced off. Otherwise it will be deleted from its parent.\n\nthis.delete()\n-------------\n\nDelete the current element from its parent in the output. Calls `delete` even on\nArrays.\n\nthis.before(fn)\n---------------\n\nCall this function before any of the children are traversed.\n\nthis.after(fn)\n--------------\n\nCall this function after any of the children are traversed.\n\nthis.pre(fn)\n------------\n\nCall this function before each of the children are traversed.\n\nthis.post(fn)\n-------------\n\nCall this function after each of the children are traversed.\n\nmethods\n=======\n\n.map(fn)\n--------\n\nExecute `fn` for each node in the object and return a new object with the\nresults of the walk. To update nodes in the result use `this.update(value)`.\n\n.forEach(fn)\n------------\n\nExecute `fn` for each node in the object but unlike `.map()`, when\n`this.update()` is called it updates the object in-place.\n\n.reduce(fn, acc)\n----------------\n\nFor each node in the object, perform a\n[left-fold](http://en.wikipedia.org/wiki/Fold_(higher-order_function))\nwith the return value of `fn(acc, node)`.\n\nIf `acc` isn't specified, `acc` is set to the root object for the first step\nand the root element is skipped.\n\n.deepEqual(obj)\n---------------\n\nReturns a boolean, whether the instance value is equal to the supplied object\nalong a deep traversal using some opinionated choices.\n\nSome notes:\n\n* RegExps are equal if their .toString()s match, but not functions since\nfunctions can close over different variables.\n\n* Date instances are compared using `.getTime()` just like `assert.deepEqual()`.\n\n* Circular references must refer to the same paths within the data structure for\nboth objects. For instance, in this snippet:\n\n````javascript\nvar a = [1];\na.push(a); // a = [ 1, *a ]\n\nvar b = [1];\nb.push(a); // b = [ 1, [ 1, *a ] ]\n````\n\n`a` is not the same as `b` since even though the expansion is the same, the\ncircular references in each refer to different paths into the data structure.\n\nHowever, in:\n\n````javascript\nvar c = [1];\nc.push(c); // c = [ 1, *c ];\n````\n\n`c` is equal to `a` in a `deepEqual()` because they have the same terminal node\nstructure.\n\n* Arguments objects are not arrays and neither are they the same as regular\nobjects.\n\n* Instances created with `new` of String, Boolean, and Number types are never\nequal to the native versions.\n\n.paths()\n--------\n\nReturn an `Array` of every possible non-cyclic path in the object.\nPaths are `Array`s of string keys.\n\n.nodes()\n--------\n\nReturn an `Array` of every node in the object.\n\n.clone()\n--------\n\nCreate a deep clone of the object.\n\ninstallation\n============\n\nUsing npm:\n npm install traverse\n\nOr check out the repository and link your development copy:\n git clone http://github.com/substack/js-traverse.git\n cd js-traverse\n npm link .\n\nYou can test traverse with \"expresso\":http://github.com/visionmedia/expresso\n(`npm install expresso`):\n js-traverse $ expresso\n \n 100% wahoo, your stuff is not broken!\n\nhash transforms\n===============\n\nThis library formerly had a hash transformation component. It has been\n[moved to the hashish package](https://github.com/substack/node-hashish).\n",
|
|
"readmeFilename": "README.markdown",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+ssh://git@github.com/substack/js-traverse.git"
|
|
},
|
|
"scripts": {
|
|
"test": "expresso"
|
|
},
|
|
"version": "0.3.9"
|
|
}
|