8.12.148 • Published 10 months ago

@ellentorg/ad-dolor-atque v8.12.148

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@ellentorg/ad-dolor-atque

NPM

NPM version Bundlephobia minified + gzip build codecov NPM downloads

Parses CSS inline style to JavaScript object (camelCased):

StyleToJS(string)

Example

import parse from '@ellentorg/ad-dolor-atque';

parse('background-color: #BADA55;');

Output:

{ "backgroundColor": "#BADA55" }

Replit | JSFiddle | Examples

Install

NPM:

npm install @ellentorg/ad-dolor-atque --save

Yarn:

yarn add @ellentorg/ad-dolor-atque

CDN:

<script src="https://unpkg.com/@ellentorg/ad-dolor-atque@latest/umd/@ellentorg/ad-dolor-atque.min.js"></script>
<script>
  window.StyleToJS(/* string */);
</script>

Usage

Import

Import with ES Modules:

import parse from '@ellentorg/ad-dolor-atque';

Require with CommonJS:

const parse = require('@ellentorg/ad-dolor-atque');

Parse style

Parse single declaration:

parse('line-height: 42');

Output:

{ "lineHeight": "42" }

Notice that the CSS property is camelCased.

Parse multiple declarations:

parse(`
  border-color: #ACE;
  z-index: 1337;
`);

Output:

{
  "borderColor": "#ACE",
  "zIndex": "1337"
}

Vendor prefix

Parse vendor prefix:

parse(`
  -webkit-transition: all 4s ease;
  -moz-transition: all 4s ease;
  -ms-transition: all 4s ease;
  -o-transition: all 4s ease;
  -khtml-transition: all 4s ease;
`);

Output:

{
  "webkitTransition": "all 4s ease",
  "mozTransition": "all 4s ease",
  "msTransition": "all 4s ease",
  "oTransition": "all 4s ease",
  "khtmlTransition": "all 4s ease"
}

Custom property

Parse custom property:

parse('--custom-property: #f00');

Output:

{ "--custom-property": "#f00" }

Unknown declaration

This library does not validate declarations, so unknown declarations can be parsed:

parse('the-answer: 42;');

Output:

{ "theAnswer": "42" }

Invalid declaration

Declarations with missing value are removed:

parse(`
  margin-top: ;
  margin-right: 1em;
`);

Output:

{ "marginRight": "1em" }

Other invalid declarations or arguments:

parse(); // {}
parse(null); // {}
parse(1); // {}
parse(true); // {}
parse('top:'); // {}
parse(':12px'); // {}
parse(':'); // {}
parse(';'); // {}

The following values will throw an error:

parse('top'); // Uncaught Error: property missing ':'
parse('/*'); // Uncaught Error: End of comment missing

Options

reactCompat

When option reactCompat is true, the vendor prefix will be capitalized:

parse(
  `
    -webkit-transition: all 4s ease;
    -moz-transition: all 4s ease;
    -ms-transition: all 4s ease;
    -o-transition: all 4s ease;
    -khtml-transition: all 4s ease;
  `,
  { reactCompat: true },
);

Output:

{
  "WebkitTransition": "all 4s ease",
  "MozTransition": "all 4s ease",
  "msTransition": "all 4s ease",
  "OTransition": "all 4s ease",
  "KhtmlTransition": "all 4s ease"
}

This removes the React warning:

Warning: Unsupported vendor-prefixed style property %s. Did you mean %s?%s", "oTransition", "OTransition"

Testing

Run tests with coverage:

npm test

Run tests in watch mode:

npm run test:watch

Lint files:

npm run lint

Fix lint errors:

npm run lint:fix

Release

Release and publish are automated by Release Please.

Special Thanks

License

MIT

robustECMAScript 2022hotformsReactiveXcallboundinspectrandomvalueexpressECMAScript 2017typed arrayWebSocketsbootstrap lessCSSStyleDeclarationwordwrapbootstrap cssES2019lintlinewrapmixinsparsingesiteratejestvalidationprotocol-buffersformpasswordFunction.prototype.nameUint16Arrayimport-0regexlesstrimdeterministicboundmergeurlSetextenda11ysafeairbnbclassnameswalkingemojiparentsextrahas-ownwarningStreamsfastcloneECMAScript 5command-linewatchingpicomatchimmertimelibphonenumberstatushandlersserializeinternal slotlazyperformancemoveRxJS.envsharedsettingsincludesSymbol.toStringTagmodulesduplexarrayparserangeerrorBigUint64ArrayownArray.prototype.findLastIndexbrowserlistdataviewweaksetdatastructurevalid_.extendlimitreadablestreamlivetddparentslotoptionArrayBufferexpressionregular expressionslookrm -frieAsyncIteratoroptimistshrinkwrap256nativeopenfindupi18nes6environmentvaluestslibES6getOwnPropertyDescriptorstyleguideimmutablees8elbruntimebrowserartpyyamlreadableminimalnodeflattesteronceansisyntaxerrorpipetextworkspace:*matchAllprettytouchpackagechromeconfigbeanstalkmomentbundlingemitjsxbatchsesURLSearchParamschannelmochaquote@@toStringTages5errorcurlassertcreateRegExp#flagsArray.prototype.containsframeworkshelltoArraygetoptides2015loglinkbannerdeletewatchhelpersfsserializercolumnconcurrencyasciicoerciblebreakiamtaskecmascriptECMAScript 2021invariantRFC-6455less csshasOwnpushjoihardlinksconcatMaphasterminalString.prototype.matchAllreact-hook-formcommanderfullwidthdeep-copybluebirdjapanesescheme-validationyamlcomparetappromiseObservablesArray.prototype.flattenlinuxpreserve-symlinksnumberlesscssvisualeslintdirectoryArrayBuffer.prototype.sliceObject.keyscssfast-deep-cloneestreeapidefinePropertyreal-timechinesequerysqsdatasignalform-validationbyteLengthawaitcryptogenericscloudformation$.extendrdsmapreducedefinejsonpathcolorsless mixinsexecflagstableemrconfigurabledebuggerinstallglobalfromECMAScript 2019phoneremovecollectionjavascriptES2017Array.prototype.filtertypesimpledbyuppathroutingprocessArrayBuffer#sliceregexpjasmineeverygradients css3symlinkfastifytestingwidthbinddescriptorsautoscalingreplaybyteOffsetwebwritableswfobjspinnerendpointcorepackage.jsondescriptorstdliblimitedES5fseventsstatesortjsdomautoprefixermatchextensionpromisescjkajaxvariablesrmdirequality[[Prototype]]keynegativeforEachArray.prototype.flatMapzeroresolveESReactiveExtensionsserializationcall-bindES2018arraybufferFloat64ArraytypesafeglacierArray.prototype.includesES2015mruoperating-systemeslint-pluginappstatelessshimstreamcloudsearchelmintrinsicarktypeWeakSetstringECMAScript 7mkdirpArray.prototype.findLastUint32Arrayroute53redux-toolkitSymbolcensorbrowserslistECMAScript 3symbolloggercodestestfunctionsInt32Arrayless.jssearchcallclass-validatorgradients cssfull-widthbuffersgdprfetchtypescriptRxtrimStartnodejsglobdomargvaccessibilityprunefunctionalwatchereventsInt16Arrayfluxsignalsinferencecolormimecss variableUint8Arraycss lessauthpackage managertoStringTagarrayswafastoutputrequireajvweakmapjwtiteratorregular expressionrestwhichObject.valueslastchaimake dirschemeprototypedatelook-upencryptionhttpss3fastgroupByvestWebSocketset__proto__macosES2023consumetc39exitefficienteventDispatcherjsdifffolderfunctionqsendererror-handlingmiddlewarerm -rfprogresskarmafindLastYAMLsuperagentcompile lessloadingstarterUnderscoreomitkeysrestfuldirassignaccessorwriteregularclonesyntaxformatmkdir
@ellentorg/debitis-laboriosam-laudantium@ellentorg/alias-quibusdam-eius@ellentorg/asperiores-minima-minima@ellentorg/deleniti-beatae-dolorum@ellentorg/dolorem-animi-sed@ellentorg/corporis-soluta-ea@ellentorg/temporibus-modi-odio@ellentorg/maxime-libero-minus@ellentorg/eligendi-quisquam-provident@ellentorg/eligendi-earum-dolore@ellentorg/mollitia-consequatur-nemo@ellentorg/nihil-neque-non@ellentorg/nobis-eum-iste@ellentorg/quo-voluptatem-commodi@ellentorg/sint-dicta-modi@ellentorg/quo-debitis-odio@ellentorg/soluta-architecto-nesciunt@ellentorg/recusandae-ad-mollitia@ellentorg/recusandae-eius-maiores@ellentorg/similique-ullam-commodi@ellentorg/suscipit-quaerat-voluptas@ellentorg/cumque-qui-voluptas@ellentorg/doloribus-deserunt-odio@ellentorg/culpa-reiciendis-error@ellentorg/error-officiis-excepturi@ellentorg/expedita-accusantium-aliquid@ellentorg/perferendis-aspernatur-eligendi@ellentorg/quas-molestiae-vel@ellentorg/quam-temporibus-aperiam@ellentorg/possimus-eius-quos@ellentorg/possimus-sunt-quas@ellentorg/nobis-quis-excepturi@ellentorg/magnam-corrupti-ab@ellentorg/maiores-odit-temporibus@ellentorg/maxime-ut-id@ellentorg/aliquam-aspernatur-quidem@ellentorg/aperiam-facere-fuga@ellentorg/aperiam-praesentium-aliquam@ellentorg/consequatur-eveniet-asperiores@ellentorg/aliquam-rem-saepe@ellentorg/aliquid-molestiae-odit@ellentorg/iusto-alias-vero@ellentorg/voluptates-eaque-unde@ellentorg/unde-eum-explicabo@ellentorg/vel-ipsa-nemo@ellentorg/velit-praesentium-enim@ellentorg/veritatis-possimus-vitae@ellentorg/nostrum-exercitationem-facilis@ellentorg/officia-dolorem-ad@ellentorg/non-iure-assumenda
8.12.148

10 months ago

7.12.148

10 months ago

3.8.87

1 year ago

5.10.119

11 months ago

5.10.118

11 months ago

5.10.117

11 months ago

5.10.116

11 months ago

5.10.120

11 months ago

3.8.85

1 year ago

2.7.66

1 year ago

3.8.86

1 year ago

2.7.65

1 year ago

3.8.83

1 year ago

3.8.84

1 year ago

3.8.82

1 year ago

2.7.69

1 year ago

2.7.68

1 year ago

2.7.67

1 year ago

2.7.73

1 year ago

2.7.72

1 year ago

2.7.71

1 year ago

2.7.70

1 year ago

5.10.108

12 months ago

5.10.107

12 months ago

5.10.106

12 months ago

5.10.109

12 months ago

5.10.111

11 months ago

6.12.125

11 months ago

5.10.110

12 months ago

5.10.115

11 months ago

2.5.58

1 year ago

5.10.114

11 months ago

2.5.59

1 year ago

5.10.113

11 months ago

5.10.112

11 months ago

2.5.54

1 year ago

2.5.55

1 year ago

2.7.75

1 year ago

2.5.56

1 year ago

2.7.74

1 year ago

2.5.57

1 year ago

2.5.51

1 year ago

2.5.52

1 year ago

2.5.53

1 year ago

2.5.60

1 year ago

7.12.128

11 months ago

7.12.127

11 months ago

4.8.87

1 year ago

7.12.129

11 months ago

7.12.135

11 months ago

4.8.89

1 year ago

2.1.27

1 year ago

7.12.134

11 months ago

4.8.88

1 year ago

2.1.28

1 year ago

7.12.137

10 months ago

2.1.25

1 year ago

7.12.136

11 months ago

2.1.26

1 year ago

7.12.131

11 months ago

5.9.106

12 months ago

2.3.46

1 year ago

7.12.130

11 months ago

5.9.105

12 months ago

2.3.45

1 year ago

2.1.24

1 year ago

7.12.133

11 months ago

2.3.48

1 year ago

7.12.132

11 months ago

2.3.47

1 year ago

5.9.102

12 months ago

5.9.101

12 months ago

5.9.104

12 months ago

2.3.44

1 year ago

5.9.103

12 months ago

2.5.61

1 year ago

2.5.62

1 year ago

5.9.100

12 months ago

2.5.63

1 year ago

1.1.19

1 year ago

7.12.139

10 months ago

7.12.138

10 months ago

2.1.29

1 year ago

7.12.146

10 months ago

7.12.145

10 months ago

2.1.36

1 year ago

7.12.147

10 months ago

7.12.142

10 months ago

2.1.34

1 year ago

7.12.141

10 months ago

2.1.35

1 year ago

7.12.144

10 months ago

2.1.32

1 year ago

7.12.143

10 months ago

2.1.33

1 year ago

2.1.30

1 year ago

1.1.23

1 year ago

2.1.31

1 year ago

1.1.22

1 year ago

7.12.140

10 months ago

1.1.21

1 year ago

1.1.20

1 year ago

1.1.24

1 year ago

3.7.79

1 year ago

3.7.77

1 year ago

3.7.78

1 year ago

3.7.75

1 year ago

3.7.76

1 year ago

4.8.100

12 months ago

6.11.123

11 months ago

6.11.124

11 months ago

5.11.122

11 months ago

6.11.125

11 months ago

5.11.121

11 months ago

4.8.90

1 year ago

6.11.122

11 months ago

5.11.120

11 months ago

4.8.92

1 year ago

4.8.91

1 year ago

4.8.94

12 months ago

4.8.93

1 year ago

4.8.96

12 months ago

4.8.95

12 months ago

4.8.98

12 months ago

4.8.97

12 months ago

4.8.99

12 months ago

7.12.126

11 months ago

7.12.125

11 months ago

2.4.49

1 year ago

2.4.48

1 year ago

3.7.82

1 year ago

3.7.80

1 year ago

3.7.81

1 year ago

2.6.63

1 year ago

2.6.64

1 year ago

2.6.65

1 year ago

2.2.39

1 year ago

2.2.37

1 year ago

2.2.38

1 year ago

2.2.36

1 year ago

2.4.50

1 year ago

2.4.51

1 year ago

5.8.100

12 months ago

2.2.44

1 year ago

2.2.42

1 year ago

2.2.43

1 year ago

2.2.40

1 year ago

2.2.41

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago