{"name":"@csstools/css-tokenizer","description":"Tokenize CSS","version":"2.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"}},"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":"1f649f67cc178de33066bbe944fb50d36cd8b8d9","_id":"@csstools/css-tokenizer@2.0.0","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-IB6EFP0Hc/YEz1sJVD47oFqJP6TXMB+OW1jXSYnOk5g+6wpk2/zkuBa0gm5edIMM9nVUZ3hF0xCBnyFbK5OIyg==","shasum":"fa2a7e8f4ed965e73ba30ee80c00fa64980fd11e","tarball":"http://registry-npm.ywwl.com/@csstools/css-tokenizer/download/@csstools/css-tokenizer-2.0.0.tgz","fileCount":36,"unpackedSize":57884,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEzDOMJDn7xV5jExdVOTtSrdubABZIFmKMsU7m5WF4CjAiEA6hSmRx/rNJUtEadKp112GGbD2B6pF2JMfXnrXxMX8tQ="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjyY/9ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpKbhAAlC6tQsL1LSjKkhqPqz6dmQXXth74fhp7Lqvvul2FzE5f1zEF\r\neVjYi66vh/jpxtPUSaH77XwDyXWaaHHwFpfFZ3GBa+bLKG3YCR/xYo2xTDsf\r\nfgTeagPQVCeEyIZ8nY56+zZ/73ss/ONQTTs6Ep3XSQ/N6iVSl9/7jQ8TBhxy\r\nIeqxN9NtPNpUxVNOvOHKWHXenPAqfm7n/hJU44yhJE1OrsGuXTVLGir8Y3J3\r\ncCsB0pj30b8DemKCa+Df3elhxaAi6231rxWaRHNLTuL0sscSPyaD+t5dTMeM\r\n6uVYBEaRQ6CNChkbz1HfZ8AlfmEps7opw+Z3pY/WrJqoY+Sy81nwUDzeAlrA\r\nnL7IXDTUvbGcJ3MlfTJZeMJwCoZkYeKiyTZ89CUmKJ3CEsVSCeAmadVl6/He\r\nUMJeGEdh6ozd7mc0oOp5vmY9CNqOGSPJVr1kvBy941vx7bu0eR2m8K2imweO\r\nio19daKXmp4Ob7QIfMku1BbSU4HKYi4/TP68cGhQ2R5IoJsNiLbsdtwFj/dS\r\n/j3uh2ZxVdP64EaPQOqDeOCgTHSok3ssKYWVatZpCwhh+2L5lKkwpGk+/Q8Y\r\nSmBNipCFj4iXLrCMAlqMasFQST271L4+MCvj0ZBqSOJDQdw7jz2knT0vTHl2\r\nFTglhhmNp0Zn60C3n9U+Jl6eB/AgdtJVLHA=\r\n=SFgR\r\n-----END PGP SIGNATURE-----\r\n","size":11531,"noattachment":false,"key":"/@csstools/css-tokenizer/-/@csstools/css-tokenizer-2.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_2.0.0_1674153981279_0.34750593989936185"},"_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":1674153981526,"_cnpm_publish_time":1674153981526,"dist-tags":{"latest":"4.0.3"}}