Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@a-2-c-2-anpm/architecto-dolorum-rem

a-2-c-2-anpm302MIT1.0.0

NPM

trimEnd, form-validation, ES2018, dir, break, Object.values, typesafe, import, starter, metadata, karma, robust, ascii, bundling, commander, mime, name, uuid, function.length, sharedarraybuffer, japanese, computed-types, minimal, promise, HyBi, react animation, Object.entries, sham, typedarray, manipulation, vest, Object, visual, es-abstract, atom, jsdom, ES3, callbind, CSS, type, emr, local, coercible, byte, utilities, rm, ratelimit, protocol-buffers, arrays, picomatch, child, glacier, JSON, limited, testing, autoprefixer, npmignore, take, streams, String.prototype.trim, ReactiveExtensions, mocha, es2015, ES2016, es7, column, queue, YAML, typed array, optimist, codes, three, dom, parsing, validation, form, lint, ECMAScript 5, private, ajax, cloudformation, deepclone, toStringTag, width, reuse, collection, parser, js, slice, invariant, execute, mkdirp, streams2, time, censor, mimetypes, WebSockets, input, mime-db, byteOffset, css, [[Prototype]], joi, findLastIndex, toobject, ES2022, mkdir, internal slot, fps, cli, lazy, id, config, es8, ECMAScript 6, Promise, extra, jasmine, ECMAScript 2018, ECMAScript 2016, rm -fr, look-up, Symbol.toStringTag, rate, logger, generics, endpoint, concatMap, matches, buffers, source map, location, emoji, toArray, routing, map, @@toStringTag, deep-clone, workspace:*, cloudtrail, BigInt64Array, environment, own, a11y, debugger, dependency manager, forEach, is, iterator, task, ec2, TypeScript, fnmatch, contains, characters, colour, output, group, Underscore, $.extend, cache, matchAll, http, descriptor, binary, dotenv, lru, symlink, apollo, multi-package, guid, ReactiveX, WeakSet, stable, safe, eslintplugin, getopt, dom-testing-library, getPrototypeOf, api, functional, flatten, chinese, Object.is, random, graphql, es6, dependencies, typanion, dataView, extension, performance, es-shims, symlinks, native, dataview, libphonenumber, last, Int8Array, ECMAScript 2015, rework, querystring, Uint32Array, command, styling, persistent, figlet, valid, getOwnPropertyDescriptor, make, get, gitignore, text, superagent, character, util, uninstall, types, fs, shared, https, browserslist, tester, es5, deterministic, loading, Float64Array, create, electron, environments, route53, call, eslint, promises, reduce, Microsoft, east-asian-width, RFC-6455, argument, traverse, popmotion, weakmap, getter, ES2019, args, chai, RxJS, regular expression, fork, wget, ponyfill, Int32Array, xml, Uint8ClampedArray, scheme-validation, rules, ECMAScript 2023, Array.prototype.contains, functions, asserts, jsx, process, xhr, simpledb, packages, mobile, redux, core, flatMap, Observable, installer, prefix, ES2017, superstruct, negative zero, Array.prototype.findLastIndex, find-up, length, has, 0, forms, swf, client, ecmascript, loadbalancing, spec, global, syntax, assign, bound, descriptors, hookform, eslint-plugin, getintrinsic, dynamodb, settings, aws, trimRight, once, spinner, waf, redux-toolkit, inspect, Push, telephone, filter, typeerror, request, up, read, hash, expression, WeakMap, es-shim API, Stream, fast-clone, touch, obj, assert, rm -rf, prototype, Object.keys, yaml, columns, espree, shell, runtime, efficient, property, queueMicrotask, core-js, positive, arktype, search, console, debug, limit, fast, ESnext, cjk, has-own, subprocess, i18n, color, zod, trim, Object.fromEntries, zero, hardlinks, file system, array, .gitignore, __proto__, ts, env, from, ES7, slot, ansi, package, StyleSheet, remove, internal, jQuery, yup, bin, es2016, helper, write, Array, identifiers, pose, nope, transform, fastcopy, binaries, throat, warning, immutable, accessibility, execfile, terminal, toolkit, flat, code points, test, Float32Array, delete, install, performant, weakset, worker, flags, importexport, setImmediate, ES, optimizer, assertion, command-line, negative, pretty, datastructure, higher-order, folder, tc39, stream, WebSocket, resolve, rmdir, argv, set, batch, structuredClone, some, shim, look, real-time, await, ES5, file, equality, elasticache, CSSStyleDeclaration, ES8, sameValueZero, sequence, equal, extend, package.json, ECMAScript 2022, bdd, sort, callbound, setPrototypeOf, Int16Array, curl, styles, Set, zx, Rx, fetch, ES2021, URLSearchParams, typed, rds, log, rfc4122, ava, regular-expression, 256, require, link, language, listeners, ECMAScript 2019, deepcopy, every, react-hooks, vars, ArrayBuffer.prototype.slice, iteration, syntaxerror, cloudfront, prop, ES2015, speed, copy, description, RegExp.prototype.flags, module, String.prototype.matchAll, fast-deep-copy

readme

@a-2-c-2-anpm/architecto-dolorum-rem

NPM

NPM version Bundlephobia minified + gzip build codecov NPM downloads

Parses CSS inline style to JavaScript object (camelCased):

StyleToJS(string)

Example

import parse from '@a-2-c-2-anpm/architecto-dolorum-rem';

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

Output:

{ "backgroundColor": "#BADA55" }

Replit | JSFiddle | Examples

Install

NPM:

npm install @a-2-c-2-anpm/architecto-dolorum-rem --save

Yarn:

yarn add @a-2-c-2-anpm/architecto-dolorum-rem

CDN:

<script src="https://unpkg.com/@a-2-c-2-anpm/architecto-dolorum-rem@latest/umd/@a-2-c-2-anpm/architecto-dolorum-rem.min.js"></script>
<script>
  window.StyleToJS(/* string */);
</script>

Usage

Import

Import with ES Modules:

import parse from '@a-2-c-2-anpm/architecto-dolorum-rem';

Require with CommonJS:

const parse = require('@a-2-c-2-anpm/architecto-dolorum-rem');

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