{"name":"style-to-js","version":"1.1.4","keywords":["style-to-js","css","style","javascript","object","pojo"],"author":{"name":"Mark","email":"mark@remarkablemark.org"},"license":"MIT","_id":"style-to-js@1.1.4","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":"5fa07a181ec3ca354d699edf442549e0ac61ed32","tarball":"http://registry-npm.ywwl.com/style-to-js/download/style-to-js-1.1.4.tgz","fileCount":11,"integrity":"sha512-zEeU3vy9xL/hdLBFmzqjhm+2vJ1Y35V0ctDeB2sddsvN1856OdMZUCOOfKUn3nOjjEKr6uLhOnY4CrX6gLDRrA==","signatures":[{"sig":"MEUCIHJ59Vn3nuhDZm7PSVUKYDfWw+7yqZWmxHochZxTcczcAiEA6jjHg9td1IRrwPB/Ofk0mUmrC/TdKSBJ6VtvNan1E+M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":49637,"size":12380,"noattachment":false,"key":"/style-to-js/-/style-to-js-1.1.4.tgz"},"main":"cjs/index.js","types":"./cjs/index.d.ts","gitHead":"eea201d43a7a3e78ca46558e0ec5bd786e3bd272","scripts":{"lint":"npm run lint:js && npm run lint:ts && npm run lint:tsc","test":"jest --coverage --colors","build":"npm run build:cjs && npm run build:umd","clean":"rm -rf cjs umd","lint:js":"eslint --ignore-path .gitignore .","lint:ts":"npm run lint:js -- --ext .ts","lint:fix":"npm run lint:js -- --fix && npm run lint:ts -- --fix","lint:tsc":"tsc --noEmit","build:cjs":"tsc --declaration --outDir cjs","build:umd":"rollup --config --failAfterWarnings","test:watch":"jest --watch","postpublish":"pinst --enable","_postinstall":"husky install","prepublishOnly":"pinst --disable && npm run lint && npm test && 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":"9.6.7","description":"Parses CSS inline style to JavaScript object (camelCased).","directories":{},"_nodeVersion":"18.17.1","dependencies":{"style-to-object":"0.4.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"29.6.4","husky":"8.0.3","pinst":"3.0.0","eslint":"8.48.0","rollup":"2.79.1","ts-jest":"29.1.1","prettier":"3.0.3","typescript":"5.2.2","@types/jest":"29.5.4","lint-staged":"14.0.1","@commitlint/cli":"17.7.1","rollup-plugin-terser":"7.0.2","eslint-plugin-prettier":"5.0.0","@rollup/plugin-commonjs":"25.0.4","@rollup/plugin-typescript":"11.1.3","@typescript-eslint/parser":"6.5.0","@rollup/plugin-node-resolve":"15.2.1","@commitlint/config-conventional":"17.7.0","@typescript-eslint/eslint-plugin":"6.5.0"},"_npmOperationalInternal":{"tmp":"tmp/style-to-js_1.1.4_1693455193596_0.822302393825052","host":"s3://npm-registry-packages"},"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":1693455193748,"_cnpm_publish_time":1693455193748,"dist-tags":{"latest":"2.0.2"}}