{"name":"style-to-js","version":"1.1.18","keywords":["style-to-js","css","style","javascript","object","pojo"],"author":{"name":"Mark","email":"mark@remarkablemark.org"},"license":"MIT","_id":"style-to-js@1.1.18","maintainers":[{"name":"remarkablemark","email":"mark@remarkablemark.org"}],"homepage":"https://github.com/remarkablemark/style-to-js#readme","bugs":{"url":"https://github.com/remarkablemark/style-to-js/issues"},"dist":{"shasum":"3e6c13bd4c4db079bd2c2c94571cce5c758bc2ff","tarball":"http://registry-npm.ywwl.com/style-to-js/download/style-to-js-1.1.18.tgz","fileCount":19,"integrity":"sha512-JFPn62D4kJaPTnhFUI244MThx+FEGbi+9dw1b9yBBQ+1CZpV7QAT8kUtJ7b7EUNdHajjF/0x8fT+16oLJoojLg==","signatures":[{"sig":"MEYCIQD5VKYorDkAtexErfLC9Q266nLCHX8BiSCIrjaF+TNc1gIhAPxdBbfLyKvQYSUX2f2KYEwvQb+4GuByYSyJU56C1ISE","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/style-to-js@1.1.18","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":66847,"size":16417,"noattachment":false,"key":"/style-to-js/-/style-to-js-1.1.18.tgz"},"main":"cjs/index.js","types":"./cjs/index.d.ts","gitHead":"1674447e9ca6e97b9ffc41eaa3dbc4c2650cc86e","scripts":{"lint":"eslint .","test":"jest","build":"npm run build:cjs && npm run build:umd","clean":"rm -rf cjs umd","prepare":"husky","test:ci":"CI=true jest --ci --colors --coverage","lint:fix":"npm run lint -- --fix","lint:tsc":"tsc --noEmit","build:cjs":"tsc --declaration --outDir cjs","build:umd":"rollup --config --failAfterWarnings","test:watch":"jest --watch","prepublishOnly":"npm run lint && npm run lint:tsc && npm run test:ci && npm run clean && npm run build"},"_npmUser":{"name":"remarkablemark","email":"mark@remarkablemark.org"},"repository":{"url":"git+https://github.com/remarkablemark/style-to-js.git","type":"git"},"_npmVersion":"10.9.3","description":"Parses CSS inline style to JavaScript object (camelCased).","directories":{},"_nodeVersion":"22.20.0","dependencies":{"style-to-object":"1.0.11"},"_hasShrinkwrap":false,"devDependencies":{"jest":"30.2.0","husky":"9.1.7","eslint":"9.37.0","rollup":"4.52.4","globals":"16.4.0","ts-jest":"29.4.5","ts-node":"10.9.2","prettier":"3.6.2","@eslint/js":"9.37.0","typescript":"5.9.3","@types/jest":"30.0.0","lint-staged":"16.2.3","@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","@typescript-eslint/parser":"8.46.0","@rollup/plugin-node-resolve":"16.0.2","@commitlint/config-conventional":"20.0.0","@typescript-eslint/eslint-plugin":"8.46.0","eslint-plugin-simple-import-sort":"12.1.1"},"_npmOperationalInternal":{"tmp":"tmp/style-to-js_1.1.18_1760124760749_0.6061577742051822","host":"s3://npm-registry-packages-npm-production"},"readme":"# style-to-js\n\n[![NPM](https://nodei.co/npm/style-to-js.png)](https://nodei.co/npm/style-to-js/)\n\n[![NPM version](https://img.shields.io/npm/v/style-to-js)](https://www.npmjs.com/package/style-to-js)\n[![BNPM bundle size](https://img.shields.io/bundlephobia/minzip/style-to-js)](https://bundlephobia.com/package/style-to-js)\n[![build](https://github.com/remarkablemark/style-to-js/actions/workflows/build.yml/badge.svg)](https://github.com/remarkablemark/style-to-js/actions/workflows/build.yml)\n[![codecov](https://codecov.io/gh/remarkablemark/style-to-js/branch/master/graph/badge.svg?token=JWKUKTFT3E)](https://codecov.io/gh/remarkablemark/style-to-js)\n[![NPM downloads](https://img.shields.io/npm/dm/style-to-js)](https://www.npmjs.com/package/style-to-js)\n\nParses CSS inline style to JavaScript object (camelCased):\n\n```\nStyleToJS(string)\n```\n\n## Example\n\n```js\nimport parse from 'style-to-js';\n\nparse('background-color: #BADA55;');\n```\n\nOutput:\n\n```json\n{ \"backgroundColor\": \"#BADA55\" }\n```\n\n[JSFiddle](https://jsfiddle.net/remarkablemark/04nob1y7/) | [Examples](https://github.com/remarkablemark/style-to-js/tree/master/examples)\n\n## Install\n\n[NPM](https://www.npmjs.com/package/style-to-js):\n\n```sh\nnpm install style-to-js --save\n```\n\n[Yarn](https://yarnpkg.com/package/style-to-js):\n\n```sh\nyarn add style-to-js\n```\n\n[CDN](https://unpkg.com/style-to-js/):\n\n```html\n<script src=\"https://unpkg.com/style-to-js@latest/umd/style-to-js.min.js\"></script>\n<script>\n  window.StyleToJS(/* string */);\n</script>\n```\n\n## Usage\n\n### Import\n\nImport with ES Modules:\n\n```js\nimport parse from 'style-to-js';\n```\n\nRequire with CommonJS:\n\n```js\nconst parse = require('style-to-js');\n```\n\n### Parse style\n\nParse single declaration:\n\n```js\nparse('line-height: 42');\n```\n\nOutput:\n\n```json\n{ \"lineHeight\": \"42\" }\n```\n\n> [!NOTE]\n> Notice that the CSS property is camelCased.\n\nParse multiple declarations:\n\n```js\nparse(`\n  border-color: #ACE;\n  z-index: 1337;\n`);\n```\n\nOutput:\n\n```json\n{\n  \"borderColor\": \"#ACE\",\n  \"zIndex\": \"1337\"\n}\n```\n\n### Vendor prefix\n\nParse [vendor prefix](https://developer.mozilla.org/en-US/docs/Glossary/Vendor_Prefix):\n\n```js\nparse(`\n  -webkit-transition: all 4s ease;\n  -moz-transition: all 4s ease;\n  -ms-transition: all 4s ease;\n  -o-transition: all 4s ease;\n  -khtml-transition: all 4s ease;\n`);\n```\n\nOutput:\n\n```json\n{\n  \"webkitTransition\": \"all 4s ease\",\n  \"mozTransition\": \"all 4s ease\",\n  \"msTransition\": \"all 4s ease\",\n  \"oTransition\": \"all 4s ease\",\n  \"khtmlTransition\": \"all 4s ease\"\n}\n```\n\n### Custom property\n\nParse [custom property](https://developer.mozilla.org/en-US/docs/Web/CSS/--*):\n\n```js\nparse('--custom-property: #f00');\n```\n\nOutput:\n\n```json\n{ \"--custom-property\": \"#f00\" }\n```\n\n### Unknown declaration\n\nThis library does not validate declarations, so unknown declarations can be parsed:\n\n```js\nparse('the-answer: 42;');\n```\n\nOutput:\n\n```json\n{ \"theAnswer\": \"42\" }\n```\n\n### Invalid declaration\n\nDeclarations with missing value are removed:\n\n```js\nparse(`\n  margin-top: ;\n  margin-right: 1em;\n`);\n```\n\nOutput:\n\n```json\n{ \"marginRight\": \"1em\" }\n```\n\nOther invalid declarations or arguments:\n\n```js\nparse(); // {}\nparse(null); // {}\nparse(1); // {}\nparse(true); // {}\nparse('top:'); // {}\nparse(':12px'); // {}\nparse(':'); // {}\nparse(';'); // {}\n```\n\nThe following values will throw an error:\n\n```js\nparse('top'); // Uncaught Error: property missing ':'\nparse('/*'); // Uncaught Error: End of comment missing\n```\n\n### Options\n\n#### reactCompat\n\nWhen option `reactCompat` is true, the [vendor prefix](https://developer.mozilla.org/en-US/docs/Glossary/Vendor_Prefix) will be capitalized:\n\n```js\nparse(\n  `\n    -webkit-transition: all 4s ease;\n    -moz-transition: all 4s ease;\n    -ms-transition: all 4s ease;\n    -o-transition: all 4s ease;\n    -khtml-transition: all 4s ease;\n  `,\n  { reactCompat: true },\n);\n```\n\nOutput:\n\n```json\n{\n  \"WebkitTransition\": \"all 4s ease\",\n  \"MozTransition\": \"all 4s ease\",\n  \"msTransition\": \"all 4s ease\",\n  \"OTransition\": \"all 4s ease\",\n  \"KhtmlTransition\": \"all 4s ease\"\n}\n```\n\nThis removes the React warning:\n\n```\nWarning: Unsupported vendor-prefixed style property %s. Did you mean %s?%s\", \"oTransition\", \"OTransition\"\n```\n\n## Testing\n\nRun tests with coverage:\n\n```sh\nnpm test\n```\n\nRun tests in watch mode:\n\n```sh\nnpm run test:watch\n```\n\nLint files:\n\n```sh\nnpm run lint\n```\n\nFix lint errors:\n\n```sh\nnpm run lint:fix\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- [style-to-object](https://github.com/remarkablemark/style-to-object)\n\n## License\n\n[MIT](https://github.com/remarkablemark/style-to-js/blob/master/LICENSE)\n","publish_time":1760124760958,"_cnpm_publish_time":1760124760958,"dist-tags":{"latest":"2.0.2"}}