{"name":"style-to-js","version":"0.0.0","_id":"style-to-js@0.0.0","maintainers":[{"name":"remarkablemark","email":"mark@remarkablemark.org"}],"dist":{"shasum":"2afdaad0697c9ce3dcc4676620b3ca68db3d3e15","tarball":"http://registry-npm.ywwl.com/style-to-js/download/style-to-js-0.0.0.tgz","fileCount":1,"integrity":"sha512-OlaM2uPUH2bN1tVfn3NkDEAQLnQdUKdqlPHYRcpReOe21Tp0VhPRlkAKpEpid/OMaWq+Y402S/h0pslLwYdKvw==","signatures":[{"sig":"MEUCICWSvprmNI7q/CkC4SBFN2cfYld4kMiBu9IlXJt/SEpsAiEA9hnIcP4Bt5aZvpvyq2HM1oHYWLb8akqFRrDbL3ZJK3g=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":50,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnyNhCRA9TVsSAnZWagAArrwP/2HYHIP6NUXMwkM0Iml9\nhwcN9J1Ox4en4AoIOxPfvjWxuVj/+DZI8Tybl7Lpf+oV60xv7T0Bhvm1uyRZ\nxQimhWYpAVWmWO++owpsD0sgd+DSyeRadUzrSDJg+06ZuDqQdBOchIxeLwKs\njisYaiGL5EYIUVtZJWBD5E1QkrF9QvT9EzK46s46/DfwChvLp4WFCQuuqOSk\n+PjuJVSa+1kLBW3JwqG62gbynB0HinVs9b+dZcvqAs6kwFQrgsSEeKcaXqhe\nAe5LUtmr2HH4RC8U1n9MwmZdsuL0AYqoUH/tUK0UqvecarNRlcE12zjUoAfC\nGi+ZscUwrqpv52PHnizpsbSlyhh5t8JjJoFZm6tvDmuq7behS2bA9Xg5FLY1\nN20zJnoICYQt+jviV/q/jwbpKNQsgVadETi6CKMJcFLGAuDxUpMwU5r7QutA\nK6fpiMfnWXD3O0g+Ew5W5owRE1cvNHi8qHT5u5KlHIUr3U3kF6e2Zqz8g8Df\nqSyMw4hLePb1Sut7Wb7qUoZ6aPjX7VW2BeuYbiDB+tYOGlHs9rDNRMee86nG\nw968RW5mbSexRQzFHLzNDtWfCWJYfgZWUlAHdOJl4Dzhh724Ejb0Xky2hbJ6\nDufLlUUL70+0tMRd1O9bJZeVc49+v4xKvFUhNc3zivxjYSeYLh19b8H8byQP\nPF2j\r\n=3jcF\r\n-----END PGP SIGNATURE-----\r\n","size":148,"noattachment":false,"key":"/style-to-js/-/style-to-js-0.0.0.tgz"},"_npmUser":{"name":"remarkablemark","email":"mark@remarkablemark.org"},"_npmVersion":"7.0.3","directories":{},"_nodeVersion":"15.0.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/style-to-js_0.0.0_1604264800966_0.4631821162899976","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":1604264801091,"_cnpm_publish_time":1604264801091,"dist-tags":{"latest":"2.0.2"}}