style-to-object 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -318,3 +318,4 @@
318
318
  return index;
319
319
 
320
320
  }));
321
+ //# sourceMappingURL=style-to-object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style-to-object.js","sources":["../node_modules/inline-style-parser/index.js","../index.js"],"sourcesContent":["// http://www.w3.org/TR/CSS21/grammar.html\n// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027\nvar COMMENT_REGEX = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\n\nvar NEWLINE_REGEX = /\\n/g;\nvar WHITESPACE_REGEX = /^\\s*/;\n\n// declaration\nvar PROPERTY_REGEX = /^(\\*?[-#/*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/;\nvar COLON_REGEX = /^:\\s*/;\nvar VALUE_REGEX = /^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^)]*?\\)|[^};])+)/;\nvar SEMICOLON_REGEX = /^[;\\s]*/;\n\n// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill\nvar TRIM_REGEX = /^\\s+|\\s+$/g;\n\n// strings\nvar NEWLINE = '\\n';\nvar FORWARD_SLASH = '/';\nvar ASTERISK = '*';\nvar EMPTY_STRING = '';\n\n// types\nvar TYPE_COMMENT = 'comment';\nvar TYPE_DECLARATION = 'declaration';\n\n/**\n * @param {String} style\n * @param {Object} [options]\n * @return {Object[]}\n * @throws {TypeError}\n * @throws {Error}\n */\nmodule.exports = function(style, options) {\n if (typeof style !== 'string') {\n throw new TypeError('First argument must be a string');\n }\n\n if (!style) return [];\n\n options = options || {};\n\n /**\n * Positional.\n */\n var lineno = 1;\n var column = 1;\n\n /**\n * Update lineno and column based on `str`.\n *\n * @param {String} str\n */\n function updatePosition(str) {\n var lines = str.match(NEWLINE_REGEX);\n if (lines) lineno += lines.length;\n var i = str.lastIndexOf(NEWLINE);\n column = ~i ? str.length - i : column + str.length;\n }\n\n /**\n * Mark position and patch `node.position`.\n *\n * @return {Function}\n */\n function position() {\n var start = { line: lineno, column: column };\n return function(node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n\n /**\n * Store position information for a node.\n *\n * @constructor\n * @property {Object} start\n * @property {Object} end\n * @property {undefined|String} source\n */\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n\n /**\n * Non-enumerable source string.\n */\n Position.prototype.content = style;\n\n var errorsList = [];\n\n /**\n * Error `msg`.\n *\n * @param {String} msg\n * @throws {Error}\n */\n function error(msg) {\n var err = new Error(\n options.source + ':' + lineno + ':' + column + ': ' + msg\n );\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = style;\n\n if (options.silent) {\n errorsList.push(err);\n } else {\n throw err;\n }\n }\n\n /**\n * Match `re` and return captures.\n *\n * @param {RegExp} re\n * @return {undefined|Array}\n */\n function match(re) {\n var m = re.exec(style);\n if (!m) return;\n var str = m[0];\n updatePosition(str);\n style = style.slice(str.length);\n return m;\n }\n\n /**\n * Parse whitespace.\n */\n function whitespace() {\n match(WHITESPACE_REGEX);\n }\n\n /**\n * Parse comments.\n *\n * @param {Object[]} [rules]\n * @return {Object[]}\n */\n function comments(rules) {\n var c;\n rules = rules || [];\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n }\n return rules;\n }\n\n /**\n * Parse comment.\n *\n * @return {Object}\n * @throws {Error}\n */\n function comment() {\n var pos = position();\n if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;\n\n var i = 2;\n while (\n EMPTY_STRING != style.charAt(i) &&\n (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))\n ) {\n ++i;\n }\n i += 2;\n\n if (EMPTY_STRING === style.charAt(i - 1)) {\n return error('End of comment missing');\n }\n\n var str = style.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n style = style.slice(i);\n column += 2;\n\n return pos({\n type: TYPE_COMMENT,\n comment: str\n });\n }\n\n /**\n * Parse declaration.\n *\n * @return {Object}\n * @throws {Error}\n */\n function declaration() {\n var pos = position();\n\n // prop\n var prop = match(PROPERTY_REGEX);\n if (!prop) return;\n comment();\n\n // :\n if (!match(COLON_REGEX)) return error(\"property missing ':'\");\n\n // val\n var val = match(VALUE_REGEX);\n\n var ret = pos({\n type: TYPE_DECLARATION,\n property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),\n value: val\n ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))\n : EMPTY_STRING\n });\n\n // ;\n match(SEMICOLON_REGEX);\n\n return ret;\n }\n\n /**\n * Parse declarations.\n *\n * @return {Object[]}\n */\n function declarations() {\n var decls = [];\n\n comments(decls);\n\n // declarations\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n }\n\n return decls;\n }\n\n whitespace();\n return declarations();\n};\n\n/**\n * Trim `str`.\n *\n * @param {String} str\n * @return {String}\n */\nfunction trim(str) {\n return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;\n}\n","var parse = require('inline-style-parser');\n\n/**\n * Parses inline style to object.\n *\n * @example\n * // returns { 'line-height': '42' }\n * StyleToObject('line-height: 42;');\n *\n * @param {String} style - The inline style.\n * @param {Function} [iterator] - The iterator function.\n * @return {null|Object}\n */\nfunction StyleToObject(style, iterator) {\n var output = null;\n if (!style || typeof style !== 'string') {\n return output;\n }\n\n var declaration;\n var declarations = parse(style);\n var hasIterator = typeof iterator === 'function';\n var property;\n var value;\n\n for (var i = 0, len = declarations.length; i < len; i++) {\n declaration = declarations[i];\n property = declaration.property;\n value = declaration.value;\n\n if (hasIterator) {\n iterator(property, value, declaration);\n } else if (value) {\n output || (output = {});\n output[property] = value;\n }\n }\n\n return output;\n}\n\nmodule.exports = StyleToObject;\nmodule.exports.default = StyleToObject; // ESM support\n"],"names":["require$$0","styleToObjectModule"],"mappings":";;;;;;;;;;;;CAAA;CACA;CACA,IAAI,aAAa,GAAG,iCAAiC,CAAC;AACtD;CACA,IAAI,aAAa,GAAG,KAAK,CAAC;CAC1B,IAAI,gBAAgB,GAAG,MAAM,CAAC;AAC9B;CACA;CACA,IAAI,cAAc,GAAG,wCAAwC,CAAC;CAC9D,IAAI,WAAW,GAAG,OAAO,CAAC;CAC1B,IAAI,WAAW,GAAG,sDAAsD,CAAC;CACzE,IAAI,eAAe,GAAG,SAAS,CAAC;AAChC;CACA;CACA,IAAI,UAAU,GAAG,YAAY,CAAC;AAC9B;CACA;CACA,IAAI,OAAO,GAAG,IAAI,CAAC;CACnB,IAAI,aAAa,GAAG,GAAG,CAAC;CACxB,IAAI,QAAQ,GAAG,GAAG,CAAC;CACnB,IAAI,YAAY,GAAG,EAAE,CAAC;AACtB;CACA;CACA,IAAI,YAAY,GAAG,SAAS,CAAC;CAC7B,IAAI,gBAAgB,GAAG,aAAa,CAAC;AACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,IAAA,iBAAc,GAAG,SAAS,KAAK,EAAE,OAAO,EAAE;CAC1C,EAAE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;CACjC,IAAI,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;CAC3D,GAAG;AACH;CACA,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;AACxB;CACA,EAAE,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;AAC1B;CACA;CACA;CACA;CACA,EAAE,IAAI,MAAM,GAAG,CAAC,CAAC;CACjB,EAAE,IAAI,MAAM,GAAG,CAAC,CAAC;AACjB;CACA;CACA;CACA;CACA;CACA;CACA,EAAE,SAAS,cAAc,CAAC,GAAG,EAAE;CAC/B,IAAI,IAAI,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;CACzC,IA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CACtB,MAAM,MAAM,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC;CAC9B,MAAM,MAAM,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;CAC/B,KAAK;CACL,GAAG;AACH;CACA,EAAE,OAAO,MAAM,CAAC;CAChB,CAAC;AACD;AACAC,cAAc,CAAA,OAAA,GAAG,aAAa,CAAC;AACTA,cAAA,CAAA,OAAA,CAAA,OAAA,GAAG,cAAc;;;;;;;;;;;","x_google_ignoreList":[0]}
@@ -1 +1 @@
1
- {"version":3,"file":"style-to-object.min.js","sources":["../node_modules/inline-style-parser/index.js","../index.js"],"sourcesContent":["// http://www.w3.org/TR/CSS21/grammar.html\n// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027\nvar COMMENT_REGEX = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\n\nvar NEWLINE_REGEX = /\\n/g;\nvar WHITESPACE_REGEX = /^\\s*/;\n\n// declaration\nvar PROPERTY_REGEX = /^(\\*?[-#/*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/;\nvar COLON_REGEX = /^:\\s*/;\nvar VALUE_REGEX = /^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^)]*?\\)|[^};])+)/;\nvar SEMICOLON_REGEX = /^[;\\s]*/;\n\n// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill\nvar TRIM_REGEX = /^\\s+|\\s+$/g;\n\n// strings\nvar NEWLINE = '\\n';\nvar FORWARD_SLASH = '/';\nvar ASTERISK = '*';\nvar EMPTY_STRING = '';\n\n// types\nvar TYPE_COMMENT = 'comment';\nvar TYPE_DECLARATION = 'declaration';\n\n/**\n * @param {String} style\n * @param {Object} [options]\n * @return {Object[]}\n * @throws {TypeError}\n * @throws {Error}\n */\nmodule.exports = function(style, options) {\n if (typeof style !== 'string') {\n throw new TypeError('First argument must be a string');\n }\n\n if (!style) return [];\n\n options = options || {};\n\n /**\n * Positional.\n */\n var lineno = 1;\n var column = 1;\n\n /**\n * Update lineno and column based on `str`.\n *\n * @param {String} str\n */\n function updatePosition(str) {\n var lines = str.match(NEWLINE_REGEX);\n if (lines) lineno += lines.length;\n var i = str.lastIndexOf(NEWLINE);\n column = ~i ? str.length - i : column + str.length;\n }\n\n /**\n * Mark position and patch `node.position`.\n *\n * @return {Function}\n */\n function position() {\n var start = { line: lineno, column: column };\n return function(node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n\n /**\n * Store position information for a node.\n *\n * @constructor\n * @property {Object} start\n * @property {Object} end\n * @property {undefined|String} source\n */\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n\n /**\n * Non-enumerable source string.\n */\n Position.prototype.content = style;\n\n var errorsList = [];\n\n /**\n * Error `msg`.\n *\n * @param {String} msg\n * @throws {Error}\n */\n function error(msg) {\n var err = new Error(\n options.source + ':' + lineno + ':' + column + ': ' + msg\n );\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = style;\n\n if (options.silent) {\n errorsList.push(err);\n } else {\n throw err;\n }\n }\n\n /**\n * Match `re` and return captures.\n *\n * @param {RegExp} re\n * @return {undefined|Array}\n */\n function match(re) {\n var m = re.exec(style);\n if (!m) return;\n var str = m[0];\n updatePosition(str);\n style = style.slice(str.length);\n return m;\n }\n\n /**\n * Parse whitespace.\n */\n function whitespace() {\n match(WHITESPACE_REGEX);\n }\n\n /**\n * Parse comments.\n *\n * @param {Object[]} [rules]\n * @return {Object[]}\n */\n function comments(rules) {\n var c;\n rules = rules || [];\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n }\n return rules;\n }\n\n /**\n * Parse comment.\n *\n * @return {Object}\n * @throws {Error}\n */\n function comment() {\n var pos = position();\n if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;\n\n var i = 2;\n while (\n EMPTY_STRING != style.charAt(i) &&\n (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))\n ) {\n ++i;\n }\n i += 2;\n\n if (EMPTY_STRING === style.charAt(i - 1)) {\n return error('End of comment missing');\n }\n\n var str = style.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n style = style.slice(i);\n column += 2;\n\n return pos({\n type: TYPE_COMMENT,\n comment: str\n });\n }\n\n /**\n * Parse declaration.\n *\n * @return {Object}\n * @throws {Error}\n */\n function declaration() {\n var pos = position();\n\n // prop\n var prop = match(PROPERTY_REGEX);\n if (!prop) return;\n comment();\n\n // :\n if (!match(COLON_REGEX)) return error(\"property missing ':'\");\n\n // val\n var val = match(VALUE_REGEX);\n\n var ret = pos({\n type: TYPE_DECLARATION,\n property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),\n value: val\n ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))\n : EMPTY_STRING\n });\n\n // ;\n match(SEMICOLON_REGEX);\n\n return ret;\n }\n\n /**\n * Parse declarations.\n *\n * @return {Object[]}\n */\n function declarations() {\n var decls = [];\n\n comments(decls);\n\n // declarations\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n }\n\n return decls;\n }\n\n whitespace();\n return declarations();\n};\n\n/**\n * Trim `str`.\n *\n * @param {String} str\n * @return {String}\n */\nfunction trim(str) {\n return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;\n}\n","var parse = require('inline-style-parser');\n\n/**\n * Parses inline style to object.\n *\n * @example\n * // returns { 'line-height': '42' }\n * StyleToObject('line-height: 42;');\n *\n * @param {String} style - The inline style.\n * @param {Function} [iterator] - The iterator function.\n * @return {null|Object}\n */\nfunction StyleToObject(style, iterator) {\n var output = null;\n if (!style || typeof style !== 'string') {\n return output;\n }\n\n var declaration;\n var declarations = parse(style);\n var hasIterator = typeof iterator === 'function';\n var property;\n var value;\n\n for (var i = 0, len = declarations.length; i < len; i++) {\n declaration = declarations[i];\n property = declaration.property;\n value = declaration.value;\n\n if (hasIterator) {\n iterator(property, value, declaration);\n } else if (value) {\n output || (output = {});\n output[property] = value;\n }\n }\n\n return output;\n}\n\nmodule.exports = StyleToObject;\nmodule.exports.default = StyleToObject; // ESM support\n"],"names":["COMMENT_REGEX","NEWLINE_REGEX","WHITESPACE_REGEX","PROPERTY_REGEX","COLON_REGEX","VALUE_REGEX","SEMICOLON_REGEX","TRIM_REGEX","EMPTY_STRING","trim","str","replace","parse","style","options","TypeError","lineno","column","updatePosition","lines","match","length","i","lastIndexOf","position","start","line","node","Position","whitespace","this","end","source","error","msg","err","Error","reason","filename","silent","re","m","exec","slice","comments","rules","c","comment","push","pos","charAt","type","declaration","prop","val","ret","property","value","prototype","content","decl","decls","declarations","StyleToObject","iterator","output","hasIterator","len","styleToObjectModule","exports","default"],"mappings":"qWAEIA,EAAgB,kCAEhBC,EAAgB,MAChBC,EAAmB,OAGnBC,EAAiB,yCACjBC,EAAc,QACdC,EAAc,uDACdC,EAAkB,UAGlBC,EAAa,aAMbC,EAAe,GA8OnB,SAASC,EAAKC,GACZ,OAAOA,EAAMA,EAAIC,QAAQJ,EAAYC,GAAgBA,CACvD,CCpQA,IAAII,EDiCa,SAASC,EAAOC,GAC/B,GAAqB,iBAAVD,EACT,MAAM,IAAIE,UAAU,mCAGtB,IAAKF,EAAO,MAAO,GAEnBC,EAAUA,GAAW,GAKrB,IAAIE,EAAS,EACTC,EAAS,EAOb,SAASC,EAAeR,GACtB,IAAIS,EAAQT,EAAIU,MAAMnB,GAClBkB,IAAOH,GAAUG,EAAME,QAC3B,IAAIC,EAAIZ,EAAIa,YAvCF,MAwCVN,GAAUK,EAAIZ,EAAIW,OAASC,EAAIL,EAASP,EAAIW,MAC7C,CAOD,SAASG,IACP,IAAIC,EAAQ,CAAEC,KAAMV,EAAQC,OAAQA,GACpC,OAAO,SAASU,GAGd,OAFAA,EAAKH,SAAW,IAAII,EAASH,GAC7BI,IACOF,CACb,CACG,CAUD,SAASC,EAASH,GACh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P,IAAIH,EAAMzB,IAGN6B,EAAOjC,EAAMjB,GACjB,GAAKkD,EAAL,CAIA,GAHAN,KAGK3B,EAAMhB,GAAc,OAAO6B,EAAM,wBAGtC,IAAIqB,EAAMlC,EAAMf,GAEZkD,EAAMN,EAAI,CACZE,KA7LiB,cA8LjBK,SAAU/C,EAAK4C,EAAK,GAAG1C,QAAQX,EAAeQ,IAC9CiD,MAAOH,EACH7C,EAAK6C,EAAI,GAAG3C,QAAQX,EAAeQ,IACnCA,IAMN,OAFAY,EAAMd,GAECiD,CApBW,CAqBnB,CAyBD,OA9JA3B,EAAS8B,UAAUC,QAAU9C,EA6J7BgB,IAjBA,WACE,IAKI+B,EALAC,EAAQ,GAMZ,IAJAjB,EAASiB,GAIDD,EAAOR,MACA,IAATQ,IACFC,EAAMb,KAAKY,GACXhB,EAASiB,IAIb,OAAOA,CACR,CAGMC,EACT,EC7OA,SAASC,EAAclD,EAAOmD,GAC5B,IAKIZ,EALAa,EAAS,KACb,IAAKpD,GAA0B,iBAAVA,EACnB,OAAOoD,EAST,IALA,IAEIT,EACAC,EAHAK,EAAelD,EAAMC,GACrBqD,EAAkC,mBAAbF,EAIhB1C,EAAI,EAAG6C,EAAML,EAAazC,OAAQC,EAAI6C,EAAK7C,IAElDkC,GADAJ,EAAcU,EAAaxC,IACJkC,SACvBC,EAAQL,EAAYK,MAEhBS,EACFF,EAASR,EAAUC,EAAOL,GACjBK,IACTQ,IAAWA,EAAS,CAAA,GACpBA,EAAOT,GAAYC,GAIvB,OAAOQ,CACT,QAEAG,EAAcC,QAAGN,EACKK,EAAAC,QAAAC,QAAGP"}
1
+ {"version":3,"file":"style-to-object.min.js","sources":["../node_modules/inline-style-parser/index.js","../index.js"],"sourcesContent":["// http://www.w3.org/TR/CSS21/grammar.html\n// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027\nvar COMMENT_REGEX = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\n\nvar NEWLINE_REGEX = /\\n/g;\nvar WHITESPACE_REGEX = /^\\s*/;\n\n// declaration\nvar PROPERTY_REGEX = /^(\\*?[-#/*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/;\nvar COLON_REGEX = /^:\\s*/;\nvar VALUE_REGEX = /^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^)]*?\\)|[^};])+)/;\nvar SEMICOLON_REGEX = /^[;\\s]*/;\n\n// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill\nvar TRIM_REGEX = /^\\s+|\\s+$/g;\n\n// strings\nvar NEWLINE = '\\n';\nvar FORWARD_SLASH = '/';\nvar ASTERISK = '*';\nvar EMPTY_STRING = '';\n\n// types\nvar TYPE_COMMENT = 'comment';\nvar TYPE_DECLARATION = 'declaration';\n\n/**\n * @param {String} style\n * @param {Object} [options]\n * @return {Object[]}\n * @throws {TypeError}\n * @throws {Error}\n */\nmodule.exports = function(style, options) {\n if (typeof style !== 'string') {\n throw new TypeError('First argument must be a string');\n }\n\n if (!style) return [];\n\n options = options || {};\n\n /**\n * Positional.\n */\n var lineno = 1;\n var column = 1;\n\n /**\n * Update lineno and column based on `str`.\n *\n * @param {String} str\n */\n function updatePosition(str) {\n var lines = str.match(NEWLINE_REGEX);\n if (lines) lineno += lines.length;\n var i = str.lastIndexOf(NEWLINE);\n column = ~i ? str.length - i : column + str.length;\n }\n\n /**\n * Mark position and patch `node.position`.\n *\n * @return {Function}\n */\n function position() {\n var start = { line: lineno, column: column };\n return function(node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n\n /**\n * Store position information for a node.\n *\n * @constructor\n * @property {Object} start\n * @property {Object} end\n * @property {undefined|String} source\n */\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n\n /**\n * Non-enumerable source string.\n */\n Position.prototype.content = style;\n\n var errorsList = [];\n\n /**\n * Error `msg`.\n *\n * @param {String} msg\n * @throws {Error}\n */\n function error(msg) {\n var err = new Error(\n options.source + ':' + lineno + ':' + column + ': ' + msg\n );\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = style;\n\n if (options.silent) {\n errorsList.push(err);\n } else {\n throw err;\n }\n }\n\n /**\n * Match `re` and return captures.\n *\n * @param {RegExp} re\n * @return {undefined|Array}\n */\n function match(re) {\n var m = re.exec(style);\n if (!m) return;\n var str = m[0];\n updatePosition(str);\n style = style.slice(str.length);\n return m;\n }\n\n /**\n * Parse whitespace.\n */\n function whitespace() {\n match(WHITESPACE_REGEX);\n }\n\n /**\n * Parse comments.\n *\n * @param {Object[]} [rules]\n * @return {Object[]}\n */\n function comments(rules) {\n var c;\n rules = rules || [];\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n }\n return rules;\n }\n\n /**\n * Parse comment.\n *\n * @return {Object}\n * @throws {Error}\n */\n function comment() {\n var pos = position();\n if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;\n\n var i = 2;\n while (\n EMPTY_STRING != style.charAt(i) &&\n (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))\n ) {\n ++i;\n }\n i += 2;\n\n if (EMPTY_STRING === style.charAt(i - 1)) {\n return error('End of comment missing');\n }\n\n var str = style.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n style = style.slice(i);\n column += 2;\n\n return pos({\n type: TYPE_COMMENT,\n comment: str\n });\n }\n\n /**\n * Parse declaration.\n *\n * @return {Object}\n * @throws {Error}\n */\n function declaration() {\n var pos = position();\n\n // prop\n var prop = match(PROPERTY_REGEX);\n if (!prop) return;\n comment();\n\n // :\n if (!match(COLON_REGEX)) return error(\"property missing ':'\");\n\n // val\n var val = match(VALUE_REGEX);\n\n var ret = pos({\n type: TYPE_DECLARATION,\n property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),\n value: val\n ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))\n : EMPTY_STRING\n });\n\n // ;\n match(SEMICOLON_REGEX);\n\n return ret;\n }\n\n /**\n * Parse declarations.\n *\n * @return {Object[]}\n */\n function declarations() {\n var decls = [];\n\n comments(decls);\n\n // declarations\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n }\n\n return decls;\n }\n\n whitespace();\n return declarations();\n};\n\n/**\n * Trim `str`.\n *\n * @param {String} str\n * @return {String}\n */\nfunction trim(str) {\n return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;\n}\n","var parse = require('inline-style-parser');\n\n/**\n * Parses inline style to object.\n *\n * @example\n * // returns { 'line-height': '42' }\n * StyleToObject('line-height: 42;');\n *\n * @param {String} style - The inline style.\n * @param {Function} [iterator] - The iterator function.\n * @return {null|Object}\n */\nfunction StyleToObject(style, iterator) {\n var output = null;\n if (!style || typeof style !== 'string') {\n return output;\n }\n\n var declaration;\n var declarations = parse(style);\n var hasIterator = typeof iterator === 'function';\n var property;\n var value;\n\n for (var i = 0, len = declarations.length; i < len; i++) {\n declaration = declarations[i];\n property = declaration.property;\n value = declaration.value;\n\n if (hasIterator) {\n iterator(property, value, declaration);\n } else if (value) {\n output || (output = {});\n output[property] = value;\n }\n }\n\n return output;\n}\n\nmodule.exports = StyleToObject;\nmodule.exports.default = StyleToObject; // ESM support\n"],"names":["COMMENT_REGEX","NEWLINE_REGEX","WHITESPACE_REGEX","PROPERTY_REGEX","COLON_REGEX","VALUE_REGEX","SEMICOLON_REGEX","TRIM_REGEX","EMPTY_STRING","trim","str","replace","parse","style","options","TypeError","lineno","column","updatePosition","lines","match","length","i","lastIndexOf","position","start","line","node","Position","whitespace","this","end","source","error","msg","err","Error","reason","filename","silent","re","m","exec","slice","comments","rules","c","comment","push","pos","charAt","type","declaration","prop","val","ret","property","value","prototype","content","decl","decls","declarations","StyleToObject","iterator","output","hasIterator","len","styleToObjectModule","exports","default"],"mappings":"qWAEIA,EAAgB,kCAEhBC,EAAgB,MAChBC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T,EC7OA,SAASC,EAAclD,EAAOmD,GAC5B,IAKIZ,EALAa,EAAS,KACb,IAAKpD,GAA0B,iBAAVA,EACnB,OAAOoD,EAST,IALA,IAEIT,EACAC,EAHAK,EAAelD,EAAMC,GACrBqD,EAAkC,mBAAbF,EAIhB1C,EAAI,EAAG6C,EAAML,EAAazC,OAAQC,EAAI6C,EAAK7C,IAElDkC,GADAJ,EAAcU,EAAaxC,IACJkC,SACvBC,EAAQL,EAAYK,MAEhBS,EACFF,EAASR,EAAUC,EAAOL,GACjBK,IACTQ,IAAWA,EAAS,CAAA,GACpBA,EAAOT,GAAYC,GAIvB,OAAOQ,CACT,QAEAG,EAAcC,QAAGN,EACKK,EAAAC,QAAAC,QAAGP","x_google_ignoreList":[0]}
package/index.d.ts CHANGED
@@ -2,37 +2,44 @@
2
2
  * Parses inline style to object.
3
3
  *
4
4
  * @example
5
- * import StyleToObject from 'style-to-object';
6
- * StyleToObject('line-height: 42;');
5
+ *
6
+ * ```ts
7
+ * import parse from 'style-to-object';
8
+ * parse('line-height: 42;'); // { 'line-height': '42' }
9
+ * ```
7
10
  */
8
- declare function StyleToObject(
11
+ export default function StyleToObject(
9
12
  style: string,
10
- iterator?: StyleToObject.Iterator
13
+ iterator?: Iterator
11
14
  ): { [name: string]: string } | null;
12
15
 
13
- export = StyleToObject;
14
-
15
- declare namespace StyleToObject {
16
- interface DeclarationPos {
16
+ interface Position {
17
+ start: {
18
+ line: number;
19
+ column: number;
20
+ };
21
+ end: {
17
22
  line: number;
18
23
  column: number;
19
- }
24
+ };
25
+ source?: string;
26
+ }
20
27
 
21
- // declaration is an object from module `inline-style-parser`
22
- interface Declaration {
23
- type: string;
24
- property: string;
25
- value: string;
26
- position: {
27
- start: DeclarationPos;
28
- end: DeclarationPos;
29
- source: any;
30
- };
31
- }
28
+ export interface Declaration {
29
+ type: 'declaration';
30
+ property: string;
31
+ value: string;
32
+ position: Position;
33
+ }
32
34
 
33
- type Iterator = (
34
- property: string,
35
- value: string,
36
- declaration: Declaration
37
- ) => void;
35
+ export interface Comment {
36
+ type: 'comment';
37
+ comment: string;
38
+ position: Position;
38
39
  }
40
+
41
+ type Iterator = (
42
+ property: string,
43
+ value: string,
44
+ declaration: Declaration | Comment
45
+ ) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "style-to-object",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Converts inline style to object.",
5
5
  "author": "Mark <mark@remarkablemark.org>",
6
6
  "main": "index.js",
@@ -12,9 +12,7 @@
12
12
  "require": "./index.js"
13
13
  },
14
14
  "scripts": {
15
- "build": "run-s build:*",
16
- "build:min": "NODE_ENV=production rollup --config --file dist/style-to-object.min.js --sourcemap",
17
- "build:unmin": "NODE_ENV=development rollup --config --file dist/style-to-object.js",
15
+ "build": "rollup --config --failAfterWarnings",
18
16
  "clean": "rm -rf dist",
19
17
  "lint": "eslint --ignore-path .gitignore .",
20
18
  "lint:fix": "npm run lint -- --fix",
@@ -22,9 +20,9 @@
22
20
  "_postinstall": "husky install",
23
21
  "postpublish": "pinst --enable",
24
22
  "prepublishOnly": "pinst --disable && run-s lint lint:dts test clean build",
25
- "test": "mocha --exclude **/*.mjs",
26
- "test:coverage": "nyc npm test",
27
- "test:module": "node --experimental-modules test/index.mjs",
23
+ "test": "jest",
24
+ "test:ci": "CI=true jest --ci --colors --coverage",
25
+ "test:esm": "node --test __tests__/index.test.mjs",
28
26
  "test:watch": "npm run test -- --watch"
29
27
  },
30
28
  "repository": {
@@ -47,23 +45,23 @@
47
45
  "inline-style-parser": "0.1.1"
48
46
  },
49
47
  "devDependencies": {
50
- "@commitlint/cli": "17.6.7",
51
- "@commitlint/config-conventional": "17.6.7",
52
- "@rollup/plugin-commonjs": "25.0.3",
53
- "@rollup/plugin-node-resolve": "15.1.0",
54
- "@rollup/plugin-terser": "0.4.3",
55
- "dtslint": "4.2.1",
56
- "eslint": "8.46.0",
57
- "eslint-plugin-prettier": "5.0.0",
48
+ "@commitlint/cli": "17.8.0",
49
+ "@commitlint/config-conventional": "17.8.0",
50
+ "@definitelytyped/dtslint": "0.0.182",
51
+ "@rollup/plugin-commonjs": "25.0.5",
52
+ "@rollup/plugin-node-resolve": "15.2.3",
53
+ "@rollup/plugin-terser": "0.4.4",
54
+ "@typescript-eslint/parser": "5.62.0",
55
+ "eslint": "8.51.0",
56
+ "eslint-plugin-prettier": "5.0.1",
58
57
  "husky": "8.0.3",
59
- "lint-staged": "13.2.3",
60
- "mocha": "10.2.0",
58
+ "jest": "29.7.0",
59
+ "lint-staged": "14.0.1",
61
60
  "npm-run-all": "4.1.5",
62
- "nyc": "15.1.0",
63
61
  "pinst": "3.0.0",
64
- "prettier": "3.0.0",
65
- "rollup": "2.79.1",
66
- "typescript": "5.1.6"
62
+ "prettier": "3.0.3",
63
+ "rollup": "4.1.0",
64
+ "typescript": "5.2.2"
67
65
  },
68
66
  "files": [
69
67
  "/dist",