8.12.148 • Published 1 year ago

@ellentorg/ad-dolor-atque v8.12.148

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year 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
8.12.148

1 year ago

7.12.148

1 year ago

3.8.87

1 year ago

5.10.119

1 year ago

5.10.118

1 year ago

5.10.117

1 year ago

5.10.116

1 year ago

5.10.120

1 year 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

1 year ago

5.10.107

1 year ago

5.10.106

1 year ago

5.10.109

1 year ago

5.10.111

1 year ago

6.12.125

1 year ago

5.10.110

1 year ago

5.10.115

1 year ago

2.5.58

1 year ago

5.10.114

1 year ago

2.5.59

1 year ago

5.10.113

1 year ago

5.10.112

1 year 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

1 year ago

7.12.127

1 year ago

4.8.87

1 year ago

7.12.129

1 year ago

7.12.135

1 year ago

4.8.89

1 year ago

2.1.27

2 years ago

7.12.134

1 year ago

4.8.88

1 year ago

2.1.28

2 years ago

7.12.137

1 year ago

2.1.25

2 years ago

7.12.136

1 year ago

2.1.26

2 years ago

7.12.131

1 year ago

5.9.106

1 year ago

2.3.46

1 year ago

7.12.130

1 year ago

5.9.105

1 year ago

2.3.45

1 year ago

2.1.24

2 years ago

7.12.133

1 year ago

2.3.48

1 year ago

7.12.132

1 year ago

2.3.47

1 year ago

5.9.102

1 year ago

5.9.101

1 year ago

5.9.104

1 year ago

2.3.44

1 year ago

5.9.103

1 year ago

2.5.61

1 year ago

2.5.62

1 year ago

5.9.100

1 year ago

2.5.63

1 year ago

1.1.19

2 years ago

7.12.139

1 year ago

7.12.138

1 year ago

2.1.29

2 years ago

7.12.146

1 year ago

7.12.145

1 year ago

2.1.36

1 year ago

7.12.147

1 year ago

7.12.142

1 year ago

2.1.34

1 year ago

7.12.141

1 year ago

2.1.35

1 year ago

7.12.144

1 year ago

2.1.32

2 years ago

7.12.143

1 year ago

2.1.33

1 year ago

2.1.30

2 years ago

1.1.23

2 years ago

2.1.31

2 years ago

1.1.22

2 years ago

7.12.140

1 year ago

1.1.21

2 years ago

1.1.20

2 years ago

1.1.24

2 years 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

1 year ago

6.11.123

1 year ago

6.11.124

1 year ago

5.11.122

1 year ago

6.11.125

1 year ago

5.11.121

1 year ago

4.8.90

1 year ago

6.11.122

1 year ago

5.11.120

1 year ago

4.8.92

1 year ago

4.8.91

1 year ago

4.8.94

1 year ago

4.8.93

1 year ago

4.8.96

1 year ago

4.8.95

1 year ago

4.8.98

1 year ago

4.8.97

1 year ago

4.8.99

1 year ago

7.12.126

1 year ago

7.12.125

1 year 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

1 year 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

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago