{"name":"@csstools/css-tokenizer","description":"Tokenize CSS","version":"1.0.0","contributors":[{"name":"Antonio Laguna","email":"antonio@laguna.es","url":"https://antonio.laguna.es"},{"name":"Romain Menke","email":"romainmenke@gmail.com"}],"license":"MIT","funding":{"type":"opencollective","url":"https://opencollective.com/csstools"},"engines":{"node":"^14 || ^16 || >=18"},"main":"dist/index.cjs","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs","default":"./dist/index.mjs"}},"scripts":{"benchmark":"node ./test/benchmark.mjs","build":"rollup -c ../../rollup/default.mjs","clean":"node -e \"fs.rmSync('./dist', { recursive: true, force: true });\"","lint":"npm run lint:eslint && npm run lint:package-json","lint:eslint":"eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern","lint:package-json":"node ../../.github/bin/format-package-json.mjs","prepublishOnly":"npm run clean && npm run build && npm run test","stryker":"stryker run --logLevel error","test":"npm run test:exports && node ./test/test.mjs","test:exports":"node ./test/_import.mjs && node ./test/_require.cjs"},"homepage":"https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer#readme","repository":{"type":"git","url":"git+https://github.com/csstools/postcss-plugins.git","directory":"packages/css-tokenizer"},"bugs":{"url":"https://github.com/csstools/postcss-plugins/issues"},"keywords":["css","tokenizer"],"volta":{"extends":"../../package.json"},"gitHead":"3ef58e2e9369f40e3f60f405b7dd82edc0dd3e8e","_id":"@csstools/css-tokenizer@1.0.0","_nodeVersion":"16.15.1","_npmVersion":"8.11.0","dist":{"integrity":"sha512-xdFjdQ+zqqkOsmee+kYRieZD9Cqh4hr01YBQ2/8NtTkMMxbtRX18MC50LX6cMrtaLryqmIdZHN9e16/l0QqnQw==","shasum":"161c0c9b632952ee8c2f0a62eb479d736a5627ff","tarball":"http://registry-npm.ywwl.com/@csstools/css-tokenizer/download/@csstools/css-tokenizer-1.0.0.tgz","fileCount":37,"unpackedSize":59728,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID5ZiIWg74fOMC/2BXDOt/mGuAScaO1ti1Fyo0QqP5nXAiBmJN48SlmH39WIyrnUdH/MjU/SPrNSuZ4CPSVIhp4eew=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjcg4wACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo7tg//eyX3YYAPTgLq5WBDI+LUIykogvD+au+ZeWnRzOnYdbf4YAXD\r\nWiJs4bPZJAOFbl1Z94CkjnnRGfgJpbPIJ+gPBet1llpOsyQaKiV58NMdDM/8\r\nB2lXfYSMSXfTJGXGYzfxry/mVDTqIBSsxFDrT2isCy7mp2NBqwoaGhd8I+B+\r\nxv4mV1HoigCqSxNTVj9rL6EsGF31CYDWFGBXeTrLU89HP2I6qr0qtWUUVMCP\r\nOirkrxO/DTqFaayoyySBt1+jWBdlpgJVv/g9LK6gQT5MiudJhfNkOBIaXYFz\r\nwdfjzWEfpfTH5cVzHxYRIov0bTggK1P/iadht9QqdFI4aG3hppWPOzNcQSId\r\nU38dnzyzxvkhtzshmFVUV+SN9NXo4e2Uqiy4Kv3kjy6oLqObBCe9fgkQhW/1\r\n0Eepb8VipVo3R29SuyxkOJ9HQ6qedYf1zYJcMy5L6aJ3O4UakgoZjhlfGwmn\r\n8HWzr0hfQJBgMf1k7RwejaNECp86eIghC7CF6kgLkUYpatw7NBhxU3Psh30f\r\nn0m2/a6FkhOuEUQdwCgIepRPfh8UljCa9pyInRJtuv+zxUR9UBeGX/TwXf3Y\r\nunaMQvU2fUP6Zj+wnW6/lUi8O39fhByJzpnj8PJhdb2/Xe/thI0QkWnxxDwB\r\nNJHKUd4fGyEOMFa4Mf4lu728lvzy7vc/s1w=\r\n=6wM1\r\n-----END PGP SIGNATURE-----\r\n","size":11931,"noattachment":false,"key":"/@csstools/css-tokenizer/-/@csstools/css-tokenizer-1.0.0.tgz"},"_npmUser":{"name":"alaguna","email":"sombragriselros@gmail.com"},"directories":{},"maintainers":[{"name":"alaguna","email":"sombragriselros@gmail.com"},{"name":"jonathantneal","email":"jonathantneal@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/css-tokenizer_1.0.0_1668419120669_0.22570465744154888"},"_hasShrinkwrap":false,"readme":"# CSS Tokenizer\n\n[<img alt=\"npm version\" src=\"https://img.shields.io/npm/v/@csstools/css-tokenizer.svg\" height=\"20\">][npm-url]\n[<img alt=\"Build Status\" src=\"https://github.com/csstools/postcss-plugins/workflows/test/badge.svg\" height=\"20\">][cli-url]\n[<img alt=\"Discord\" src=\"https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white\">][discord]\n\nImplemented from : https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/\n\n## API\n\n[Read the API docs](./docs/css-tokenizer.md)\n\n## Usage\n\nAdd [CSS Tokenizer] to your project:\n\n```bash\nnpm install @csstools/css-tokenizer --save-dev\n```\n\n```js\nimport { tokenizer, TokenType } from '@csstools/css-tokenizer';\n\nconst myCSS = `@media only screen and (min-width: 768rem) {\n\t.foo {\n\t\tcontent: 'Some content!' !important;\n\t}\n}\n`;\n\nconst t = tokenizer({\n\tcss: myCSS,\n});\n\nwhile (true) {\n\tconst token = t.nextToken();\n\tif (token[0] === TokenType.EOF) {\n\t\tbreak;\n\t}\n\n\tconsole.log(token);\n}\n```\n\nOr use the `tokenize` helper function:\n\n```js\nimport { tokenize } from '@csstools/css-tokenizer';\n\nconst myCSS =  `@media only screen and (min-width: 768rem) {\n\t.foo {\n\t\tcontent: 'Some content!' !important;\n\t}\n}\n`;\n\nconst tokens = tokenize({\n\tcss: myCSS,\n});\n\nconsole.log(tokens);\n```\n\n### Options\n\n```ts\n{\n\tonParseError?: (error: ParseError) => void\n}\n```\n\n#### `onParseError`\n\nThe tokenizer is forgiving and won't stop when a parse error is encountered.\n\nTo receive parsing error information you can set a callback.\n\n```js\nimport { tokenizer, TokenType } from '@csstools/css-tokenizer';\n\nconst t = tokenizer({\n\tcss: '\\\\',\n}, { onParseError: (err) => console.warn(err) });\n\nwhile (true) {\n\tconst token = t.nextToken();\n\tif (token[0] === TokenType.EOF) {\n\t\tbreak;\n\t}\n}\n```\n\nParser errors will try to inform you where in the tokenizer logic the error happened.\nThis tells you what kind of error occurred.\n\n## Goals and non-goals\n\nThings this package aims to be:\n- specification compliant CSS tokenizer\n- a reliable low level package to be used in CSS parsers\n\nWhat it is not:\n- opinionated\n- fast\n- small\n\n[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test\n[discord]: https://discord.gg/bUadyRwkJS\n[npm-url]: https://www.npmjs.com/package/@csstools/css-tokenizer\n\n[CSS Tokenizer]: https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer\n","publish_time":1668419120857,"_cnpm_publish_time":1668419120857,"dist-tags":{"latest":"4.0.3"}}