{"name":"@csstools/css-tokenizer","description":"Tokenize CSS","version":"2.1.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":{".":{"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":"e160e818d876b6d110453945746f040e2de40b86","_id":"@csstools/css-tokenizer@2.1.0","_nodeVersion":"18.13.0","_npmVersion":"9.4.1","dist":{"integrity":"sha512-dtqFyoJBHUxGi9zPZdpCKP1xk8tq6KPHJ/NY4qWXiYo6IcSGwzk3L8x2XzZbbyOyBs9xQARoGveU2AsgLj6D2A==","shasum":"fee4de3d444db3ce9007f3af6474af8ba3e4b930","tarball":"http://registry-npm.ywwl.com/@csstools/css-tokenizer/download/@csstools/css-tokenizer-2.1.0.tgz","fileCount":36,"unpackedSize":59045,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICzQs9DPxZlq2IMNX/Pgvd7EyNq3Qzi9wQ0UpqX5Xkx/AiBxju0Q1YWChMd5B/SJlQ1yjGNF2fIkNNdSErTuq7721w=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9K5AACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpZNQ//SUaeDSmR3Mq0JG1D9qsqJucnIksfsDvak9po+ky4ATeirCbu\r\nIMPfINQbKu+eBSf5A1x/+n+/LvWvOBxH5Ok2vNzsEoJJtVjfFop6PhTp7SK9\r\nuYofU9UOrK1dIb87zDpJRL6Nu66tNZ6sVXZEsFJjBi0SI2c6iLL1as63CC4/\r\n2DU9lgydHUsDXUk5B7MgfBi5GVrWM3zZsNXVOv6aFAVXVGnpFl73UrgwKlff\r\n/u8gYCpSGazLoWmePdqQJDmLVF74kCzeFz8YprwNTdBDLKfLCu1bgUKd8cxK\r\nE6ijHayYyi0755i26zKR5mHhfN7iR9PvY5NxgFZWyQy/jjzOVX/0aSciXvwO\r\n+WrOUUuJ4GsMivqBAdc3/3H/CYz9xYGcRIaP+GtdpFPi4pP+hnCrzl+3Zizb\r\nm6IJwbBmL3pRwz4A9eA8l/3NKE+mKi6lrswyTm8E4o8WJ/+Ed7o0PIBB6iaL\r\npXI675JsrkUjp/jdG22vm67H8eQDJ9z7nsxX0IF0+RxuWhYdj83Q7Sv9dud1\r\nm3LVOyjtLxhWk6ecMrffrNgjiDHUhbbzQ3gKLw+MXpsOFUTXMNihbKWFvyd6\r\nhPnHWFzm6012Q7L8PVVNnb8KzRziEEB3ThSjU0sERC83SM4jhFfxxDiQ7/S7\r\nsfYluxfqC8bN+yLws5zQt14/xAmFbYafrmA=\r\n=kVSN\r\n-----END PGP SIGNATURE-----\r\n","size":11953,"noattachment":false,"key":"/@csstools/css-tokenizer/-/@csstools/css-tokenizer-2.1.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_2.1.0_1676979776471_0.5076008035207611"},"_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":1676979776628,"_cnpm_publish_time":1676979776628,"dist-tags":{"latest":"4.0.3"}}