8.12.124 • Published 1 year ago

@womorg/occaecati-ducimus-laboriosam v8.12.124

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

1 year ago

8.12.99

1 year ago

8.12.97

1 year ago

8.12.119

1 year ago

8.12.118

1 year ago

8.12.117

1 year ago

8.12.123

1 year ago

8.12.122

1 year ago

8.12.121

1 year ago

8.12.120

1 year ago

8.12.124

1 year ago

8.12.109

1 year ago

8.12.108

1 year ago

8.12.107

1 year ago

8.12.106

1 year ago

8.12.112

1 year ago

8.12.111

1 year ago

8.12.110

1 year ago

8.12.116

1 year ago

8.12.115

1 year ago

8.12.114

1 year ago

8.12.113

1 year ago

8.12.101

1 year ago

8.12.100

1 year ago

8.12.105

1 year ago

8.12.104

1 year ago

8.12.103

1 year ago

8.12.102

1 year ago

8.12.94

1 year ago

8.12.95

1 year ago

8.12.96

1 year ago

7.12.91

1 year ago

7.12.92

1 year ago

7.12.93

1 year ago

7.12.94

1 year ago

6.12.89

1 year ago

6.12.88

1 year ago

6.12.90

1 year ago

7.12.90

1 year ago

6.12.87

1 year ago

5.12.86

1 year ago

5.12.87

1 year ago

4.12.85

1 year ago

4.12.84

1 year ago

4.12.83

1 year ago

5.12.85

1 year ago

4.12.80

1 year ago

4.12.82

1 year ago

4.12.81

1 year ago

3.12.80

1 year ago

3.12.76

1 year ago

3.12.78

1 year ago

3.12.77

1 year ago

3.12.79

1 year ago

3.11.75

1 year ago

3.11.74

1 year ago

3.11.76

1 year ago

3.11.71

1 year ago

3.11.73

1 year ago

3.11.72

1 year ago

3.10.68

1 year ago

3.10.69

1 year ago

3.10.71

1 year ago

3.10.70

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

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

2 years ago

3.6.25

2 years ago

3.6.27

1 year ago

3.6.24

2 years ago

3.3.16

2 years ago

3.3.17

2 years ago

3.3.18

2 years ago

3.3.19

2 years ago

3.4.21

2 years ago

3.5.24

2 years ago

3.5.23

2 years ago

3.5.22

2 years ago

3.5.21

2 years ago

3.3.20

2 years ago

3.3.21

2 years ago

3.3.14

2 years ago

3.3.15

2 years ago

3.3.13

2 years ago

3.3.10

2 years ago

3.3.11

2 years ago

3.3.12

2 years ago

3.3.9

2 years ago

3.3.8

2 years ago

3.2.8

2 years ago

3.2.7

2 years ago

2.2.7

2 years ago

2.2.6

2 years ago

2.1.6

2 years ago

2.1.5

2 years ago

2.1.4

2 years ago

2.0.3

2 years ago

2.1.3

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