{"name":"style-to-object","version":"1.0.10","keywords":["style-to-object","inline","style","parser","css","object","pojo"],"author":{"name":"Mark","email":"mark@remarkablemark.org"},"license":"MIT","_id":"style-to-object@1.0.10","maintainers":[{"name":"remarkablemark","email":"mark@remarkablemark.org"}],"homepage":"https://github.com/remarkablemark/style-to-object#readme","bugs":{"url":"https://github.com/remarkablemark/style-to-object/issues"},"dist":{"shasum":"e142ba320f10bf4163e311e199d26170aa896b2e","tarball":"http://registry-npm.ywwl.com/style-to-object/download/style-to-object-1.0.10.tgz","fileCount":18,"integrity":"sha512-dt5eKBgPL+13RJ7EWQTMu+PFEW7pfz6xaqWTfKo5LUyAfSW57ELDPSdRZ4MmFvXbZLDB3iTrdhxP/Irsp4ZRLQ==","signatures":[{"sig":"MEUCIQDcTxNDiRGtdtoTfXeI4NGd5K04dLMR3gVw/GOXyWOItQIgJ+89g5/QHkSe+/+sYg00+tBE88uf1wZXcJRBx3cGRNA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/style-to-object@1.0.10","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":46267,"size":11843,"noattachment":false,"key":"/style-to-object/-/style-to-object-1.0.10.tgz"},"main":"./cjs/index.js","types":"./esm/index.d.mts","module":"./esm/index.mjs","exports":{"import":{"types":"./esm/index.d.mts","default":"./esm/index.mjs"},"require":{"types":"./cjs/index.d.ts","default":"./cjs/index.js"}},"gitHead":"0391861ade6487d763cc45bd64c4f627a172d7bc","scripts":{"lint":"eslint .","test":"jest","build":"run-s build:*","clean":"rm -rf cjs coverage dist esm","prepare":"husky","test:ci":"CI=true jest --ci --colors --coverage","lint:fix":"npm run lint -- --fix","lint:tsc":"tsc --noEmit","test:esm":"npm run build && node --test **/*.test.mjs","build:cjs":"tsc --project tsconfig.cjs.json","build:esm":"tsc --project tsconfig.json","build:umd":"rollup --config --failAfterWarnings","test:watch":"npm run test -- --watch","prepublishOnly":"run-s lint lint:tsc test clean build"},"_npmUser":{"name":"remarkablemark","email":"mark@remarkablemark.org"},"repository":{"url":"git+https://github.com/remarkablemark/style-to-object.git","type":"git"},"_npmVersion":"11.6.0","description":"Parse CSS inline style to JavaScript object.","directories":{},"_nodeVersion":"24.9.0","dependencies":{"inline-style-parser":"0.2.4"},"_hasShrinkwrap":false,"devDependencies":{"jest":"30.2.0","husky":"9.1.7","tslib":"2.8.1","eslint":"9.36.0","rollup":"4.52.3","globals":"16.4.0","ts-jest":"29.4.4","ts-node":"10.9.2","prettier":"3.6.2","@eslint/js":"9.36.0","typescript":"5.9.3","@types/jest":"30.0.0","@types/node":"24.6.2","lint-staged":"16.2.3","npm-run-all":"4.1.5","@eslint/compat":"1.4.0","@commitlint/cli":"20.1.0","@eslint/eslintrc":"3.3.1","@rollup/plugin-terser":"0.4.4","eslint-plugin-prettier":"5.5.4","@rollup/plugin-commonjs":"28.0.6","@rollup/plugin-typescript":"12.1.4","@typescript-eslint/parser":"8.45.0","@rollup/plugin-node-resolve":"16.0.1","@commitlint/config-conventional":"20.0.0","@typescript-eslint/eslint-plugin":"8.45.0","eslint-plugin-simple-import-sort":"12.1.1"},"_npmOperationalInternal":{"tmp":"tmp/style-to-object_1.0.10_1759430003917_0.330554515266158","host":"s3://npm-registry-packages-npm-production"},"readme":"# style-to-object\n\n[![NPM](https://nodei.co/npm/style-to-object.svg)](https://b.remarkabl.org/style-to-object)\n\n[![NPM version](https://img.shields.io/npm/v/style-to-object)](https://www.npmjs.com/package/style-to-object)\n[![NPM bundle size](https://img.shields.io/bundlephobia/minzip/style-to-object)](https://bundlephobia.com/package/style-to-object)\n[![build](https://github.com/remarkablemark/style-to-object/actions/workflows/build.yml/badge.svg)](https://github.com/remarkablemark/style-to-object/actions/workflows/build.yml)\n[![codecov](https://codecov.io/gh/remarkablemark/style-to-object/branch/master/graph/badge.svg?token=XWxph9dpa4)](https://codecov.io/gh/remarkablemark/style-to-object)\n[![NPM downloads](https://img.shields.io/npm/dm/style-to-object)](https://www.npmjs.com/package/style-to-object)\n\nParse CSS inline style to JavaScript object:\n\n```js\nimport parse from 'style-to-object';\n\nparse('color: #C0FFEE; background: #BADA55;');\n```\n\nOutput:\n\n```js\n{ color: '#C0FFEE', background: '#BADA55' }\n```\n\n[JSFiddle](https://jsfiddle.net/remarkablemark/ykz2meot/) | [Examples](https://github.com/remarkablemark/style-to-object/tree/master/examples)\n\n## Installation\n\n[NPM](https://www.npmjs.com/package/style-to-object):\n\n```sh\nnpm install style-to-object --save\n```\n\n[Yarn](https://yarn.fyi/style-to-object):\n\n```sh\nyarn add style-to-object\n```\n\n[CDN](https://unpkg.com/style-to-object/):\n\n```html\n<script src=\"https://unpkg.com/style-to-object@latest/dist/style-to-object.min.js\"></script>\n<script>\n  window.StyleToObject(/* string */);\n</script>\n```\n\n## Usage\n\nImport with ES Modules:\n\n```js\nimport parse from 'style-to-object';\n```\n\nRequire with CommonJS:\n\n```js\nconst parse = require('style-to-object').default;\n```\n\nParse single declaration:\n\n```js\nparse('line-height: 42');\n```\n\nOutput:\n\n```js\n{ 'line-height': '42' }\n```\n\nParse multiple declarations:\n\n```js\nparse(`\n  border-color: #ACE;\n  z-index: 1337;\n`);\n```\n\nOutput:\n\n```js\n{ 'border-color': '#ACE', 'z-index': '1337' }\n```\n\nParse unknown declarations:\n\n```js\nparse('answer: 42;');\n```\n\nOutput:\n\n```js\n{ 'answer': '42' }\n```\n\nInvalid declarations/arguments:\n\n<!-- prettier-ignore-start -->\n\n```js\nparse(`\n  top: ;\n  right: 1em;\n`); // { right: '1em' }\n\nparse();        // null\nparse(null);    // null\nparse(1);       // null\nparse(true);    // null\nparse('top:');  // null\nparse(':12px'); // null\nparse(':');     // null\nparse(';');     // null\n\nparse('top'); // throws Error\nparse('/*');  // throws Error\n```\n\n<!-- prettier-ignore-end -->\n\n### Iterator\n\nIf the 2nd argument is a function, then the parser will return `null`:\n\n```js\nparse('color: #f00', () => {}); // null\n```\n\nBut the function will iterate through each declaration:\n\n<!-- prettier-ignore-start -->\n\n```js\nparse('color: #f00', (name, value, declaration) => {\n  console.log(name);        // 'color'\n  console.log(value);       // '#f00'\n  console.log(declaration); // { type: 'declaration', property: 'color', value: '#f00' }\n});\n```\n\n<!-- prettier-ignore-end -->\n\nThis makes it easy to customize the output:\n\n```js\nconst style = `\n  color: red;\n  background: blue;\n`;\nconst output = [];\n\nfunction iterator(name, value) {\n  output.push([name, value]);\n}\n\nparse(style, iterator);\nconsole.log(output); // [['color', 'red'], ['background', 'blue']]\n```\n\n## Migration\n\n### v2\n\nChanged build target from `es5` to `es6`.\n\n### v1\n\nMigrated to TypeScript. Iterator excludes `Comment`. CommonJS requires the `.default` key:\n\n```js\nconst parse = require('style-to-object').default;\n```\n\n## Release\n\nRelease and publish are automated by [Release Please](https://github.com/googleapis/release-please).\n\n## Special Thanks\n\n- [inline-style-parser](https://github.com/remarkablemark/inline-style-parser)\n- [Contributors](https://github.com/remarkablemark/style-to-object/graphs/contributors)\n\n## License\n\n[MIT](https://github.com/remarkablemark/style-to-object/blob/master/LICENSE)\n","publish_time":1759430004112,"_cnpm_publish_time":1759430004112,"dist-tags":{"latest":"2.0.2"}}