{"_id":"@analytickit/simmerjs","_rev":"4-70eb11b81964ae9c4ee1ff3e61ccf423","time":{"created":"2022-09-01T18:30:51.389Z","0.7.7":"2022-08-23T13:44:22.813Z","modified":"2022-10-15T11:20:24.833Z","0.5.6":"2022-09-01T18:30:51.707Z","0.0.1":"2022-10-15T11:20:24.745Z"},"name":"@analytickit/simmerjs","dist-tags":{"latest":"0.0.1"},"versions":{"0.5.6":{"name":"@analytickit/simmerjs","description":"A pure Javascript reverse CSS selector engine which calculates a DOM element's unique CSS selector on the current page.","version":"0.5.6","author":{"name":"Gidi Meir Morris"},"main":"lib/simmer.js","jsnext:main":"modules/simmer.js","repository":{"type":"git","url":"git+https://github.com/gmmorris/simmerjs.git"},"licenses":[{"type":"MIT","url":"https://github.com/gmmorris/simmerjs/blob/master/LICENSE"}],"dependencies":{"lodash.difference":"^4.5.0","lodash.flatmap":"^4.5.0","lodash.isfunction":"^3.0.8","lodash.take":"^4.1.1","lodash.takeright":"^4.1.1"},"scripts":{"test":"npm run testUnit && npm run testIntegration","testw":"jest .test.js  --watch","testUnit":"jest ./modules","testIntegration":"jest ./**/integration/*.test.js","testE2E":"npm run build && nightwatch --config nightwatch.conf.js","build":"npm run buildBrowser && npm run buildModule","buildBrowser":"rollup -c","buildModule":"rm -rf ./lib && babel modules -d lib --ignore .test.js","lint":"eslint ./modules/**/*.js","format":"prettier-eslint --write \"modules/**/*.js\"","formatTests":"prettier-eslint --write \"__tests__/integration/*.js\"","precommit":"lint-staged","prepublish":"npm run buildModule"},"lint-staged":{"*.js":["npm run format","npm run lint","git add"]},"devDependencies":{"babel-cli":"^6.24.1","babel-jest":"^20.0.3","babel-plugin-external-helpers":"^6.22.0","babel-plugin-transform-object-rest-spread":"^6.23.0","babel-preset-env":"^1.5.1","babel-preset-es2015":"^6.24.1","babel-preset-es2016":"^6.24.1","env2":"^2.2.0","eslint":"^4.0.0","eslint-config-standard":"^10.2.1","eslint-plugin-import":"^2.3.0","eslint-plugin-jest":"^20.0.3","eslint-plugin-node":"^5.0.0","eslint-plugin-promise":"^3.5.0","eslint-plugin-standard":"^3.0.1","express":"^4.15.3","husky":"^0.13.4","jest":"^20.0.4","jest-codemods":"^0.10.1","jsdom":"^11.0.0","lint-staged":"^4.0.0","nightwatch":"^0.9.15","path":"^0.12.7","prettier":"^1.4.4","prettier-eslint-cli":"^4.1.1","regenerator-runtime":"^0.10.5","rollup":"^0.42.0","rollup-plugin-babel":"^2.7.1","rollup-plugin-closure-compiler-js":"^1.0.4","rollup-plugin-commonjs":"^8.0.2","rollup-plugin-node-resolve":"^3.0.0","selenium-download":"^2.0.10","sinon":"^2.3.2","standard":"^10.0.2"},"keywords":["Simmer","css","css selector","sizzle"],"gitHead":"e0d67cef879c5fc089a10f08bb3e1ba4530dbb81","bugs":{"url":"https://github.com/gmmorris/simmerjs/issues"},"homepage":"https://github.com/gmmorris/simmerjs#readme","_id":"@analytickit/simmerjs@0.5.6","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-UO7PP127TnqkRpQiKimePZaNBa+9wUJwJyStubtdJW96MNs8sWSY9COUfHkH0IPQu8vSIfQCelS44rapjxft2A==","shasum":"26a53551f1e18d4dc23e5a0d40118ad9169eecc0","tarball":"https://registry.npmjs.org/@analytickit/simmerjs/-/simmerjs-0.5.6.tgz","fileCount":27,"unpackedSize":66363,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC0oU9qMjp7Elqk9YfgSxADQdv36jyWJ1xcCDIXwk05gAiB51Rq6Vc+bIdKwpvJUxDhhvmlzLMFIQamyRTlmfymOSQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjEPpbACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrmwQ/+Lp4VD5M96Bb6IWqG4webj3fFvDtDDaNxUXN8UULKF0XTsjzo\r\nG1wApltUM9CLgzDF0Qv0hq7fpIbUzOiZDWeJ9760G8GFONBzIpcmALOOzzo1\r\nYE+azSQ9Nhg+euGMRK90Dn6troRSfHi5KvMPyWQgx0Hm/0pnVUZQA5NjKQwk\r\nP9lgyVWZ5ob0UV8C1ganF85xPmxIHUciLf4RxihdBbsgQ2Yz00sqBMR1slkY\r\nh70cMRCbVJ1jxWiLFiPU2WdI7sP2IWKQK7Uxh/TtuidqOLP2M0Hrtoeqsq9b\r\nqI/ddVgNMzvMtGdb3FGuv/BqmYAnkNR1YqnzpRimDn75pxAmDwVxCi0/0ipH\r\nYyoe1+M9XQOu4ScP3BHO/3rC8XQvlDMOMq5TctWjG0qe5G22LfXm6Ppu15Qu\r\nXBBIUyQKapwSQA/b1UNpRLt7yXLIOgEm5/KAvBraWFqDn05rqW72XmX9C5o4\r\nZJSD3wC9AeCEX+88/Z7hb3UiA1lkmqyx2Mj3ElOt2OpXJamAIUe1UeaUorYP\r\n2pBYe1bBZoJV9Gj3oBh/gbZno+EKgqZivAlgnnDE/Heo6EBAAPvtq3rV+4tD\r\njTo7y8mFxrhT65DEvKMobe861HLN7E90HjXhqEsmFPRRrd5ElppEKR4aGwWA\r\n31pW2c5DUNiy0eQkSYqTCR6mG1m+Cvw5jOE=\r\n=6ctb\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"kitadmin1","email":"analytickit@gmail.com"},"directories":{},"maintainers":[{"name":"kitadmin1","email":"analytickit@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simmerjs_0.5.6_1662057051453_0.42239471820667274"},"_hasShrinkwrap":false},"0.0.1":{"name":"@analytickit/simmerjs","description":"A pure Javascript reverse CSS selector engine which calculates a DOM element's unique CSS selector on the current page.","version":"0.0.1","author":{"name":"Gidi Meir Morris"},"main":"lib/simmer.js","jsnext:main":"modules/simmer.js","types":"index.d.ts","repository":{"type":"git","url":"git+https://github.com/gmmorris/simmerjs.git"},"licenses":[{"type":"MIT","url":"https://github.com/gmmorris/simmerjs/blob/master/LICENSE"}],"dependencies":{"@babel/runtime":"^7.17.9","lodash.difference":"^4.5.0","lodash.flatmap":"^4.5.0","lodash.isfunction":"^3.0.8","lodash.take":"^4.1.1","lodash.takeright":"^4.1.1","query-selector-shadow-dom":"^1.0.0"},"scripts":{"test":"yarn run testUnit && yarn run testIntegration","testw":"jest .test.js  --watch","testUnit":"jest ./modules","testIntegration":"jest ./**/integration/*.test.js","testE2E":"yarn run build && nightwatch --config nightwatch.conf.js","build":"yarn run buildBrowser && yarn run buildModule","buildBrowser":"rollup -c","buildModule":"rm -rf ./lib && babel modules -d lib --ignore .test.js","lint":"eslint ./modules/**/*.js","format":"prettier-eslint --write \"modules/**/*.js\"","formatTests":"prettier-eslint --write \"__tests__/integration/*.js\"","precommit":"lint-staged","prepare":"yarn build"},"lint-staged":{"*.js":["yarn run format","yarn run lint","git add"]},"devDependencies":{"@ampproject/rollup-plugin-closure-compiler":"^0.26.0","@babel/cli":"^7.17.10","@babel/core":"^7.17.10","@babel/plugin-external-helpers":"^7.16.7","@babel/plugin-transform-parameters":"^7.16.7","@babel/plugin-transform-runtime":"^7.17.10","@babel/preset-env":"^7.17.10","@rollup/plugin-babel":"^5.2.1","@rollup/plugin-commonjs":"^15.1.0","@rollup/plugin-node-resolve":"^9.0.0","babel-jest":"^26.3.0","env2":"^2.2.0","eslint":"^7.10.0","eslint-config-standard":"^14.1.1","eslint-plugin-import":"^2.3.0","eslint-plugin-jest":"^24.0.2","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^4.2.1","eslint-plugin-standard":"^4.0.1","express":"^4.15.3","husky":"^4.3.0","jest":"^26.4.2","jest-codemods":"^0.23.0","jsdom":"^16.4.0","lint-staged":"^10.4.0","nightwatch":"^1.4.3","path":"^0.12.7","prettier":"^2.1.2","prettier-eslint-cli":"^5.0.0","regenerator-runtime":"^0.13.7","rollup":"^2.28.2","selenium-download":"^2.0.10","sinon":"^9.1.0","standard":"^14.3.4"},"keywords":["Simmer","css","css selector","sizzle"],"jest":{"transform":{"^.+\\.[t|j]sx?$":"babel-jest"},"transformIgnorePatterns":["node_modules/(?!(query-selector-shadow-dom)/)"]},"bugs":{"url":"https://github.com/gmmorris/simmerjs/issues"},"homepage":"https://github.com/gmmorris/simmerjs#readme","_id":"@analytickit/simmerjs@0.0.1","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-OCvsm5EuQURH/AoNBTcPRrxXI63wfFd8FyNqGqatx+px8MLvfWRI50OES3AU5K6LDFaXyZCOMAKv52vurKyqfg==","shasum":"55292a17462a26953710278ffce7b3aac99bc80d","tarball":"https://registry.npmjs.org/@analytickit/simmerjs/-/simmerjs-0.0.1.tgz","fileCount":47,"unpackedSize":112857,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC23DHeQoa0SZsS8QUMUQZ11SixBciZBIVRyBRnuD0iUAiEA87gNNEXRvEYNFpVSMikCRmfB23r5RhTBzL/jPPSNHEM="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjSpd4ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmov0xAAhWBqTISBPiyuV4CCDElGxGAwbkVqQVV4MSpGztQtBU5JDz8K\r\nU3z3inUYqE3GCg3/trownyysma9HCbWZHFpZhDFinDREJG5weIWbL/rWnlVZ\r\nEuuX8owWiaOCISS8Yvs5JEOk3+x4iuR/+lGRpqVX1rmklT6suvIpQJfM3zRd\r\nXN0R2m1oHqkzTJAJBxc22fTGtQSSVL9msrUZRqR4ExEd6hbLkl8pjdtq3mHI\r\nwm2f6c4bE87JVFyHWplMdWUapmuMWPRbAP+iOyE6lfdeMNgOcR3Pfrsilfv1\r\nGw2rXlqpKqnGYIhdl+D+hYV/IxaojDD0JmFzOfRKItiq2emXCnPs91gATxdy\r\ncPwAw26RUypKSGSObvbt0bwOQ9WkMx5nCDHFFlJCK2wJtkL+wYRiUB8aWs73\r\nOixLegh9Ygxlj7/0KG42y7t7K2wMcPF3/BLpRf313waYx8LE7hV0IBfh+3w2\r\nAVj8mG9QmCwz2MV+j1H9fA1clrHAkPuCtlbGM+YIoAOnLi5xIjwNeeOukj8O\r\n/0QdCb4WzJaee2fub62IWNpBSSIE1WrrdzPeOVxw4r43DWbzI7JxS5tRCrDy\r\nsW0ySw0voGitkuJYr0zgUMz9LsCjwsn6epOfd89muNiBm5BfUA7YeBFLrvtA\r\nSSg+vSpoVzOxG6JMXpprTumN29E6TaT5LOM=\r\n=mX7M\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"kitadmin1","email":"analytickit@gmail.com"},"directories":{},"maintainers":[{"name":"kitadmin1","email":"analytickit@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simmerjs_0.0.1_1665832824568_0.6076007055736647"},"_hasShrinkwrap":false}},"maintainers":[{"name":"kitadmin1","email":"analytickit@gmail.com"}],"description":"A pure Javascript reverse CSS selector engine which calculates a DOM element's unique CSS selector on the current page.","homepage":"https://github.com/gmmorris/simmerjs#readme","keywords":["Simmer","css","css selector","sizzle"],"repository":{"type":"git","url":"git+https://github.com/gmmorris/simmerjs.git"},"author":{"name":"Gidi Meir Morris"},"bugs":{"url":"https://github.com/gmmorris/simmerjs/issues"},"readme":"Simmer JS [![Build Status](https://travis-ci.org/gmmorris/simmerjs.svg?branch=master)](https://travis-ci.org/gmmorris/simmerjs) [![Code Climate](https://codeclimate.com/github/gmmorris/simmerjs/badges/gpa.svg)](https://codeclimate.com/github/gmmorris/simmerjs)\n=========\n\n## Docs\n\nA pure Javascript reverse CSS selector engine which calculates a DOM element's unique CSS selector on the current page.\n\n## Installation\nSimmer is now meant to be consumed as a module via npm and is no longer meant as a drop in script into the browser.\nThat said, we still build a version meant to be dropped into the browser which resides on *window.Simmer* as before.\n\nWe highly recommend you consume Simmer in the following manner, but in the interest of supporting exosting users we've retained the previous API.\n\n```bash\nnpm i --save simmerjs\n```\n\nAnd then in your code:\n```js\nimport Simmer from 'simmerjs'\n\nconst simmer = new Simmer()\n\nconst el =  document.getElementById('#SomeElement')\n\nexpect(\n    simmer(el)\n).to.equal(\n    '#SomeElement'\n)\n\n```\n\nWhen using the distribution located in the repo under **dist/simmer.js** a global *Simmer* function will be exposed on the **window**.\nThis is **not** the constructor, but rather a default instance which has exposed itself on the window wit ha default configuration.\nThis is not an idea API and is meant to maintain the original API dating back to 2011 when this library was originally written.\n\n### Basic usage\n\nTo use Simmer to analyze an element and produce a unique CSS selector for it, all you have to do is instansiate a simmer query engine and pass it an element on the page.\nUsually you'd create a single instance which you would then use multiple times.\n\n\n```html\n<div id=\"myUniqueElement\">\n    <span></span>\n    <br/>\n    <span></span>\n</div>\n```\n\n```js\nimport Simmer from 'simmerjs'\n\nconst simmer = new Simmer(window, { /* some custom configuration */ })\nvar myElement = document.getElementById(\"#myUniqueElement\");\n\nconsole.log(simmer(myElement)); // prints \"[id='myUniqueElement']\"\n```\n## API\n\n### Simmer\n```js\n    Simmer([Scope], [Options], [query])\n```\n\n#### Scope\nWhen you create an instance of Simmer its first argument is the context in which Simmer should query for elements.\nGenerally speaking this would be the **window**, which is the default value, but it would be overriden in a situation where you might be using Simmer against a Virtual Dom implementation.\nIf you _are_ using a Virtual DOM, you should provide the Window object of the Virtual DOM\n\n#### Options\nThe second argument is an Options object allowing you to override the default configuration for Simmer's behaviour.\n\nThe options are:\n\n| Option | Default |\n| ------ | ------- |\n| **specificityThreshold** - A minimum specificty level. Once the parser reaches this level it starts verifying the selector after every method is called. This can cut down our execution time by avoiding needless parsing but can also hurt execution times by performing many verifications. Specificity is calculated based on the W3C spec: http://www.w3.org/TR/css3-selectors/#specificity |  100 |\n| **depth** - How deep into the DOM hierarchy should Simmer go in order to reach a unique selector. This is a delicate game because the higher the number the more likely you are to reach a unique selector, but it also means a longer and more breakable one. Assuming you want to store this selector to use later, making it longer also means it is more likely to change and loose it's validity. | 3 | |\n| **errorHandling** - How to handle errors which occur during the analysis <br/><br/>Valid Options<br/><ul><li>_false_: errors are ignored by Simmer</li><li>_true_: errors rethrown and expected to be caught by the user</li><li>_a function callback will be called with two parameters: the exception and the element being analyzed</li></ul> | false |\n| **selectorMaxLength** - A maximum length for the CSS selector can be specified - if no specific selector can be found which is shorter than this length then it is treated as if no selector could be found. | 520 |\n\n#### query\nThe third argument is a query engine you wish Simmer to use when evaluating generated selectors.\nBy default Simmer uses the **window.document.querySelectorAll** function and if you provide a window to the scope, Simmer will assume that you want it to use the **document.querySelectorAll** on that **window**.\nBut if you wish Simmer to use another custom function, such as your own tweaked version of jQuery, you can do so by passing the third argument to the Simmer constructor.\n\nThe signature the query function should provide is this:\n\n##### query(selector: String, onError: Error => {}) : Array(DomElements)\nWhat this means is that the function you provide should expect to receive a string CSS selector and a function.\nIt should them query for elements matching the selector and return an array of the results (even if there is only one result, it should be returned in an Array.).\n\nThe second argument is a function which should be called if any error is encountered when querying for the elements.\nIf an error occurs or a problem is encountered, instead of throwing, you should call the function and pass the error object to it. Simmer will then handle the error as per its configuration.\n\n### Reconfiguring\nIf you have an existing instance of Simmer, you can use its **configure** method to instanciate a new Simmer which has the same scope and configuration as the existing one, with any new configuration you wish to apply.\n\nSo, for example, in the browser, you can replace the global Simmer wit ha newly configured version:\n```js\n\nwindow.Simmer = window.Simmer.configure({\n    depth: 10\n})\n```\n\nAnd in Node:\n```js\nimport Simmer from 'simmerjs'\n\nconst virtualWindow = new JSDom()\n\nconst simmer = new Simmer(virtualWindow)\n\nconst reconfiguredSimmer = simmer.configure({ /* some custom configuration */ })\n\n```\n\n### Conflict\nWhen the Simmer browser dist located at **dist/simmer.js** is injected in to the browser it adds the noConflict function on itself.\nThis is not relevant in a Node environment and isn't available there.\n\nJust in case you also had the brilliant idea of using a variable called \"Simmer\", or you wish to move it off of the global object then you can use the noConflict method to receive a reference to the object and remove it from the window.\nCalling it will also revert the original value of window.Simmer which was there before loading the Simmer.js script (if there was one)\n\n```js\n    var mySimmer = Simmer.noConflict();\n    mySimmer(myElm);\n```\n","readmeFilename":"README.md"}