8.12.124 • Published 10 months ago

@womorg/occaecati-ducimus-laboriosam v8.12.124

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

@womorg/occaecati-ducimus-laboriosam

NPM

NPM version Bundlephobia minified + gzip build codecov NPM downloads

Parses CSS inline style to JavaScript object (camelCased):

StyleToJS(string)

Example

import parse from '@womorg/occaecati-ducimus-laboriosam';

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

Output:

{ "backgroundColor": "#BADA55" }

Replit | JSFiddle | Examples

Install

NPM:

npm install @womorg/occaecati-ducimus-laboriosam --save

Yarn:

yarn add @womorg/occaecati-ducimus-laboriosam

CDN:

<script src="https://unpkg.com/@womorg/occaecati-ducimus-laboriosam@latest/umd/@womorg/occaecati-ducimus-laboriosam.min.js"></script>
<script>
  window.StyleToJS(/* string */);
</script>

Usage

Import

Import with ES Modules:

import parse from '@womorg/occaecati-ducimus-laboriosam';

Require with CommonJS:

const parse = require('@womorg/occaecati-ducimus-laboriosam');

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

elbaccessorroutereact-testing-libraryES5everyvalidateyamllogless mixinsnested csscall-boundzerorouteres6Uint8ClampedArrayWebSocketsvpcmomentratelimitcallgdprHyBia11ySymbolReflect.getPrototypeOftextbatchdomcompile lessECMAScript 2015walkingi18nArrayBuffer#slicepathdeep-clonejoiMapparsingvaluelinewrapchromedescriptorfolderObject.keysgetOwnPropertyDescriptorlibphonenumbersharedarraybuffercopydataViewimmers3colourfulltoobjectoptimizergroupSetstablepostcss-pluginmergeassertionless.jsinstallerrobustmatchesserializeReactiveXrm -rfxtermestreedeepclonees2015ArrayBufferefficientFloat32Arrayinstalljasmineopenec2eventDispatcherrequesttoolkitspecsortedendpoint256deterministicperformancesetterenvloadbalancingsymlinksharedvisualRxfast-copyoncebootstrap lesspreserve-symlinkslookautoprefixerhelpersstringifyECMAScript 2017functionalfixed-widththrottleeslintconfigmixinshotutilmkdirplook-upArray.prototype.containsprivatecharactersassertArray.prototype.findLastIndexcloudsearchwaitjsxmatchAllstatuses-abstracttypescriptexpressiontrimStartenumerableqsflagwatchercolumnflattenfiglet__proto__containsprotobuftypesaferemoveboundpushlinkshimisConcatSpreadableimportvaluescommandsetImmediateagentworkspace:*Int8Arrayuuidcheckreact-hooksmatchnodecharacternamesincludesyupprettyString.prototype.matchAlltrimiteratorcorspositivechromium_.extendjapaneseECMAScript 3getPrototypeOfupcompilerdatereadableSymbol.toStringTagarraybufferreduxtypeStreamcollection.es6cloudwatcherror-handlingamazonObject.ishooksclisliceproxyprogressbrowserslisttypedsimpledbiecss variableparserinputjsonsnssafecommand-line0debuggerreactspinnersString.prototype.trimenvironmentfindtscall-bindtapinspectObservableemojiquerystringdependency managerES2022bddomitdataviewES2020Array.prototype.flatMapreducerutilitiesdescriptorscloneUnderscoreliveinterruptsgetterwarningerrordefineObject.valuesvariablesguidlanguagebyteOffsetviewfastkarmareplaycss lessasciiworkflowwraplistenerscoercibletoSortedurlweakmapObject.entriesgradients css3hasOwnPropertyjavascriptES2019toolsECMAScript 2023mkdirsdirectoryhookformflatMapredux-toolkitECMAScript 6cryptconfigurablefseventsES8ES2018package managernodejsstylingframeworkmonorepoclassesArrayBuffer.prototype.slicesqsECMAScript 5typeerrornativehasOwnWebSocketthroatebsbyteLengthfastcopykinesissearchfast-deep-clonewhatwgformsmimetypesfast-clonerfc4122configsinatraes2017WeakSetform-validationindicatorprotocol-buffersmiddlewarechairegexfastcloneformattingsyntaxprunestreams2util.inspectstyled-componentsregular expressionsmimees2016superstructdayjsdeleteexpressobjectexitES2016bluebirdarraysreadablestreamformscheme-validationlastuninstallcircularxhrforEachbundlersettingsprocessrestfulRFC-6455modulesformatfind-upcloudformationterminalregularsignalsfsURLSearchParamsArrayinvariantdeepcopyemrIteratorfromwatchfindLastreusepredictablelazybrowserlistcollectioninPromiseworkerwhichWeakMapextensioncreateargumenthttpseventsstoragegatewaytslibredactroute53sortiammulti-packagestreamsTypeScriptclassnamesjsonpathcloudtraillimitrestconcatparents[[Prototype]]es-shimspromisesperformantidponyfillES3globsymbolcore-jsmkdirawaittddRegExp.prototype.flagsoutputasttestparseRegExp#flagsserializergetintrinsiclintlinuxES2017dynamodbwafemitapislotECMAScript 2020arraytestingsymbolsassertselectronYAMLrapidFloat64ArraytoArrayqueueMicrotaskarktypesequenceflagseslint-pluginclass-validatorconsoleaccessibilityparentES2023drop.envcodesPushchanneles2018deep-copysigtermvariables in cssdotenvconcurrencytostringtagawsansientriesio-tspromiseapptouchfunctionsrecursiveratestarterruntimebufferwidthwalkrdsoperating-systemweaksetawesomesaucees-shim APIpropenderpreprocessormetadatagetoptobjmochacachemapttydependenciespackagesquerycryptoautoscalingduplexcallboundES2015shrinkwrappackageprotozodinferenceESnextregexplruwindowsstreamshebangdefinePropertyCSSStyleDeclarationschemadescriptiontermJSON-SchemaRxJSwatchFilepatchmacosdebugECMAScript 2021passwordconcatMaprangeerrorcomputed-typesreal-timeintrinsices7mruArray.prototype.flatresolvetimeInt32ArrayunicodestatelesshardlinksbundlingvalidationTypeBoxfastifyauthmodulejsdommovestyleguideeventEmittercss nestinggroupBygetdom-testing-libraryECMAScript 7lessroutingdirsomelimitedfluxtesterexit-codebusyfetchfast-deep-copybeanstalkcolumnsargswordwrapes8jsdiffdatapersistentbyteescapestylestrimEndpostcssshamAsyncIteratorargparselockfileloggingcallbindsuperagentrmextrastatenpmsameValueZeroless compilernegative zeroeslintplugincsspipenumberrmdirwriteirqfileless cssasyncTypedArrayES6phoneregular expressionArray.prototype.includessestapeutilityObject.fromEntriesinternalloggerauthenticationequalnegativewgettrimLeftESInt16Arrayimportexportwordbreak
8.12.98

11 months ago

8.12.99

11 months ago

8.12.97

11 months ago

8.12.119

10 months ago

8.12.118

10 months ago

8.12.117

10 months ago

8.12.123

10 months ago

8.12.122

10 months ago

8.12.121

10 months ago

8.12.120

10 months ago

8.12.124

10 months ago

8.12.109

11 months ago

8.12.108

11 months ago

8.12.107

11 months ago

8.12.106

11 months ago

8.12.112

10 months ago

8.12.111

10 months ago

8.12.110

10 months ago

8.12.116

10 months ago

8.12.115

10 months ago

8.12.114

10 months ago

8.12.113

10 months ago

8.12.101

11 months ago

8.12.100

11 months ago

8.12.105

11 months ago

8.12.104

11 months ago

8.12.103

11 months ago

8.12.102

11 months ago

8.12.94

11 months ago

8.12.95

11 months ago

8.12.96

11 months ago

7.12.91

11 months ago

7.12.92

11 months ago

7.12.93

11 months ago

7.12.94

11 months ago

6.12.89

11 months ago

6.12.88

11 months ago

6.12.90

11 months ago

7.12.90

11 months ago

6.12.87

11 months ago

5.12.86

11 months ago

5.12.87

11 months ago

4.12.85

11 months ago

4.12.84

11 months ago

4.12.83

12 months ago

5.12.85

11 months ago

4.12.80

12 months ago

4.12.82

12 months ago

4.12.81

12 months ago

3.12.80

12 months ago

3.12.76

12 months ago

3.12.78

12 months ago

3.12.77

12 months ago

3.12.79

12 months ago

3.11.75

12 months ago

3.11.74

12 months ago

3.11.76

12 months ago

3.11.71

12 months ago

3.11.73

12 months ago

3.11.72

12 months ago

3.10.68

12 months ago

3.10.69

12 months ago

3.10.71

12 months ago

3.10.70

12 months ago

3.9.59

1 year ago

3.9.58

1 year ago

3.7.39

1 year ago

3.7.48

1 year ago

3.6.37

1 year ago

3.7.49

1 year ago

3.6.36

1 year ago

3.8.58

1 year ago

3.7.46

1 year ago

3.6.35

1 year ago

3.7.47

1 year ago

3.6.34

1 year ago

3.8.56

1 year ago

3.7.44

1 year ago

3.6.33

1 year ago

3.8.57

1 year ago

3.7.45

1 year ago

3.9.66

1 year ago

3.7.42

1 year ago

3.8.55

1 year ago

3.7.43

1 year ago

3.10.66

1 year ago

3.6.39

1 year ago

3.10.67

12 months ago

3.6.38

1 year ago

3.9.64

1 year ago

3.7.40

1 year ago

3.9.65

1 year ago

3.7.41

1 year ago

3.9.62

1 year ago

3.9.63

1 year ago

3.9.60

1 year ago

3.9.61

1 year ago

3.7.55

1 year ago

3.7.53

1 year ago

3.7.54

1 year ago

3.7.51

1 year ago

3.7.52

1 year ago

3.7.50

1 year ago

3.6.32

1 year ago

3.6.29

1 year ago

3.6.28

1 year ago

3.6.31

1 year ago

3.6.30

1 year ago

3.6.26

1 year ago

3.6.25

1 year ago

3.6.27

1 year ago

3.6.24

1 year ago

3.3.16

1 year ago

3.3.17

1 year ago

3.3.18

1 year ago

3.3.19

1 year ago

3.4.21

1 year ago

3.5.24

1 year ago

3.5.23

1 year ago

3.5.22

1 year ago

3.5.21

1 year ago

3.3.20

1 year ago

3.3.21

1 year ago

3.3.14

1 year ago

3.3.15

1 year ago

3.3.13

1 year ago

3.3.10

1 year ago

3.3.11

1 year ago

3.3.12

1 year ago

3.3.9

1 year ago

3.3.8

1 year ago

3.2.8

1 year ago

3.2.7

1 year ago

2.2.7

1 year ago

2.2.6

1 year ago

2.1.6

1 year ago

2.1.5

1 year ago

2.1.4

1 year ago

2.0.3

1 year ago

2.1.3

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