Latest repo

This commit is contained in:
Marc
2025-06-02 16:42:16 +00:00
parent 53ddf1a329
commit cde5fae175
27907 changed files with 3875388 additions and 1 deletions

22
node_modules/style-to-object/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2017 Menglin "Mark" Xu <mark@remarkablemark.org>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

188
node_modules/style-to-object/README.md generated vendored Normal file
View File

@@ -0,0 +1,188 @@
# style-to-object
[![NPM](https://nodei.co/npm/style-to-object.png)](https://nodei.co/npm/style-to-object/)
[![NPM version](https://badgen.net/npm/v/style-to-object)](https://www.npmjs.com/package/style-to-object)
[![Bundlephobia minified + gzip](https://badgen.net/bundlephobia/minzip/style-to-object)](https://bundlephobia.com/package/style-to-object)
[![build](https://github.com/remarkablemark/style-to-object/actions/workflows/build.yml/badge.svg)](https://github.com/remarkablemark/style-to-object/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/remarkablemark/style-to-object/branch/master/graph/badge.svg?token=XWxph9dpa4)](https://codecov.io/gh/remarkablemark/style-to-object)
[![NPM downloads](https://badgen.net/npm/dm/style-to-object)](https://www.npmjs.com/package/style-to-object)
Parse CSS inline style to JavaScript object:
```js
import parse from 'style-to-object';
parse('color: #C0FFEE; background: #BADA55;');
```
Output:
```js
{ color: '#C0FFEE', background: '#BADA55' }
```
[JSFiddle](https://jsfiddle.net/remarkablemark/ykz2meot/) | [Replit](https://replit.com/@remarkablemark/style-to-object) | [Examples](https://github.com/remarkablemark/style-to-object/tree/master/examples)
## Installation
[NPM](https://www.npmjs.com/package/style-to-object):
```sh
npm install style-to-object --save
```
[Yarn](https://yarn.fyi/style-to-object):
```sh
yarn add style-to-object
```
[CDN](https://unpkg.com/style-to-object/):
```html
<script src="https://unpkg.com/style-to-object@latest/dist/style-to-object.min.js"></script>
<script>
window.StyleToObject(/* string */);
</script>
```
## Usage
Import with ES Modules:
```js
import parse from 'style-to-object';
```
Require with CommonJS:
```js
const parse = require('style-to-object').default;
```
Parse single declaration:
```js
parse('line-height: 42');
```
Output:
```js
{ 'line-height': '42' }
```
Parse multiple declarations:
```js
parse(`
border-color: #ACE;
z-index: 1337;
`);
```
Output:
```js
{ 'border-color': '#ACE', 'z-index': '1337' }
```
Parse unknown declarations:
```js
parse('answer: 42;');
```
Output:
```js
{ 'answer': '42' }
```
Invalid declarations/arguments:
<!-- prettier-ignore-start -->
```js
parse(`
top: ;
right: 1em;
`); // { right: '1em' }
parse(); // null
parse(null); // null
parse(1); // null
parse(true); // null
parse('top:'); // null
parse(':12px'); // null
parse(':'); // null
parse(';'); // null
parse('top'); // throws Error
parse('/*'); // throws Error
```
<!-- prettier-ignore-end -->
### Iterator
If the 2nd argument is a function, then the parser will return `null`:
```js
parse('color: #f00', () => {}); // null
```
But the function will iterate through each declaration:
<!-- prettier-ignore-start -->
```js
parse('color: #f00', (name, value, declaration) => {
console.log(name); // 'color'
console.log(value); // '#f00'
console.log(declaration); // { type: 'declaration', property: 'color', value: '#f00' }
});
```
<!-- prettier-ignore-end -->
This makes it easy to customize the output:
```js
const style = `
color: red;
background: blue;
`;
const output = [];
function iterator(name, value) {
output.push([name, value]);
}
parse(style, iterator);
console.log(output); // [['color', 'red'], ['background', 'blue']]
```
## Migration
### v1
Migrated to TypeScript. Iterator excludes `Comment`. CommonJS requires the `.default` key:
```js
const parse = require('style-to-object').default;
```
## Release
Release and publish are automated by [Release Please](https://github.com/googleapis/release-please).
## Special Thanks
- [inline-style-parser](https://github.com/remarkablemark/inline-style-parser)
- [Contributors](https://github.com/remarkablemark/style-to-object/graphs/contributors)
## License
[MIT](https://github.com/remarkablemark/style-to-object/blob/master/LICENSE)

22
node_modules/style-to-object/cjs/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import type { Declaration } from 'inline-style-parser';
export { Declaration };
interface StyleObject {
[name: string]: string;
}
type Iterator = (property: string, value: string, declaration: Declaration) => void;
/**
* Parses inline style to object.
*
* @param style - Inline style.
* @param iterator - Iterator.
* @returns - Style object or null.
*
* @example Parsing inline style to object:
*
* ```js
* import parse from 'style-to-object';
* parse('line-height: 42;'); // { 'line-height': '42' }
* ```
*/
export default function StyleToObject(style: string, iterator?: Iterator): StyleObject | null;
//# sourceMappingURL=index.d.ts.map

1
node_modules/style-to-object/cjs/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,UAAU,WAAW;IACnB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED,KAAK,QAAQ,GAAG,CACd,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,WAAW,KACrB,IAAI,CAAC;AAEV;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,QAAQ,GAClB,WAAW,GAAG,IAAI,CA0BpB"}

44
node_modules/style-to-object/cjs/index.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = StyleToObject;
var inline_style_parser_1 = __importDefault(require("inline-style-parser"));
/**
* Parses inline style to object.
*
* @param style - Inline style.
* @param iterator - Iterator.
* @returns - Style object or null.
*
* @example Parsing inline style to object:
*
* ```js
* import parse from 'style-to-object';
* parse('line-height: 42;'); // { 'line-height': '42' }
* ```
*/
function StyleToObject(style, iterator) {
var styleObject = null;
if (!style || typeof style !== 'string') {
return styleObject;
}
var declarations = (0, inline_style_parser_1.default)(style);
var hasIterator = typeof iterator === 'function';
declarations.forEach(function (declaration) {
if (declaration.type !== 'declaration') {
return;
}
var property = declaration.property, value = declaration.value;
if (hasIterator) {
iterator(property, value, declaration);
}
else if (value) {
styleObject = styleObject || {};
styleObject[property] = value;
}
});
return styleObject;
}
//# sourceMappingURL=index.js.map

1
node_modules/style-to-object/cjs/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AA6BA,gCA6BC;AAzDD,4EAAwC;AAcxC;;;;;;;;;;;;;GAaG;AACH,SAAwB,aAAa,CACnC,KAAa,EACb,QAAmB;IAEnB,IAAI,WAAW,GAAuB,IAAI,CAAC;IAE3C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,IAAM,YAAY,GAAG,IAAA,6BAAK,EAAC,KAAK,CAAC,CAAC;IAClC,IAAM,WAAW,GAAG,OAAO,QAAQ,KAAK,UAAU,CAAC;IAEnD,YAAY,CAAC,OAAO,CAAC,UAAC,WAAW;QAC/B,IAAI,WAAW,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;YACvC,OAAO;QACT,CAAC;QAEO,IAAA,QAAQ,GAAY,WAAW,SAAvB,EAAE,KAAK,GAAK,WAAW,MAAhB,CAAiB;QAExC,IAAI,WAAW,EAAE,CAAC;YAChB,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;QACzC,CAAC;aAAM,IAAI,KAAK,EAAE,CAAC;YACjB,WAAW,GAAG,WAAW,IAAI,EAAE,CAAC;YAChC,WAAW,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;QAChC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC"}

311
node_modules/style-to-object/dist/style-to-object.js generated vendored Normal file
View File

@@ -0,0 +1,311 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.StyleToObject = factory());
})(this, (function () { 'use strict';
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
// http://www.w3.org/TR/CSS21/grammar.html
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
var NEWLINE_REGEX = /\n/g;
var WHITESPACE_REGEX = /^\s*/;
// declaration
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
var COLON_REGEX = /^:\s*/;
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
var SEMICOLON_REGEX = /^[;\s]*/;
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
var TRIM_REGEX = /^\s+|\s+$/g;
// strings
var NEWLINE = '\n';
var FORWARD_SLASH = '/';
var ASTERISK = '*';
var EMPTY_STRING = '';
// types
var TYPE_COMMENT = 'comment';
var TYPE_DECLARATION = 'declaration';
/**
* @param {String} style
* @param {Object} [options]
* @return {Object[]}
* @throws {TypeError}
* @throws {Error}
*/
var inlineStyleParser = function (style, options) {
if (typeof style !== 'string') {
throw new TypeError('First argument must be a string');
}
if (!style) return [];
options = options || {};
/**
* Positional.
*/
var lineno = 1;
var column = 1;
/**
* Update lineno and column based on `str`.
*
* @param {String} str
*/
function updatePosition(str) {
var lines = str.match(NEWLINE_REGEX);
if (lines) lineno += lines.length;
var i = str.lastIndexOf(NEWLINE);
column = ~i ? str.length - i : column + str.length;
}
/**
* Mark position and patch `node.position`.
*
* @return {Function}
*/
function position() {
var start = { line: lineno, column: column };
return function (node) {
node.position = new Position(start);
whitespace();
return node;
};
}
/**
* Store position information for a node.
*
* @constructor
* @property {Object} start
* @property {Object} end
* @property {undefined|String} source
*/
function Position(start) {
this.start = start;
this.end = { line: lineno, column: column };
this.source = options.source;
}
/**
* Non-enumerable source string.
*/
Position.prototype.content = style;
/**
* Error `msg`.
*
* @param {String} msg
* @throws {Error}
*/
function error(msg) {
var err = new Error(
options.source + ':' + lineno + ':' + column + ': ' + msg
);
err.reason = msg;
err.filename = options.source;
err.line = lineno;
err.column = column;
err.source = style;
if (options.silent) ; else {
throw err;
}
}
/**
* Match `re` and return captures.
*
* @param {RegExp} re
* @return {undefined|Array}
*/
function match(re) {
var m = re.exec(style);
if (!m) return;
var str = m[0];
updatePosition(str);
style = style.slice(str.length);
return m;
}
/**
* Parse whitespace.
*/
function whitespace() {
match(WHITESPACE_REGEX);
}
/**
* Parse comments.
*
* @param {Object[]} [rules]
* @return {Object[]}
*/
function comments(rules) {
var c;
rules = rules || [];
while ((c = comment())) {
if (c !== false) {
rules.push(c);
}
}
return rules;
}
/**
* Parse comment.
*
* @return {Object}
* @throws {Error}
*/
function comment() {
var pos = position();
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
var i = 2;
while (
EMPTY_STRING != style.charAt(i) &&
(ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))
) {
++i;
}
i += 2;
if (EMPTY_STRING === style.charAt(i - 1)) {
return error('End of comment missing');
}
var str = style.slice(2, i - 2);
column += 2;
updatePosition(str);
style = style.slice(i);
column += 2;
return pos({
type: TYPE_COMMENT,
comment: str
});
}
/**
* Parse declaration.
*
* @return {Object}
* @throws {Error}
*/
function declaration() {
var pos = position();
// prop
var prop = match(PROPERTY_REGEX);
if (!prop) return;
comment();
// :
if (!match(COLON_REGEX)) return error("property missing ':'");
// val
var val = match(VALUE_REGEX);
var ret = pos({
type: TYPE_DECLARATION,
property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
value: val
? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))
: EMPTY_STRING
});
// ;
match(SEMICOLON_REGEX);
return ret;
}
/**
* Parse declarations.
*
* @return {Object[]}
*/
function declarations() {
var decls = [];
comments(decls);
// declarations
var decl;
while ((decl = declaration())) {
if (decl !== false) {
decls.push(decl);
comments(decls);
}
}
return decls;
}
whitespace();
return declarations();
};
/**
* Trim `str`.
*
* @param {String} str
* @return {String}
*/
function trim(str) {
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
}
var parse = /*@__PURE__*/getDefaultExportFromCjs(inlineStyleParser);
/**
* Parses inline style to object.
*
* @param style - Inline style.
* @param iterator - Iterator.
* @returns - Style object or null.
*
* @example Parsing inline style to object:
*
* ```js
* import parse from 'style-to-object';
* parse('line-height: 42;'); // { 'line-height': '42' }
* ```
*/
function StyleToObject(style, iterator) {
var styleObject = null;
if (!style || typeof style !== 'string') {
return styleObject;
}
var declarations = parse(style);
var hasIterator = typeof iterator === 'function';
declarations.forEach(function (declaration) {
if (declaration.type !== 'declaration') {
return;
}
var property = declaration.property, value = declaration.value;
if (hasIterator) {
iterator(property, value, declaration);
}
else if (value) {
styleObject = styleObject || {};
styleObject[property] = value;
}
});
return styleObject;
}
return StyleToObject;
}));
//# sourceMappingURL=style-to-object.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n="undefined"!=typeof globalThis?globalThis:n||self).StyleToObject=e()}(this,(function(){"use strict";function n(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,t=/^\s*/,o=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,a="";function s(n){return n?n.replace(f,a):a}var l=n((function(n,f){if("string"!=typeof n)throw new TypeError("First argument must be a string");if(!n)return[];f=f||{};var l=1,p=1;function h(n){var e=n.match(r);e&&(l+=e.length);var t=n.lastIndexOf("\n");p=~t?n.length-t:p+n.length}function v(){var n={line:l,column:p};return function(e){return e.position=new d(n),g(),e}}function d(n){this.start=n,this.end={line:l,column:p},this.source=f.source}function m(e){var r=new Error(f.source+":"+l+":"+p+": "+e);if(r.reason=e,r.filename=f.source,r.line=l,r.column=p,r.source=n,!f.silent)throw r}function y(e){var r=e.exec(n);if(r){var t=r[0];return h(t),n=n.slice(t.length),r}}function g(){y(t)}function w(n){var e;for(n=n||[];e=b();)!1!==e&&n.push(e);return n}function b(){var e=v();if("/"==n.charAt(0)&&"*"==n.charAt(1)){for(var r=2;a!=n.charAt(r)&&("*"!=n.charAt(r)||"/"!=n.charAt(r+1));)++r;if(r+=2,a===n.charAt(r-1))return m("End of comment missing");var t=n.slice(2,r-2);return p+=2,h(t),n=n.slice(r),p+=2,e({type:"comment",comment:t})}}function A(){var n=v(),r=y(o);if(r){if(b(),!y(i))return m("property missing ':'");var t=y(u),f=n({type:"declaration",property:s(r[0].replace(e,a)),value:t?s(t[0].replace(e,a)):a});return y(c),f}}return d.prototype.content=n,g(),function(){var n,e=[];for(w(e);n=A();)!1!==n&&(e.push(n),w(e));return e}()}));return function(n,e){var r=null;if(!n||"string"!=typeof n)return r;var t=l(n),o="function"==typeof e;return t.forEach((function(n){if("declaration"===n.type){var t=n.property,i=n.value;o?e(t,i,n):i&&((r=r||{})[t]=i)}})),r}}));
//# sourceMappingURL=style-to-object.min.js.map

File diff suppressed because one or more lines are too long

21
node_modules/style-to-object/esm/index.d.mts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import type { Declaration } from 'inline-style-parser';
export { Declaration };
interface StyleObject {
[name: string]: string;
}
type Iterator = (property: string, value: string, declaration: Declaration) => void;
/**
* Parses inline style to object.
*
* @param style - Inline style.
* @param iterator - Iterator.
* @returns - Style object or null.
*
* @example Parsing inline style to object:
*
* ```js
* import parse from 'style-to-object';
* parse('line-height: 42;'); // { 'line-height': '42' }
* ```
*/
export default function StyleToObject(style: string, iterator?: Iterator): StyleObject | null;

4
node_modules/style-to-object/esm/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import StyleToObject from '../cjs/index.js';
// ensure compatibility with rollup umd build
export default StyleToObject.default || StyleToObject;

81
node_modules/style-to-object/package.json generated vendored Normal file
View File

@@ -0,0 +1,81 @@
{
"name": "style-to-object",
"version": "1.0.8",
"description": "Parse CSS inline style to JavaScript object.",
"author": "Mark <mark@remarkablemark.org>",
"main": "./cjs/index.js",
"module": "./esm/index.mjs",
"exports": {
"import": "./esm/index.mjs",
"require": "./cjs/index.js"
},
"scripts": {
"build": "run-s build:*",
"build:cjs": "tsc",
"build:esm": "awk '!/sourceMappingURL/' cjs/index.d.ts > esm/index.d.mts",
"build:umd": "rollup --config --failAfterWarnings",
"clean": "rm -rf cjs coverage dist",
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
"lint:tsc": "tsc --noEmit",
"prepare": "husky",
"prepublishOnly": "run-s lint lint:tsc test clean build",
"test": "jest",
"test:ci": "CI=true jest --ci --colors --coverage",
"test:esm": "npm run build:cjs && node --test __tests__",
"test:watch": "npm run test -- --watch"
},
"repository": {
"type": "git",
"url": "https://github.com/remarkablemark/style-to-object"
},
"bugs": {
"url": "https://github.com/remarkablemark/style-to-object/issues"
},
"keywords": [
"style-to-object",
"inline",
"style",
"parser",
"css",
"object",
"pojo"
],
"dependencies": {
"inline-style-parser": "0.2.4"
},
"devDependencies": {
"@commitlint/cli": "19.5.0",
"@commitlint/config-conventional": "19.5.0",
"@eslint/compat": "1.1.1",
"@eslint/eslintrc": "3.1.0",
"@eslint/js": "9.10.0",
"@rollup/plugin-commonjs": "26.0.1",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-terser": "0.4.4",
"@rollup/plugin-typescript": "11.1.6",
"@types/jest": "29.5.12",
"@types/node": "22.5.4",
"@typescript-eslint/eslint-plugin": "8.5.0",
"@typescript-eslint/parser": "8.5.0",
"eslint": "9.10.0",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-simple-import-sort": "12.1.1",
"globals": "15.9.0",
"husky": "9.1.5",
"jest": "29.7.0",
"lint-staged": "15.2.10",
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"rollup": "4.21.2",
"ts-jest": "29.2.5",
"typescript": "5.6.2"
},
"files": [
"/cjs",
"/dist",
"/esm",
"/src"
],
"license": "MIT"
}

59
node_modules/style-to-object/src/index.ts generated vendored Normal file
View File

@@ -0,0 +1,59 @@
import type { Declaration } from 'inline-style-parser';
import parse from 'inline-style-parser';
export { Declaration };
interface StyleObject {
[name: string]: string;
}
type Iterator = (
property: string,
value: string,
declaration: Declaration,
) => void;
/**
* Parses inline style to object.
*
* @param style - Inline style.
* @param iterator - Iterator.
* @returns - Style object or null.
*
* @example Parsing inline style to object:
*
* ```js
* import parse from 'style-to-object';
* parse('line-height: 42;'); // { 'line-height': '42' }
* ```
*/
export default function StyleToObject(
style: string,
iterator?: Iterator,
): StyleObject | null {
let styleObject: StyleObject | null = null;
if (!style || typeof style !== 'string') {
return styleObject;
}
const declarations = parse(style);
const hasIterator = typeof iterator === 'function';
declarations.forEach((declaration) => {
if (declaration.type !== 'declaration') {
return;
}
const { property, value } = declaration;
if (hasIterator) {
iterator(property, value, declaration);
} else if (value) {
styleObject = styleObject || {};
styleObject[property] = value;
}
});
return styleObject;
}