{"_id":"@a-la/detect-jsx","_rev":"300341","name":"@a-la/detect-jsx","description":"Detects Position Of JSX Tag In JavaScript File.","dist-tags":{"latest":"1.0.2"},"maintainers":[{"name":"zvr","email":""}],"time":{"modified":"2024-01-31T16:08:12.000Z","created":"2019-01-10T05:08:11.996Z","1.0.2":"2020-02-03T05:08:04.917Z","1.0.1":"2019-01-15T19:53:31.721Z","1.0.0":"2019-01-10T05:08:11.996Z"},"users":{},"author":{"name":"Anton","email":"anton@adc.sh"},"repository":{"type":"git","url":"git://github.com/a-la/detect-jsx.git"},"versions":{"1.0.2":{"name":"@a-la/detect-jsx","version":"1.0.2","description":"Detects Position Of JSX Tag In JavaScript File.","main":"build","module":"src/index.js","scripts":{"t":"zoroaster -a","test":"yarn t test/spec test/mask","spec":"yarn t test/spec","mask":"yarn t test/mask","test-build":"ALAMODE_ENV=test-build yarn test","lint":"eslint .","doc":"NODE_DEBUG=doc doc documentary -o README.md","b":"alamode src -o build -s","d":"yarn-s d1","d1":"NODE_DEBUG=doc doc src/index.js -g","build":"yarn-s d b doc","rec":"NODE_DEBUG=appshot appshot -T 23 -a Terminal -y 150 -f","e":"node example","example/":"yarn e example/example.js"},"repository":{"type":"git","url":"git://github.com/a-la/detect-jsx.git"},"keywords":["detect-jsx","a-la"],"author":{"name":"Anton","email":"anton@adc.sh"},"license":"MIT","bugs":{"url":"https://github.com/a-la/detect-jsx/issues"},"homepage":"https://github.com/a-la/detect-jsx#readme","devDependencies":{"@wrote/read":"^1.0.4","alamode":"^3.3.2","documentary":"^1.35.11","eslint-config-artdeco":"^1.0.1","yarn-s":"^1.2.3","zoroaster":"^4.2.0"},"licenseText":"MIT License\n\nCopyright (c) 2019 Art Deco Code Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@a-la/detect-jsx@1.0.2","dist":{"shasum":"8bf79bb5f977a9b41581c37b4fc835cb3995f64c","size":3238,"noattachment":false,"key":"/@a-la/detect-jsx/-/@a-la/detect-jsx-1.0.2.tgz","tarball":"http://name.csiicloud.com:7001/@a-la/detect-jsx/download/@a-la/detect-jsx-1.0.2.tgz"},"maintainers":[{"name":"zvr","email":""}],"_npmUser":{"name":"zvr","email":"anton@adc.sh"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/detect-jsx_1.0.2_1580706484773_0.5209218492872145"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-19T19:20:51.647Z","publish_time":1580706484917,"_cnpm_publish_time":1580706484917},"1.0.1":{"name":"@a-la/detect-jsx","version":"1.0.1","description":"Detects Position Of JSX Tag In JavaScript File.","main":"build","module":"src/index.js","scripts":{"t":"zoroaster -a","test":"yarn t test/spec test/mask","spec":"yarn t test/spec","mask":"yarn t test/mask","test-build":"ALAMODE_ENV=test-build yarn test","lint":"eslint .","doc":"NODE_DEBUG=doc doc documentary -o README.md","b":"alamode src -o build -s","d":"yarn-s d1","d1":"NODE_DEBUG=doc doc src/index.js -g","build":"yarn-s d b doc","rec":"NODE_DEBUG=appshot appshot -T 23 -a Terminal -y 150 -f","e":"node example","example/":"yarn e example/example.js"},"repository":{"type":"git","url":"git://github.com/a-la/detect-jsx.git"},"keywords":["detect-jsx","a-la"],"author":{"name":"Anton","email":"anton@adc.sh"},"license":"MIT","bugs":{"url":"https://github.com/a-la/detect-jsx/issues"},"homepage":"https://github.com/a-la/detect-jsx#readme","devDependencies":{"@wrote/read":"1.0.2","alamode":"1.6.1","documentary":"1.20.1","eslint-config-artdeco":"1.0.1","yarn-s":"1.1.0","zoroaster":"3.6.6"},"licenseText":"MIT License\n\nCopyright (c) 2019 Art Deco Code Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@a-la/detect-jsx@1.0.1","dist":{"shasum":"ef36b5f3c129e0901d5752a86999a9910f6b5e7a","size":3175,"noattachment":false,"key":"/@a-la/detect-jsx/-/@a-la/detect-jsx-1.0.1.tgz","tarball":"http://name.csiicloud.com:7001/@a-la/detect-jsx/download/@a-la/detect-jsx-1.0.1.tgz"},"maintainers":[{"name":"zvr","email":""}],"_npmUser":{"name":"zvr","email":"anton@adc.sh"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/detect-jsx_1.0.1_1547582011606_0.778413466119724"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-19T19:20:50.005Z","publish_time":1547582011721,"_cnpm_publish_time":1547582011721},"1.0.0":{"name":"@a-la/detect-jsx","version":"1.0.0","description":"Detects Position Of JSX Tag In JavaScript File.","main":"build","scripts":{"t":"zoroaster -a","test":"yarn t test/spec test/mask","spec":"yarn t test/spec","mask":"yarn t test/mask","test-build":"ALAMODE_ENV=test-build yarn test","lint":"eslint .","doc":"NODE_DEBUG=doc doc documentary -o README.md","b":"alamode src -o build -s","d":"yarn-s d1","d1":"NODE_DEBUG=doc doc src/index.js -g","build":"yarn-s d b doc","rec":"NODE_DEBUG=appshot appshot -T 23 -a Terminal -y 150 -f","e":"node example","example/":"yarn e example/example.js"},"repository":{"type":"git","url":"git://github.com/a-la/detect-jsx.git"},"keywords":["detect-jsx","a-la"],"author":{"name":"Anton","email":"anton@adc.sh"},"license":"MIT","bugs":{"url":"https://github.com/a-la/detect-jsx/issues"},"homepage":"https://github.com/a-la/detect-jsx#readme","devDependencies":{"@wrote/read":"1.0.0","alamode":"1.6.1","documentary":"1.20.1","eslint-config-artdeco":"1.0.1","yarn-s":"1.1.0","zoroaster":"3.6.6"},"licenseText":"MIT License\n\nCopyright (c) 2019 Art Deco Code Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@a-la/detect-jsx@1.0.0","dist":{"shasum":"a41a78ba5a430195054097d591e95f1cf20548ee","size":2971,"noattachment":false,"key":"/@a-la/detect-jsx/-/@a-la/detect-jsx-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/@a-la/detect-jsx/download/@a-la/detect-jsx-1.0.0.tgz"},"maintainers":[{"name":"zvr","email":""}],"_npmUser":{"name":"zvr","email":"anton@adc.sh"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/detect-jsx_1.0.0_1547096891845_0.87124985150304"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-19T19:20:48.363Z","publish_time":1547096891996,"_cnpm_publish_time":1547096891996}},"readme":"# @a-la/detect-jsx\n\n[![npm version](https://badge.fury.io/js/%40a-la%2Fdetect-jsx.svg)](https://www.npmjs.com/package/@a-la/detect-jsx)\n\n`@a-la/detect-jsx` Detects Position Of JSX Tag In JavaScript File.\n\n```sh\nyarn add -E @a-la/detect-jsx\n```\n\n## Table Of Contents\n\n- [Table Of Contents](#table-of-contents)\n- [API](#api)\n- [`detectJsx(string: string): number`](#detectjsxstring-string-number)\n- [Copyright](#copyright)\n\n<p align=\"center\"><a href=\"#table-of-contents\">\n  <img src=\"/.documentary/section-breaks/0.svg?sanitize=true\">\n</a></p>\n\n## API\n\nThe package is available by importing its default function:\n\n```js\nimport detectJsx from '@a-la/detect-jsx'\n```\n\n<p align=\"center\"><a href=\"#table-of-contents\">\n  <img src=\"/.documentary/section-breaks/1.svg?sanitize=true\">\n</a></p>\n\n## <code><ins>detectJsx</ins>(</code><sub><br/>&nbsp;&nbsp;`string: string,`<br/></sub><code>): <i>number</i></code>\n\nReturns the position of the first JSX tag by evaluating the code using Node's `vm` package: since JSX reference will throw an error, this error can be caught and used to find out the index of the opening `<` symbol in JSX.\n\nFor example, given the following JSX component:\n```jsx\nconst Component = ({ example }) => (\n  <div class=\"Test\" id={example}></div>\n)\n```\n\nIt is possible to detect where `JSX` starts:\n\n```js\n/* yarn example/ */\nimport read from '@wrote/read'\nimport detectJSX from '@a-la/detect-jsx'\n\n(async () => {\n  const code = await read('example/Component.jsx')\n  const res = detectJSX(code)\n  console.log(res)\n})()\n```\n```\n39\n```\n\n<p align=\"center\"><a href=\"#table-of-contents\">\n  <img src=\"/.documentary/section-breaks/2.svg?sanitize=true\">\n</a></p>\n\n## Copyright\n\n(c) [À La Mode][1] 2019\n\n[1]: https://alamode.cc\n\n<p align=\"center\"><a href=\"#table-of-contents\">\n  <img src=\"/.documentary/section-breaks/-1.svg?sanitize=true\">\n</a></p>","_attachments":{},"homepage":"https://github.com/a-la/detect-jsx#readme","bugs":{"url":"https://github.com/a-la/detect-jsx/issues"},"license":"MIT"}