9.20.139 • Published 9 months ago

@firanorg/nulla-cupiditate-ad v9.20.139

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

@firanorg/nulla-cupiditate-ad

NPM

NPM version Bundlephobia minified + gzip build codecov NPM downloads

Parses CSS inline style to JavaScript object (camelCased):

StyleToJS(string)

Example

import parse from '@firanorg/nulla-cupiditate-ad';

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

Output:

{ "backgroundColor": "#BADA55" }

Replit | JSFiddle | Examples

Install

NPM:

npm install @firanorg/nulla-cupiditate-ad --save

Yarn:

yarn add @firanorg/nulla-cupiditate-ad

CDN:

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

Usage

Import

Import with ES Modules:

import parse from '@firanorg/nulla-cupiditate-ad';

Require with CommonJS:

const parse = require('@firanorg/nulla-cupiditate-ad');

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

performantwatchFilecss variableES2015matchvestfluxexit-codeoptionmetadataES2019String.prototype.matchAllrdsroute53cloudtrailkoreandatasqsregexpES2020mapreducetestingautoscalingclassnamecircular@@toStringTages-abstractfscolorsFunction.prototype.namecollection.es6mapcallbackgetintrinsichttpsReactiveXArrayBuffer#sliceincludesajaxwebcoercibleencryptionArray.prototype.includesObject.definePropertyrmdirnodejsfromintrinsicratehasOwnidleformfilterlimitReflect.getPrototypeOfwatchwgetcharactermake direqualtappersistent-0statelesspostcss-pluginframeworksorteddataViewes-shimsenvoptimizertextsetImmediatepackage managerguidimportexportnamesbyteOffsetclonefast-cloneECMAScript 2017es2018syntaxpackageparsingproxytrimdirectorytakecommandObject.valuesfastcopysigintwidthagenttyped arrayinspecteventsgroupnativestringjsxsomeaccessorworkerUint8ClampedArrayslotWebSocketsfileoutputisConcatSpreadableObject.fromEntriescallESdebugphonechineseterminalchaisignalscheme-validationoncehelpersendpointregularpruneregular expressiongdpryamlArray.prototype.findLastURLtoobjectmulti-packagevaluedescriptorrangeerrorredux-toolkitutilcall-bindECMAScript 7genericsfindupdescriptorsfindLastIndexECMAScript 2021a11yeslintconfigroutingcloudfrontfastclonelook-upswfauthbannerfunctiontostringtagforEachreduceclassnamesflagwordbreakappfile systemnegative zeroamazonrm -frtelephoneexpressmatchAllcollectionentriesconfigurablecss nestingbrowserslistfindquerystringlibphonenumberObject.entriesloadingrm -rftouchECMAScript 2023keyeast-asian-widthhasOwnPropertyRegExp#flagswarningawsrapidsnskinesisoperating-systemsinatrakeysArray.prototype.filterinpredictablestringifieremrString.prototype.trimBigUint64Arrayspinnercomputed-typeserrorcloudformationieiterationObjectES6256eslint-pluginlrurobustArrayBuffer.prototype.slicees2017ArrayassertionextrawatcherRxvpclesscsssuperagentdynamodbinternallazyeventEmitterSymbolWeakMapgetopthottypeponyfillflatMapsameValueZeroshimxtermprotobufup__proto__everyJSONwrapbytetslibpreprocessorrestwalkingebsthroatCSSStyleDeclarationjsonpathtrimStartconfigesec2ECMAScript 5interruptsprocesscolorcall-boundfetchmrustylingstarternopefunctionalhas-ownqsmkdirsauthenticationjwtasyncjQueryless cssmodulesetwaftrimLeftbuffersindicatorshameventDispatcherdatastructurecolumnsargvCSSStreammovevariablespropertiesReactiveExtensionsboundFloat64ArrayBigInt64ArrayES2021deep-cloneconcatMapbusypasswordhashsliceautoprefixerbundlingxhrdependencieslogtoolkitpushfullwidthutilityunicodetimestablecharactersi18nMicrosoftMapidObject.keysdefinePropertybootstrap lessinstallopengradients css3argsES2023l10nqueueMicrotaskdefinepluginsetterajvlintmodulesrouteremitsigtermcommanderWebSocketglacierprefixuuidprivate datalessserializerglobminimaldirArray.prototype.flatobjregexarrayinferencehigher-orderflatduplexsuperstructviewregular expressionsprototypeECMAScript 2020sesimmutablepreserve-symlinksargumentthrottlees8sortURLSearchParamsflattenArray.prototype.findLastIndexreact-hook-formrestfulsignalsbreakexitnested csscjkRegExp.prototype.flagspyyamlObject.getPrototypeOfsafetrimRightdescriptionelasticacheiteratorJSON-SchemaoptimistredactreuseenderlimitedsetPrototypeOfwatchingcss lessshebangInt8Arrayserializemkdirclass-validatormakedeepworkspace:*omittddspecES3deepclonepromisessymbolsspeedstatuscomparees-shim APItraverseECMAScript 2019containstoArrayttytypeslistenersreadableinvariantenumerableexpressionstdlibtapedom-testing-libraryparsesymlinkjsonstylesheetcloudwatchratelimitutilitiesclasseses2016bcryptchromesettingsawaitpackagessideobjectpnpm9prettyiamerror-handlinges6eslintpluginstringifyvalidationwindowsWeakSetrequiremergeastreact-testing-librarynpmSymbol.toStringTagcssimmershellpromisebindkarmasyntaxerrortoStringTagio-tslinewrapequalityiterate_.extendarktype.envparentsavaObject.isinternal slotvalidconcatvaluesAsyncIteratorrecursiveurlformatuninstallcore-jsprotostylesisreal-timerandomartjasmineirqES5StyleSheetprotocol-buffersInt32ArrayUint16Arrayapireact-hooksjapanesesymlinksefficientRxJSES2022bluebirdtestshrinkwrapES8negativeHyBimomentcorscommand-lineArray.prototype.flatMapserializationfigletjestdateutil.inspectwalkTypeScriptless compilerdeletequerylengthstreamsflagsruntimefind-upfast-deep-copymatchessearchawesomesaucehasimportformattingfolderinstallerArray.prototype.containscopyfixed-widthtsreplays3fast-deep-clonecorerequestconsumeconnectschemesequencelinuxYAMLtesterjavascriptlockfilepositivestructuredClonehandlersmiddlewarebddtypedarrayextensiondataviewvisualObservableses2015arraybuffernodebundlerassertdomtypescriptmimestatetoSortedstyled-componentsenvironmentwaitwhatwg[[Prototype]]hardlinkssharedarraybufferdebuggerbyteLengtheslintfull-widthfasttaskquotestyleguidecolourIteratorpatchgetcensorvalidatevariables in cssTypedArrayECMAScript 2018termes5cryptomochaArray.prototype.flattenES2016deterministicdeep-copyqueuereactairbnbcacheextendECMAScript 2022bufferES2017execpicomatchcolumntypedlastFloat32ArraychannelfindLastrgbes7typeofmimetypesdiffwordwrapowncryptmkdirpestreemacosESnextinputStreamsgradients cssdependency managerArrayBufferbrowserdayjslanguagelookecmascriptbrowserlistreduxgetOwnPropertyDescriptorjsES2018cliPromisejoiloggerfast-copyweakmapremovepolyfillECMAScript 2015package.jsonaccessibilityelbpipelivespinnersform-validationTypeBoxfullcallboundECMAScript 3readmonorepoelectrontypanionhttpcloudsearchyupformswritablejsdiffresolvesimpledbmixinsdotenvcss-in-jsbeanstalkfunctionspostcssInt16Arrayconcurrencymime-dbnumberstreamworkflowtypesafeansigetPrototypeOfmobilearraystoolsloggingparentECMAScript 6less mixinscompiler$.extendescapebatchdrophookswritehookformcreatedeepcopyjsdomcode pointscurlelmbootstrap csspropfseventstypeerrortypedarraysrfc4122pathassign
9.20.139

9 months ago

9.19.139

9 months ago

9.17.134

9 months ago

9.17.135

9 months ago

9.17.136

9 months ago

9.19.136

9 months ago

9.19.137

9 months ago

9.19.138

9 months ago

9.16.130

10 months ago

9.16.131

10 months ago

9.16.134

9 months ago

9.16.132

10 months ago

9.16.133

9 months ago

9.16.127

10 months ago

9.16.128

10 months ago

9.16.125

10 months ago

9.16.126

10 months ago

9.16.129

10 months ago

8.16.125

10 months ago

8.16.124

10 months ago

9.18.136

9 months ago

8.15.123

10 months ago

8.16.123

10 months ago

8.15.122

10 months ago

7.15.122

10 months ago

7.14.122

10 months ago

7.14.120

10 months ago

7.14.121

10 months ago

7.14.115

10 months ago

7.14.116

10 months ago

7.14.117

10 months ago

7.14.118

10 months ago

7.14.119

10 months ago

6.14.115

10 months ago

6.13.115

10 months ago

6.13.114

10 months ago

6.13.113

10 months ago

6.12.113

10 months ago

6.12.112

10 months ago

6.11.112

10 months ago

6.11.110

11 months ago

6.11.111

10 months ago

6.11.109

11 months ago

6.11.108

11 months ago

6.11.107

11 months ago

6.11.106

11 months ago

6.11.105

11 months ago

6.11.104

11 months ago

6.11.103

11 months ago

6.11.102

11 months ago

6.11.101

11 months ago

3.2.24

1 year ago

3.2.23

1 year ago

3.2.26

1 year ago

3.2.25

1 year ago

3.2.20

1 year ago

3.2.22

1 year ago

3.2.21

1 year ago

6.8.80

12 months ago

6.6.60

1 year ago

6.6.61

1 year ago

6.6.62

1 year ago

6.6.63

1 year ago

6.6.64

1 year ago

6.6.65

1 year ago

6.8.79

12 months ago

6.6.58

1 year ago

6.6.59

1 year ago

6.8.70

12 months ago

6.8.78

12 months ago

6.8.77

12 months ago

6.8.76

12 months ago

6.8.75

12 months ago

6.8.74

12 months ago

6.8.73

12 months ago

6.8.72

12 months ago

6.8.71

12 months ago

3.2.17

1 year ago

3.2.16

1 year ago

3.2.19

1 year ago

6.11.100

11 months ago

3.2.18

1 year ago

6.4.54

1 year ago

6.4.53

1 year ago

6.4.55

1 year ago

6.4.52

1 year ago

6.4.51

1 year ago

6.3.39

1 year ago

6.5.55

1 year ago

6.5.57

1 year ago

6.5.56

1 year ago

3.3.30

1 year ago

3.3.31

1 year ago

6.5.58

1 year ago

3.3.32

1 year ago

3.3.33

1 year ago

6.9.92

11 months ago

6.9.91

11 months ago

6.9.90

11 months ago

6.7.67

12 months ago

6.7.68

12 months ago

6.7.69

12 months ago

6.10.99

11 months ago

6.9.82

12 months ago

6.10.98

11 months ago

6.9.81

12 months ago

6.10.97

11 months ago

6.9.80

12 months ago

6.10.96

11 months ago

6.10.95

11 months ago

6.10.94

11 months ago

6.10.93

11 months ago

6.7.65

12 months ago

6.10.92

11 months ago

6.7.66

12 months ago

6.9.89

11 months ago

6.9.88

11 months ago

6.9.87

11 months ago

6.9.86

11 months ago

6.9.85

11 months ago

6.9.84

11 months ago

6.9.83

11 months ago

6.8.69

12 months ago

6.11.99

11 months ago

6.3.50

1 year ago

4.3.35

1 year ago

6.3.51

1 year ago

4.3.34

1 year ago

4.3.33

1 year ago

4.3.39

1 year ago

4.3.38

1 year ago

4.3.37

1 year ago

4.3.36

1 year ago

6.3.49

1 year ago

3.3.26

1 year ago

3.3.27

1 year ago

3.3.28

1 year ago

3.3.29

1 year ago

6.3.43

1 year ago

6.3.44

1 year ago

6.3.41

1 year ago

6.3.42

1 year ago

6.3.47

1 year ago

6.3.48

1 year ago

6.3.45

1 year ago

6.3.46

1 year ago

6.3.40

1 year ago

5.3.39

1 year ago

3.2.15

1 year ago

3.2.13

1 year ago

3.2.14

1 year ago

2.2.13

1 year ago

2.2.12

1 year ago

2.2.11

1 year ago

1.2.11

1 year ago

1.2.10

1 year ago

1.2.9

1 year ago

1.2.8

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago