style-to-object 0.2.3 → 0.3.0
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.
- package/CHANGELOG.md +19 -0
- package/README.md +14 -4
- package/dist/style-to-object.js +2 -2
- package/dist/style-to-object.min.js +1 -1
- package/dist/style-to-object.min.js.map +1 -1
- package/index.d.ts +38 -0
- package/package.json +22 -17
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [0.3.0](https://github.com/remarkablemark/style-to-object/compare/v0.2.3...v0.3.0) (2019-11-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **index:** update return type of main function (remove `any`) ([c6e8a54](https://github.com/remarkablemark/style-to-object/commit/c6e8a54))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add typescript support ([74a1b83](https://github.com/remarkablemark/style-to-object/commit/74a1b83))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Tests
|
|
19
|
+
|
|
20
|
+
* **index:** add test for TS declaration file ([b029a4b](https://github.com/remarkablemark/style-to-object/commit/b029a4b))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
5
24
|
### [0.2.3](https://github.com/remarkablemark/style-to-object/compare/v0.2.2...v0.2.3) (2019-06-22)
|
|
6
25
|
|
|
7
26
|
|
package/README.md
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
Parses inline style to object:
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
|
-
var
|
|
15
|
-
|
|
14
|
+
var parse = require('style-to-object');
|
|
15
|
+
parse('color: #C0FFEE; background: #BADA55;');
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
Output:
|
|
@@ -129,7 +129,7 @@ parse('color: #f00', function() {}); // null
|
|
|
129
129
|
But the function will iterate through each declaration:
|
|
130
130
|
|
|
131
131
|
```js
|
|
132
|
-
|
|
132
|
+
parse('color: #f00', function(name, value, declaration) {
|
|
133
133
|
console.log(name); // 'color'
|
|
134
134
|
console.log(value); // '#f00'
|
|
135
135
|
console.log(declaration); // { type: 'declaration', property: 'color', value: '#f00' }
|
|
@@ -144,9 +144,11 @@ const style = `
|
|
|
144
144
|
background: blue;
|
|
145
145
|
`;
|
|
146
146
|
const output = [];
|
|
147
|
+
|
|
147
148
|
function iterator(name, value) {
|
|
148
149
|
output.push([name, value]);
|
|
149
150
|
}
|
|
151
|
+
|
|
150
152
|
parse(style, iterator);
|
|
151
153
|
console.log(output); // [['color', 'red'], ['background', 'blue']]
|
|
152
154
|
```
|
|
@@ -169,7 +171,9 @@ Run tests with coverage:
|
|
|
169
171
|
|
|
170
172
|
```sh
|
|
171
173
|
$ npm run test:coverage
|
|
172
|
-
|
|
174
|
+
|
|
175
|
+
# generate html report
|
|
176
|
+
$ npm run test:coverage:report
|
|
173
177
|
```
|
|
174
178
|
|
|
175
179
|
Lint files:
|
|
@@ -184,6 +188,12 @@ Fix lint errors:
|
|
|
184
188
|
$ npm run lint:fix
|
|
185
189
|
```
|
|
186
190
|
|
|
191
|
+
Test TypeScript declaration file for style and correctness:
|
|
192
|
+
|
|
193
|
+
```sh
|
|
194
|
+
$ npm run lint:dts
|
|
195
|
+
```
|
|
196
|
+
|
|
187
197
|
## Release
|
|
188
198
|
|
|
189
199
|
Only collaborators with credentials can release and publish:
|
package/dist/style-to-object.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
4
|
(global = global || self, global.StyleToObject = factory());
|
|
5
|
-
}(this, function () { 'use strict';
|
|
5
|
+
}(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
// http://www.w3.org/TR/CSS21/grammar.html
|
|
8
8
|
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
|
|
@@ -305,4 +305,4 @@
|
|
|
305
305
|
|
|
306
306
|
return styleToObject;
|
|
307
307
|
|
|
308
|
-
}));
|
|
308
|
+
})));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(n=n||self).StyleToObject=r()}(this,function(){"use strict";
|
|
1
|
+
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(n=n||self).StyleToObject=r()}(this,function(){"use strict";function s(e,t){if("string"!=typeof e)throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var o=1,i=1;function u(n){var r=n.match(g);r&&(o+=r.length);var t=n.lastIndexOf("\n");i=~t?n.length-t:i+n.length}function c(){var r={line:o,column:i};return function(n){return n.position=new f(r),l(),n}}function f(n){this.start=n,this.end={line:o,column:i},this.source=t.source}function a(n){var r=new Error(t.source+":"+o+":"+i+": "+n);if(r.reason=n,r.filename=t.source,r.line=o,r.column=i,r.source=e,!t.silent)throw r}function s(n){var r=n.exec(e);if(r){var t=r[0];return u(t),e=e.slice(t.length),r}}function l(){s(n)}function p(n){var r;for(n=n||[];r=h();)!1!==r&&n.push(r);return n}function h(){var n=c();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var r=2;x!=e.charAt(r)&&("*"!=e.charAt(r)||"/"!=e.charAt(r+1));)++r;if(r+=2,x===e.charAt(r-1))return a("End of comment missing");var t=e.slice(2,r-2);return i+=2,u(t),e=e.slice(r),i+=2,n({type:"comment",comment:t})}}function v(){var n=c(),r=s(y);if(r){if(h(),!s(d))return a("property missing ':'");var t=s(w),e=n({type:"declaration",property:b(r[0].replace(m,x)),value:t?b(t[0].replace(m,x)):x});return s(A),e}}return f.prototype.content=e,l(),function(){var n,r=[];for(p(r);n=v();)!1!==n&&(r.push(n),p(r));return r}()}var m=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,g=/\n/g,n=/^\s*/,y=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,d=/^:\s*/,w=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,A=/^[;\s]*/,r=/^\s+|\s+$/g,x="";function b(n){return n?n.replace(r,x):x}return function(n,r){var t,e=null;if(!n||"string"!=typeof n)return e;for(var o,i,u=s(n),c="function"==typeof r,f=0,a=u.length;f<a;f++)o=(t=u[f]).property,i=t.value,c?r(o,i,t):i&&((e=e||{})[o]=i);return e}});
|
|
2
2
|
//# sourceMappingURL=style-to-object.min.js.map
|
|
@@ -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;\n"],"names":["
|
|
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;\n"],"names":["style","options","TypeError","lineno","column","updatePosition","str","lines","match","NEWLINE_REGEX","length","i","lastIndexOf","position","start","line","node","Position","whitespace","this","end","source","error","msg","err","Error","reason","filename","silent","re","m","exec","slice","WHITESPACE_REGEX","comments","rules","c","comment","push","pos","charAt","EMPTY_STRING","type","declaration","prop","PROPERTY_REGEX","COLON_REGEX","val","VALUE_REGEX","ret","property","trim","replace","COMMENT_REGEX","value","SEMICOLON_REGEX","prototype","content","decl","decls","declarations","TRIM_REGEX","iterator","output","parse","hasIterator","len"],"mappings":"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"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses inline style to object.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* import StyleToObject from 'style-to-object';
|
|
6
|
+
* StyleToObject('line-height: 42;');
|
|
7
|
+
*/
|
|
8
|
+
declare function StyleToObject(
|
|
9
|
+
style: string,
|
|
10
|
+
iterator?: StyleToObject.Iterator
|
|
11
|
+
): { [name: string]: string } | null;
|
|
12
|
+
|
|
13
|
+
export = StyleToObject;
|
|
14
|
+
|
|
15
|
+
declare namespace StyleToObject {
|
|
16
|
+
interface DeclarationPos {
|
|
17
|
+
line: number;
|
|
18
|
+
column: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
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
|
+
}
|
|
32
|
+
|
|
33
|
+
type Iterator = (
|
|
34
|
+
property: string,
|
|
35
|
+
value: string,
|
|
36
|
+
declaration: Declaration
|
|
37
|
+
) => void;
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "style-to-object",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Converts inline style to object.",
|
|
5
5
|
"author": "Mark <mark@remarkablemark.org>",
|
|
6
6
|
"main": "index.js",
|
|
7
|
+
"types": "index.d.ts",
|
|
7
8
|
"scripts": {
|
|
8
|
-
"build": "
|
|
9
|
+
"build": "run-s build:*",
|
|
9
10
|
"build:min": "NODE_ENV=production rollup --config --file dist/style-to-object.min.js --sourcemap",
|
|
10
11
|
"build:unmin": "NODE_ENV=development rollup --config --file dist/style-to-object.js",
|
|
11
12
|
"clean": "rm -rf dist",
|
|
12
13
|
"coveralls": "nyc report --reporter=text-lcov | coveralls",
|
|
13
14
|
"lint": "eslint --ignore-path .gitignore .",
|
|
14
15
|
"lint:fix": "npm run lint -- --fix",
|
|
15
|
-
"
|
|
16
|
+
"lint:dts": "dtslint .",
|
|
17
|
+
"prepublishOnly": "run-s lint lint:dts test clean build",
|
|
16
18
|
"release": "standard-version --no-verify",
|
|
17
19
|
"test": "mocha",
|
|
18
20
|
"test:coverage": "nyc npm test",
|
|
@@ -39,24 +41,27 @@
|
|
|
39
41
|
"inline-style-parser": "0.1.1"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
|
-
"@commitlint/cli": "^8.
|
|
43
|
-
"@commitlint/config-conventional": "^8.
|
|
44
|
-
"coveralls": "^3.0.
|
|
45
|
-
"
|
|
46
|
-
"eslint
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
44
|
+
"@commitlint/cli": "^8.2.0",
|
|
45
|
+
"@commitlint/config-conventional": "^8.2.0",
|
|
46
|
+
"coveralls": "^3.0.7",
|
|
47
|
+
"dtslint": "^1.0.3",
|
|
48
|
+
"eslint": "^6.6.0",
|
|
49
|
+
"eslint-plugin-prettier": "^3.1.1",
|
|
50
|
+
"husky": "^3.0.9",
|
|
51
|
+
"lint-staged": "^9.4.2",
|
|
52
|
+
"mocha": "^6.2.2",
|
|
53
|
+
"npm-run-all": "^4.1.5",
|
|
50
54
|
"nyc": "^14.1.1",
|
|
51
55
|
"prettier": "^1.18.2",
|
|
52
|
-
"rollup": "^1.
|
|
53
|
-
"rollup-plugin-commonjs": "^10.
|
|
54
|
-
"rollup-plugin-node-resolve": "^5.0
|
|
55
|
-
"rollup-plugin-uglify": "^6.0.
|
|
56
|
-
"standard-version": "^6
|
|
56
|
+
"rollup": "^1.26.3",
|
|
57
|
+
"rollup-plugin-commonjs": "^10.1.0",
|
|
58
|
+
"rollup-plugin-node-resolve": "^5.2.0",
|
|
59
|
+
"rollup-plugin-uglify": "^6.0.3",
|
|
60
|
+
"standard-version": "^6"
|
|
57
61
|
},
|
|
58
62
|
"files": [
|
|
59
|
-
"/dist"
|
|
63
|
+
"/dist",
|
|
64
|
+
"index.d.ts"
|
|
60
65
|
],
|
|
61
66
|
"license": "MIT"
|
|
62
67
|
}
|