{"_id":"dom-iterator","_rev":"411476","name":"dom-iterator","description":"iterator for mini-html-parser","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"mattmueller","email":"mattmuelle@gmail.com"}],"time":{"modified":"2021-08-04T05:09:59.000Z","created":"2014-02-05T15:33:33.968Z","1.0.0":"2018-01-05T06:45:06.515Z","0.3.0":"2014-07-20T17:58:42.997Z","0.2.1":"2014-05-30T07:09:36.020Z","0.2.0":"2014-02-10T14:17:56.977Z","0.1.0":"2014-02-07T17:54:16.485Z","0.0.5":"2014-02-05T15:33:33.968Z"},"users":{"sebjwallace":true},"author":{"name":"Matthew Mueller"},"repository":{"type":"git","url":"git+https://github.com/MatthewMueller/dom-iterator.git"},"versions":{"1.0.0":{"name":"dom-iterator","version":"1.0.0","description":"iterator for mini-html-parser","main":"index.js","directories":{"example":"examples","test":"test"},"dependencies":{"component-xor":"0.0.4","component-props":"1.1.1"},"devDependencies":{"chalk":"2.1.0","mini-html-parser":"0.0.3","mocha":"~1.17.1","component-test":"~0.1.3"},"scripts":{"test":"make test"},"repository":{"type":"git","url":"git+https://github.com/MatthewMueller/dom-iterator.git"},"keywords":["iterator","dom","mini-html-parser"],"author":{"name":"Matthew Mueller"},"license":"MIT","bugs":{"url":"https://github.com/MatthewMueller/dom-iterator/issues"},"homepage":"https://github.com/MatthewMueller/dom-iterator","gitHead":"91121a41d04a09d28bcd4d0e8cd535b8582d2c08","_id":"dom-iterator@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.3.0","_npmUser":{"name":"mattmueller","email":"mattmuelle@gmail.com"},"dist":{"shasum":"9c09899846ec41c2d257adc4d6015e4759ef05ad","size":6171,"noattachment":false,"key":"/dom-iterator/-/dom-iterator-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/dom-iterator/download/dom-iterator-1.0.0.tgz"},"maintainers":[{"name":"mattmueller","email":"mattmuelle@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dom-iterator-1.0.0.tgz_1515134706394_0.8109441564884037"},"publish_time":1515134706515,"_hasShrinkwrap":false,"_cnpm_publish_time":1515134706515},"0.3.0":{"name":"dom-iterator","version":"0.3.0","description":"iterator for mini-html-parser","main":"index.js","directories":{"example":"examples","test":"test"},"dependencies":{"component-xor":"0.0.3","component-props":"1.1.1"},"devDependencies":{"mini-html-parser":"0.0.3","mocha":"~1.17.1","component-test":"~0.1.3"},"browser":{"xor":"component-xor","props":"component-props"},"scripts":{"test":"make test"},"repository":{"type":"git","url":"https://github.com/MatthewMueller/dom-iterator.git"},"keywords":["iterator","dom","mini-html-parser"],"author":{"name":"Matthew Mueller"},"license":"MIT","bugs":{"url":"https://github.com/MatthewMueller/dom-iterator/issues"},"homepage":"https://github.com/MatthewMueller/dom-iterator","gitHead":"9f183af5532f38832e777d54556d29e3369cd05c","_id":"dom-iterator@0.3.0","_shasum":"5a745bf47bc692ac0fa3c0c385396ff2cbd55882","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"tootallnate","email":"nathan@tootallnate.net"},"maintainers":[{"name":"mattmueller","email":"mattmuelle@gmail.com"}],"dist":{"shasum":"5a745bf47bc692ac0fa3c0c385396ff2cbd55882","size":6371,"noattachment":false,"key":"/dom-iterator/-/dom-iterator-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/dom-iterator/download/dom-iterator-0.3.0.tgz"},"publish_time":1405879122997,"_cnpm_publish_time":1405879122997,"_hasShrinkwrap":false},"0.2.1":{"name":"dom-iterator","version":"0.2.1","description":"iterator for mini-html-parser","main":"index.js","directories":{"example":"examples","test":"test"},"dependencies":{"xor":"component/xor#0.0.2","props":"component/props#1.0.3"},"devDependencies":{"mini-html-parser":"0.0.3","mocha":"~1.17.1","component-test":"~0.1.3"},"scripts":{"postinstall":"make npm","test":"make test"},"repository":{"type":"git","url":"https://github.com/MatthewMueller/dom-iterator.git"},"keywords":["iterator","dom","mini-html-parser"],"author":{"name":"Matthew Mueller"},"license":"MIT","bugs":{"url":"https://github.com/MatthewMueller/dom-iterator/issues"},"homepage":"https://github.com/MatthewMueller/dom-iterator","_id":"dom-iterator@0.2.1","dist":{"shasum":"4e64275abbaff8b189c936ea24bc908cf6b41c9c","size":6136,"noattachment":false,"key":"/dom-iterator/-/dom-iterator-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/dom-iterator/download/dom-iterator-0.2.1.tgz"},"_from":".","_npmVersion":"1.3.25","_npmUser":{"name":"mattmueller","email":"mattmuelle@gmail.com"},"maintainers":[{"name":"mattmueller","email":"mattmuelle@gmail.com"}],"publish_time":1401433776020,"_cnpm_publish_time":1401433776020,"_hasShrinkwrap":false},"0.2.0":{"name":"dom-iterator","version":"0.2.0","description":"iterator for mini-html-parser","main":"index.js","directories":{"example":"examples","test":"test"},"dependencies":{"xor":"component/xor#0.0.2","props":"component/props#1.0.3"},"devDependencies":{"mini-html-parser":"0.0.3","mocha":"~1.17.1","component-test":"~0.1.3"},"scripts":{"postinstall":"make npm","test":"make test"},"repository":{"type":"git","url":"https://github.com/MatthewMueller/dom-iterator.git"},"keywords":["iterator","dom","mini-html-parser"],"author":{"name":"Matthew Mueller"},"license":"MIT","bugs":{"url":"https://github.com/MatthewMueller/dom-iterator/issues"},"homepage":"https://github.com/MatthewMueller/dom-iterator","_id":"dom-iterator@0.2.0","dist":{"shasum":"90650f196da52c466ef88f3e883a3d2ca40f3dcc","size":6067,"noattachment":false,"key":"/dom-iterator/-/dom-iterator-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/dom-iterator/download/dom-iterator-0.2.0.tgz"},"_from":".","_npmVersion":"1.3.25","_npmUser":{"name":"mattmueller","email":"mattmuelle@gmail.com"},"maintainers":[{"name":"mattmueller","email":"mattmuelle@gmail.com"}],"publish_time":1392041876977,"_cnpm_publish_time":1392041876977,"_hasShrinkwrap":false},"0.1.0":{"name":"dom-iterator","version":"0.1.0","description":"iterator for mini-html-parser","main":"index.js","directories":{"example":"examples","test":"test"},"dependencies":{"xor":"component/xor#0.0.2","props":"component/props#1.0.3"},"devDependencies":{"mini-html-parser":"0.0.3","mocha":"~1.17.1"},"scripts":{"postinstall":"make npm","test":"make test"},"repository":{"type":"git","url":"https://github.com/MatthewMueller/dom-iterator.git"},"keywords":["iterator","dom","mini-html-parser"],"author":{"name":"Matthew Mueller"},"license":"MIT","bugs":{"url":"https://github.com/MatthewMueller/dom-iterator/issues"},"homepage":"https://github.com/MatthewMueller/dom-iterator","_id":"dom-iterator@0.1.0","dist":{"shasum":"c71b8e2c7cef9037e701cacc4fce3b728405c226","size":5802,"noattachment":false,"key":"/dom-iterator/-/dom-iterator-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/dom-iterator/download/dom-iterator-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.25","_npmUser":{"name":"mattmueller","email":"mattmuelle@gmail.com"},"maintainers":[{"name":"mattmueller","email":"mattmuelle@gmail.com"}],"publish_time":1391795656485,"_cnpm_publish_time":1391795656485,"_hasShrinkwrap":false},"0.0.5":{"name":"dom-iterator","version":"0.0.5","description":"iterator for mini-html-parser","main":"index.js","directories":{"example":"examples","test":"test"},"devDependencies":{"component-test":"~0.1.2"},"scripts":{"test":"make test"},"repository":{"type":"git","url":"https://github.com/MatthewMueller/dom-iterator.git"},"keywords":["iterator","dom","mini-html-parser"],"author":{"name":"Matthew Mueller"},"license":"MIT","bugs":{"url":"https://github.com/MatthewMueller/dom-iterator/issues"},"homepage":"https://github.com/MatthewMueller/dom-iterator","_id":"dom-iterator@0.0.5","dist":{"shasum":"1c29ec3e3fc24044e93119b318a6662306bb0d66","size":6172,"noattachment":false,"key":"/dom-iterator/-/dom-iterator-0.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/dom-iterator/download/dom-iterator-0.0.5.tgz"},"_from":".","_npmVersion":"1.3.25","_npmUser":{"name":"mattmueller","email":"mattmuelle@gmail.com"},"maintainers":[{"name":"mattmueller","email":"mattmuelle@gmail.com"}],"publish_time":1391614413968,"_cnpm_publish_time":1391614413968,"_hasShrinkwrap":false}},"readme":"\n# dom-iterator\n\n  Feature-rich, well-tested Iterator for traversing DOM nodes. A better version of [NodeIterator](https://developer.mozilla.org/en-US/docs/Web/API/NodeIterator). Travels in both directions.\n\n  Can be used in node.js with [mini-html-parser](http://github.com/matthewmueller/mini-html-parser).\n\n## Installation\n\n  Install with [component(1)](http://component.io):\n\n    $ component install matthewmueller/dom-iterator\n\n  With node.js:\n\n    $ npm install dom-iterator\n\n## Example\n\n```js\nvar it = iterator(node);\nvar next;\n\nwhile (next = it.next(Node.TEXT_NODE)) {\n  console.log(next.nodeValue) // next textnodes after node\n}\n```\n\n## API\n\n### `iterator(node, root)`\n\nInitialize an iterator starting on the `node`. Optionally you can\nspecify a `root` to limit your traversal to a particular subtree.\n`root` must be either a parent or an ancestor of `node`.\n\n```js\nvar it = iterator(el.firstChild, el)\n```\n\n### `iterator#next([expr], [n])`\n\nGets the next DOM `node`. If no `node` exists, return `null`.\nYou may pass an expression `expr`, to grab the first node that\nmatches `expr`.\n\nAdditionally, you can pass a number to select the `nth` node.\nDefaults to `1` or the `1st` node.\n\n```js\nvar node = it.next()\n// select the 2nd element node we come across\nvar next = it.next(Node.ELEMENT_NODE, 2)\n```\n\nHere's a look at how the DOM is traversed:\n\n![next](https://i.cloudup.com/kl80e5axNP.png)\n\n### `iterator#prev()`, `iterator#previous()`\n\nGets the previous DOM `node`. If no `node` exists, return `null`.\nYou may pass an expression `expr`, to grab the first node that\nmatches `expr`.\n\nAdditionally, you can pass a number to select the `nth` node.\nDefaults to `1` or the `1st` node.\n\n```js\nvar node = it.prev()\n// select the 2nd element node we come across\nvar prev = it.prev(Node.ELEMENT_NODE, 2)\n```\n\nHere's a look at how the DOM is traversed:\n\n![prev](https://i.cloudup.com/EkaCyvdwvF.png)\n\n### `iterator.select(expr)`\n\niterate over nodes that pass the expression `expr`. The `expr` can be an\nenum, number, string or function. If it's a number, the `nodeType` is compared.\n\nThis function can be chained where all expressions are OR-ed.\n\n```js\nit.select(Node.ELEMENT_NODE)\n  .select(8)\n  .select('nodeValue == \"sloth\"')\n  .select(fn)\n```\n\nThis is saying:\n\n> select all element nodes or comment nodes\n> or nodes with the nodeValue \"sloth\" or\n> nodes that pass the function `fn`.\n\n### `iterator.reject(expr)`\n\niterate over nodes that do not pass the expression `expr`. The `expr` can be an\nenum, number, string or function. If it's a number, the `nodeType` is compared.\n\nThis function can be chained where all expressions are AND-ed.\n\n```js\nit.reject(Node.ELEMENT_NODE)\n  .reject(8)\n  .reject('nodeValue == \"sloth\"')\n  .reject(fn)\n```\n\nThis is saying:\n\n> reject all element nodes and comment nodes\n> and nodes with the nodeValue sloth and\n> nodes that pass the function `fn`\".\n\n### `iterator.revisit(revisit)`\n\nYou can also skip over elements you already visited, by setting `revisit` to false. By default, `revisit` is set to `true`.\n\n```js\nit.revisit(false);\n```\n\nHere's how that would change the iterator:\n\n**it.next():**\n\n![next](https://i.cloudup.com/VX6BbZEuzf.png)\n\n**it.prev()**\n\n![prev](https://i.cloudup.com/NEKe6F4EUX.png)\n\n### `iterator.opening()`\n\nJump to the opening tag of an element. This is the default.\n\n```js\nvar dom = domify('<em>hi</em>');\nvar it = it(dom).opening()\nit.next() // 'hi'\n```\n\n### `iterator.closing()`\n\nJump to the closing tag of an element\n\n```js\nvar dom = domify('<em>hi</em>');\nvar it = it(dom).closing()\nit.prev() // 'hi'\n```\n\n### `iterator.peek([expr], [n])`\n\nSometimes you want to peek on the following or previous node without actually visiting it. With `peek` you can peek forward or backwards `n` steps. If no `n` is given, peek forward 1 step.\n\nPeaking forward:\n\n```js\nit.peek(); // peek forward 1\nit.peek(3); // peek forward 3 steps\n```\n\nPeaking backwards:\n\n```js\nit.peek(Node.ELEMENT_NODE, -3) // peek backwards 3 steps, only selecting element nodes\n```\n\n### `iterator.reset([newNode])`\n\nReset the iterator to the original `node`. Optionally pass a `newNode` to start at.\n\n```js\nit.reset();\n```\n\n### `iterator.use(fn)`\n\nAdd a plugin to the iterator.\n\n## Run Tests\n\nOn the server:\n\n```js\nnpm install\nmake test\n```\n\nOr in the browser:\n\n```js\nnpm install\nmake test-browser\n```\n\n## License\n\n  MIT\n","_attachments":{},"homepage":"https://github.com/MatthewMueller/dom-iterator","bugs":{"url":"https://github.com/MatthewMueller/dom-iterator/issues"},"license":"MIT"}