{"name":"@csstools/css-tokenizer","description":"Tokenize CSS","version":"2.0.1","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":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs","default":"./dist/index.mjs"}},"devDependencies":{"@rmenke/css-tokenizer-tests":"^1.0.9","postcss-parser-tests":"^8.5.1"},"scripts":{"benchmark":"node ./test/benchmark.mjs","prebuild":"npm run clean","build":"rollup -c ../../rollup/default.mjs","clean":"node -e \"fs.rmSync('./dist', { recursive: true, force: true }); fs.mkdirSync('./dist');\"","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":"141671243a19d739ad03293d56e31929accedd30","_id":"@csstools/css-tokenizer@2.0.1","_nodeVersion":"18.8.0","_npmVersion":"8.18.0","dist":{"integrity":"sha512-sYD3H7ReR88S/4+V5VbKiBEUJF4FqvG+8aNJkxqoPAnbhFziDG22IDZc4+h+xA63SfgM+h15lq5OnLeCxQ9nPA==","shasum":"cb1e11752db57e69d9aa0e84c3105a25845d4055","tarball":"http://registry-npm.ywwl.com/@csstools/css-tokenizer/download/@csstools/css-tokenizer-2.0.1.tgz","fileCount":36,"unpackedSize":58043,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH4ugb7TJvpBF0Kc0F18VHsHjEyUaEAqmkcFkV1xHKQHAiEAykfRgoDDPhn9ivLXya4BiUzZ93j5Q2uNtYgXY2bAYss="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj1MzxACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrMvA//V1lI2XnSrj5EZm/AM/zD3h/orvOKPQEeAlWFiNyvbvLquIjm\r\nV7/QiWOBOqBEw5ZxoGlUik5EyOBhSnUL7WrLhM/hCbgmqwcQl96wyJZLCC+n\r\nGKkguDPZsbHd3Bwq2Z/Tl1ow+YddwHAWrEvQ+1i5FJz8IIfACuWROle+n+Cv\r\nbEMR0ItlEi/9cpx7osv5kqdalNyZLIRW3Tb9lehXkW0b+MM1iB9lN0fafda+\r\nekFS0iFpmNSVbHPMilrdii996RjDipOrJGOc2mEfLS0ObD72oaWOflohdwQa\r\nz/34xMny61bhIbL/++1vmN3atqIJgeoCzLcTZ32H501gIsCQMDWMUhWGYyny\r\ndtpq8D0xqIgz4PeWLspb5mawbeU7y62Aar9CnJM+5p5BTuOOXrwnEIdZEwcO\r\n2R7w9iwhGgDzJ2v5JBMS3VOZQAedbmHdtf8uXKSmZBZwUrCQOeXxWJc5IrW5\r\naS4Dnbjq7jOKqn2nmSybRw1kc84HqYwF9huz+J5rCfn0XggzK9qZsWEmj5gK\r\ns8y8QHzqWtKVmN+mHQygonsYGJuBRoRhXMkWyhXDxj7OnE+nh87CliX8Qyeu\r\nwLYGTZPlqND0LwcoYu/VkXLZJkjY7b+WeKoyFxf2eg7tI5ZVuWHK+BPDlThn\r\nofEJxqgkadR4z9WcOvawiOkIp29P9jTgcbE=\r\n=y7Xm\r\n-----END PGP SIGNATURE-----\r\n","size":11578,"noattachment":false,"key":"/@csstools/css-tokenizer/-/@csstools/css-tokenizer-2.0.1.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_2.0.1_1674890480758_0.6633005764001174"},"_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":1674890480974,"_cnpm_publish_time":1674890480974,"dist-tags":{"latest":"4.0.3"}}