9.20.139 • Published 10 months ago

@firanorg/nulla-cupiditate-ad v9.20.139

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

10 months ago

9.19.139

10 months ago

9.17.134

10 months ago

9.17.135

10 months ago

9.17.136

10 months ago

9.19.136

10 months ago

9.19.137

10 months ago

9.19.138

10 months ago

9.16.130

10 months ago

9.16.131

10 months ago

9.16.134

10 months ago

9.16.132

10 months ago

9.16.133

10 months ago

9.16.127

11 months ago

9.16.128

11 months ago

9.16.125

11 months ago

9.16.126

11 months ago

9.16.129

10 months ago

8.16.125

11 months ago

8.16.124

11 months ago

9.18.136

10 months ago

8.15.123

11 months ago

8.16.123

11 months ago

8.15.122

11 months ago

7.15.122

11 months ago

7.14.122

11 months ago

7.14.120

11 months ago

7.14.121

11 months ago

7.14.115

11 months ago

7.14.116

11 months ago

7.14.117

11 months ago

7.14.118

11 months ago

7.14.119

11 months ago

6.14.115

11 months ago

6.13.115

11 months ago

6.13.114

11 months ago

6.13.113

11 months ago

6.12.113

11 months ago

6.12.112

11 months ago

6.11.112

11 months ago

6.11.110

11 months ago

6.11.111

11 months ago

6.11.109

11 months ago

6.11.108

11 months ago

6.11.107

11 months ago

6.11.106

12 months ago

6.11.105

12 months ago

6.11.104

12 months ago

6.11.103

12 months ago

6.11.102

12 months ago

6.11.101

12 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

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

1 year ago

3.2.16

1 year ago

3.2.19

1 year ago

6.11.100

12 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

12 months ago

6.9.91

12 months ago

6.9.90

12 months ago

6.7.67

1 year ago

6.7.68

1 year ago

6.7.69

1 year ago

6.10.99

12 months ago

6.9.82

1 year ago

6.10.98

12 months ago

6.9.81

1 year ago

6.10.97

12 months ago

6.9.80

1 year ago

6.10.96

12 months ago

6.10.95

12 months ago

6.10.94

12 months ago

6.10.93

12 months ago

6.7.65

1 year ago

6.10.92

12 months ago

6.7.66

1 year ago

6.9.89

12 months 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

12 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