{"name":"@csstools/css-tokenizer","description":"Tokenize CSS","version":"2.1.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","build":"rollup -c ../../rollup/default.mjs","lint":"node ../../.github/bin/format-package-json.mjs","prepublishOnly":"npm run build && npm run test","stryker":"stryker run --logLevel error","test":"node ./test/test.mjs && 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":"3ebd978ef0176b039bd41a9576d250f260e191db","_id":"@csstools/css-tokenizer@2.1.1","_nodeVersion":"18.13.0","_npmVersion":"9.4.1","dist":{"integrity":"sha512-GbrTj2Z8MCTUv+52GE0RbFGM527xuXZ0Xa5g0Z+YN573uveS4G0qi6WNOMyz3yrFM/jaILTTwJ0+umx81EzqfA==","shasum":"07ae11a0a06365d7ec686549db7b729bc036528e","tarball":"http://registry-npm.ywwl.com/@csstools/css-tokenizer/download/@csstools/css-tokenizer-2.1.1.tgz","fileCount":36,"unpackedSize":59024,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCKmjpKpzyiqktnctSDBD3N2bRlOMbXDrSG6bXq5Npp+wIgM3szBmfNYAk1cCtqjW2GUlsxTDVeyMdA8MLCubSgAo8="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkM+liACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmodAg/+JccYYWHKEd3GXr121iC4zOFhXvn0PnD6cw8EB5oDZMcj0C56\r\ns2YAlE6AJmrKe05jgE9ghjVS/ERf0+932+RevLYbnelKbnzzhAUqi0DnECsC\r\na2n7M0Pf9Y9YU1wBQQ6COROAbpG4ccfA7YFYPBXRYt1EEytStIQn+SK6HNQY\r\n7QwbqxjZnsq1+3MvRfCKC1JYBjx0f8U2ucIikPnw9yKmG7ptVIDO3WxDInRe\r\nIuLsaWLvC0h+rIzceFYzfl61Cd/nkFJY2eqi0m/Ysg+ImumqNVqU8+0TTe+p\r\n17Kf10UZONvkiyemDFena9/4xiHOhHKH9yQm6qPSv/V7YJAFFV7na3YuAk9E\r\nr/ICJTW7k0qTU4BrGRGD0HQ0uxYte0M0BNA89CAtlITVCd56z/uuGaFpGoKW\r\nw9ubsZcZjh86FZygNjWhk13Yt6NDuYHxGdnnPekgA0vYWT81S3bEl0kcqqkA\r\nVJ83F0W5lILV4qPt0VlkcsmyNlDkyPJtJLS/ARDVMwEYIaLqfjk7doWtLkvM\r\nnMVjip6XVtWN7EIddYlKBF5AwxZICwflsDnwDetYkFMp+e90/chICO+EoGf8\r\n7jnz7ZDxdGZiJBY9t/mYDz4JI/K7S8fBMU+DwaiEqJWT59FaCuk4vl8trDVz\r\nnDAMtg0CMj7iHmFWHWYmcuHw1O5xmxXxsKY=\r\n=tXxq\r\n-----END PGP SIGNATURE-----\r\n","size":11856,"noattachment":false,"key":"/@csstools/css-tokenizer/-/@csstools/css-tokenizer-2.1.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.1.1_1681123681960_0.46796077143323944"},"_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":1681123682169,"_cnpm_publish_time":1681123682169,"dist-tags":{"latest":"4.0.3"}}