9.20.139 • Published 1 year ago

@firanorg/nulla-cupiditate-ad v9.20.139

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

1 year ago

9.19.139

1 year ago

9.17.134

1 year ago

9.17.135

1 year ago

9.17.136

1 year ago

9.19.136

1 year ago

9.19.137

1 year ago

9.19.138

1 year ago

9.16.130

1 year ago

9.16.131

1 year ago

9.16.134

1 year ago

9.16.132

1 year ago

9.16.133

1 year ago

9.16.127

1 year ago

9.16.128

1 year ago

9.16.125

1 year ago

9.16.126

1 year ago

9.16.129

1 year ago

8.16.125

1 year ago

8.16.124

1 year ago

9.18.136

1 year ago

8.15.123

1 year ago

8.16.123

1 year ago

8.15.122

1 year ago

7.15.122

1 year ago

7.14.122

1 year ago

7.14.120

1 year ago

7.14.121

1 year ago

7.14.115

1 year ago

7.14.116

1 year ago

7.14.117

1 year ago

7.14.118

1 year ago

7.14.119

1 year ago

6.14.115

1 year ago

6.13.115

1 year ago

6.13.114

1 year ago

6.13.113

1 year ago

6.12.113

1 year ago

6.12.112

1 year ago

6.11.112

1 year ago

6.11.110

1 year ago

6.11.111

1 year ago

6.11.109

1 year ago

6.11.108

1 year ago

6.11.107

1 year ago

6.11.106

1 year ago

6.11.105

1 year ago

6.11.104

1 year ago

6.11.103

1 year ago

6.11.102

1 year ago

6.11.101

1 year ago

3.2.24

2 years ago

3.2.23

2 years ago

3.2.26

2 years ago

3.2.25

2 years ago

3.2.20

2 years ago

3.2.22

2 years ago

3.2.21

2 years ago

6.8.80

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

1 year ago

6.6.58

1 year ago

6.6.59

1 year ago

6.8.70

1 year ago

6.8.78

1 year ago

6.8.77

1 year ago

6.8.76

1 year ago

6.8.75

1 year ago

6.8.74

1 year ago

6.8.73

1 year ago

6.8.72

1 year ago

6.8.71

1 year ago

3.2.17

2 years ago

3.2.16

2 years ago

3.2.19

2 years ago

6.11.100

1 year ago

3.2.18

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

1 year ago

6.9.91

1 year ago

6.9.90

1 year ago

6.7.67

1 year ago

6.7.68

1 year ago

6.7.69

1 year ago

6.10.99

1 year ago

6.9.82

1 year ago

6.10.98

1 year ago

6.9.81

1 year ago

6.10.97

1 year ago

6.9.80

1 year ago

6.10.96

1 year ago

6.10.95

1 year ago

6.10.94

1 year ago

6.10.93

1 year ago

6.7.65

1 year ago

6.10.92

1 year ago

6.7.66

1 year ago

6.9.89

1 year ago

6.9.88

1 year ago

6.9.87

1 year ago

6.9.86

1 year ago

6.9.85

1 year ago

6.9.84

1 year ago

6.9.83

1 year ago

6.8.69

1 year ago

6.11.99

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

2 years ago

3.3.27

2 years ago

3.3.28

2 years ago

3.3.29

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

2 years ago

3.2.13

2 years ago

3.2.14

2 years ago

2.2.13

2 years ago

2.2.12

2 years ago

2.2.11

2 years ago

1.2.11

2 years ago

1.2.10

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago