{"name":"nwsapi","version":"2.2.4","description":"Fast CSS Selectors API Engine","homepage":"http://javascript.nwbox.com/nwsapi/","main":"./src/nwsapi","keywords":["css","css3","css4","matcher","selector"],"licenses":[{"type":"MIT","url":"http://javascript.nwbox.com/nwsapi/MIT-LICENSE"}],"license":"MIT","author":{"name":"Diego Perini","email":"diego.perini@gmail.com","url":"http://www.iport.it/"},"maintainers":[{"name":"diego","email":"diego.perini@gmail.com"}],"bugs":{"url":"http://github.com/dperini/nwsapi/issues"},"repository":{"type":"git","url":"git://github.com/dperini/nwsapi.git"},"scripts":{"lint":"eslint ./src/nwsapi.js"},"gitHead":"8d71cdfcdeb85800d7c0578476e8bca31d36285b","_id":"nwsapi@2.2.4","_nodeVersion":"18.15.0","_npmVersion":"9.6.2","dist":{"integrity":"sha512-NHj4rzRo0tQdijE9ZqAx6kYDcoRwYwSYzCA8MY3JzfxlrvEU0jhnhJT9BhqhJs7I/dKcrDm6TyulaRqZPIhN5g==","shasum":"fd59d5e904e8e1f03c25a7d5a15cfa16c714a1e5","tarball":"http://registry-npm.ywwl.com/nwsapi/download/nwsapi-2.2.4.tgz","fileCount":7,"unpackedSize":80490,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGWyWruxWEHnF/wLPpWmpqMT/T1ebJMo9BgCiw/NI8pNAiEAqdVhhqZZmQGMrP9Xpm+1JjLhhVD1r3D9qJb48XBXvDs="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkNxaSACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo50RAAm6rts2rQqiG1mZx/1gZnHmLcs/jHbhDxlYTbQBRXpVItg/IB\r\nS7AGkN4CSLt6lPxEYcNQoLaZfdbMZV55+mMLxGST1r0b8co1IonraIg4k/Pr\r\nheFdzQdkFieGRLIAXLKjySrx6MM487z9XiJUUyvHVSKjVSILGu3LOTsTCto2\r\ndgTY99gHS3PCaeA7moGPTtmFJ0S1dKbV/UZup7qsXVayfZ9v2xBNwntnLFmr\r\nwEKlJ0IwB5wItx9sxaTlZwUa2O0W/h7Nk9QS7F5mi9xDsvhV9D2wQfIgWh2i\r\nip1YfOel6iXw3ZJn7vMsjCIT2y4JipQOGqxkHts2sRkHMAgdzuVbzXtOsKt8\r\nby6vm4QvO6dEWxYL60UoRYNyM1zmi+C7GOI/+BsISQDaONScrlXIsBEmcqV8\r\nhTsVTq8/0L7s2MQc6LoAaoDa4GDc00pPrn4xGeLOuLw9rkXtRYKTXPWA/iqP\r\n3y6NaTSNjd+fwT3N2bKRpnfx2FDdnBsErnwElhhZdJ6nXYUWTm6cE0Qks6C/\r\ndTKJKuQksxvLXr0vGDc58EiHRN06m5O3hsQimfblXrXJn+qPSfQLDXEEMafF\r\naytfA/8yyddV9cOzJXJcp7OYc5tUZCjAC7z3HnR/l5mW2KyQ3hiHtkV/9TWY\r\nrQyPKz4l6Qm3DUY2/yw65nQuvjdRcSo+lM4=\r\n=GOr8\r\n-----END PGP SIGNATURE-----\r\n","size":19422,"noattachment":false,"key":"/nwsapi/-/nwsapi-2.2.4.tgz"},"_npmUser":{"name":"diego","email":"diego.perini@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nwsapi_2.2.4_1681331857896_0.22476090563430895"},"_hasShrinkwrap":false,"readme":"# [NWSAPI](http://dperini.github.io/nwsapi/)\n\nFast CSS Selectors API Engine\n\n![](https://img.shields.io/npm/v/nwsapi.svg?colorB=orange&style=flat) ![](https://img.shields.io/github/tag/dperini/nwsapi.svg?style=flat) ![](https://img.shields.io/npm/dw/nwsapi.svg?style=flat) ![](https://img.shields.io/github/issues/dperini/nwsapi.svg?style=flat)\n\nNWSAPI is the development progress of [NWMATCHER](https://github.com/dperini/nwmatcher) aiming at [Selectors Level 4](https://www.w3.org/TR/selectors-4/) conformance. It has been completely reworked to be easily extended and maintained. It is a right-to-left selector parser and compiler written in pure Javascript with no external dependencies. It was initially thought as a cross browser library to improve event delegation and web page scraping in various frameworks but it has become a popular replacement of the native CSS selection and matching functionality in newer browsers and headless environments.\n\nIt uses [regular expressions](https://en.wikipedia.org/wiki/Regular_expression) to parse CSS selector strings and [metaprogramming](https://en.wikipedia.org/wiki/Metaprogramming) to transforms these selector strings into Javascript function resolvers. This process is executed only once for each selector string allowing memoization of the function resolvers and achieving unmatched performances.\n\n## Installation\n\nTo include NWSAPI in a standard web page:\n\n```html\n<script type=\"text/javascript\" src=\"nwsapi.js\"></script>\n```\n\nTo include NWSAPI in a standard web page and automatically replace the native QSA:\n\n```html\n<script type=\"text/javascript\" src=\"nwsapi.js\" onload=\"NW.Dom.install()\"></script>\n```\n\nTo use NWSAPI with Node.js:\n\n```\n$ npm install nwsapi\n```\n\nNWSAPI currently supports browsers (as a global, `NW.Dom`) and headless environments (as a CommonJS module).\n\n\n## Supported Selectors\n\nHere is a list of all the CSS2/CSS3/CSS4 [Supported selectors](https://github.com/dperini/nwsapi/wiki/CSS-supported-selectors).\n\n\n## Features and Compliance\n\nYou can read more about NWSAPI [features and compliance](https://github.com/dperini/nwsapi/wiki/Features-and-compliance) on the wiki.\n\n\n## API\n\n### DOM Selection\n\n#### `ancestor( selector, context, callback )`\n\nReturns a reference to the nearest ancestor element matching `selector`, starting at `context`. Returns `null` if no element is found. If `callback` is provided, it is invoked for the matched element.\n\n#### `first( selector, context, callback )`\n\nReturns a reference to the first element matching `selector`, starting at `context`. Returns `null` if no element matches. If `callback` is provided, it is invoked for the matched element.\n\n#### `match( selector, element, callback )`\n\nReturns `true` if `element` matches `selector`, starting at `context`; returns `false` otherwise. If `callback` is provided, it is invoked for the matched element.\n\n#### `select( selector, context, callback )`\n\nReturns an array of all the elements matching `selector`, starting at `context`; returns empty `Array` otherwise. If `callback` is provided, it is invoked for each matching element.\n\n\n### DOM Helpers\n\n#### `byId( id, from )`\n\nReturns a reference to the first element with ID `id`, optionally filtered to descendants of the element `from`.\n\n#### `byTag( tag, from )`\n\nReturns an array of elements having the specified tag name `tag`, optionally filtered to descendants of the element `from`.\n\n#### `byClass( class, from )`\n\nReturns an array of elements having the specified class name `class`, optionally filtered to descendants of the element `from`.\n\n\n### Engine Configuration\n\n#### `configure( options )`\n\nThe following is the list of currently available configuration options, their default values and descriptions, they are boolean flags that can be set to `true` or `false`:\n\n* `IDS_DUPES`: true  - true to allow using multiple elements having the same id, false to disallow\n* `LIVECACHE`: true  - true for caching both results and resolvers, false for caching only resolvers\n* `MIXEDCASE`: true  - true to match tag names case insensitive, false to match using case sensitive\n* `LOGERRORS`: true  - true to print errors and warnings to the console, false to mute both of them\n\n\n### Examples on extending the basic functionalities\n\n#### `configure( { <configuration-flag>: [ true | false ] } )`\n\nDisable logging errors/warnings to console, disallow duplicate ids. Example:\n\n```js\nNW.Dom.configure( { LOGERRORS: false, IDS_DUPES: false } );\n```\nNOTE: NW.Dom.configure() without parameters return the current configuration.\n\n#### `registerCombinator( symbol, resolver )`\n\nRegisters a new symbol and its matching resolver in the combinators table. Example:\n\n```js\nNW.Dom.registerCombinator( '^', 'e.parentElement' );\n```\n\n#### `registerOperator( symbol, resolver )`\n\nRegisters a new symbol and its matching resolver in the attribute operators table. Example:\n\n```js\nNW.Dom.registerOperator( '!=', { p1: '^', p2: '$', p3: 'false' } );\n```\n\n#### `registerSelector( name, rexp, func )`\n\nRegisters a new selector, the matching RE and the resolver function, in the selectors table. Example:\n\n```js\nNW.Dom.registerSelector('Controls', /^\\:(control)(.*)/i,\n  (function(global) {\n    return function(match, source, mode, callback) {\n      var status = true;\n      source = 'if(/^(button|input|select|textarea)/i.test(e.nodeName)){' + source + '}';\n      return { 'source': source, 'status': status };\n    };\n  })(this));\n```\n","publish_time":1681331858101,"_cnpm_publish_time":1681331858101,"dist-tags":{"latest":"2.2.28"}}