style-to-js
Advanced tools
Comparing version 1.1.7 to 1.1.8
@@ -5,3 +5,7 @@ import { CamelCaseOptions } from './utilities'; | ||
} | ||
/** | ||
* Parses CSS inline style to JavaScript object (camelCased). | ||
*/ | ||
export default function StyleToJS(style: string, options?: StyleToJSOptions): StyleObject; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -8,2 +8,5 @@ "use strict"; | ||
var utilities_1 = require("./utilities"); | ||
/** | ||
* Parses CSS inline style to JavaScript object (camelCased). | ||
*/ | ||
function StyleToJS(style, options) { | ||
@@ -15,2 +18,3 @@ var output = {}; | ||
(0, style_to_object_1.default)(style, function (property, value) { | ||
// skip CSS comment | ||
if (property && value) { | ||
@@ -23,1 +27,2 @@ output[(0, utilities_1.camelCase)(property, options)] = value; | ||
exports.default = StyleToJS; | ||
//# sourceMappingURL=index.js.map |
@@ -0,4 +1,11 @@ | ||
/** | ||
* CamelCase options. | ||
*/ | ||
export interface CamelCaseOptions { | ||
reactCompat?: boolean; | ||
} | ||
/** | ||
* CamelCases a CSS property. | ||
*/ | ||
export declare const camelCase: (property: string, options?: CamelCaseOptions) => string; | ||
//# sourceMappingURL=utilities.d.ts.map |
@@ -9,2 +9,5 @@ "use strict"; | ||
var MS_VENDOR_PREFIX_REGEX = /^-(ms)-/; | ||
/** | ||
* Checks whether to skip camelCase. | ||
*/ | ||
var skipCamelCase = function (property) { | ||
@@ -15,6 +18,15 @@ return !property || | ||
}; | ||
/** | ||
* Replacer that capitalizes first character. | ||
*/ | ||
var capitalize = function (match, character) { | ||
return character.toUpperCase(); | ||
}; | ||
/** | ||
* Replacer that removes beginning hyphen of vendor prefix property. | ||
*/ | ||
var trimHyphen = function (match, prefix) { return "".concat(prefix, "-"); }; | ||
/** | ||
* CamelCases a CSS property. | ||
*/ | ||
var camelCase = function (property, options) { | ||
@@ -27,5 +39,7 @@ if (options === void 0) { options = {}; } | ||
if (options.reactCompat) { | ||
// `-ms` vendor prefix should not be capitalized | ||
property = property.replace(MS_VENDOR_PREFIX_REGEX, trimHyphen); | ||
} | ||
else { | ||
// for non-React, remove first hyphen so vendor prefix is not capitalized | ||
property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen); | ||
@@ -36,1 +50,2 @@ } | ||
exports.camelCase = camelCase; | ||
//# sourceMappingURL=utilities.js.map |
{ | ||
"name": "style-to-js", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "Parses CSS inline style to JavaScript object (camelCased).", | ||
@@ -19,4 +19,5 @@ "author": "Mark <mark@remarkablemark.org>", | ||
"postpublish": "pinst --enable", | ||
"prepublishOnly": "pinst --disable && npm run lint && npm test && npm run clean && npm run build", | ||
"test": "jest --coverage --colors", | ||
"prepublishOnly": "pinst --disable && npm run lint && npm run test:ci && npm run clean && npm run build", | ||
"test": "jest", | ||
"test:ci": "CI=true jest --ci --colors --coverage", | ||
"test:watch": "jest --watch" | ||
@@ -47,2 +48,3 @@ }, | ||
"@rollup/plugin-node-resolve": "15.2.3", | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"@rollup/plugin-typescript": "11.1.5", | ||
@@ -59,4 +61,3 @@ "@types/jest": "29.5.6", | ||
"prettier": "3.0.3", | ||
"rollup": "2.79.1", | ||
"rollup-plugin-terser": "7.0.2", | ||
"rollup": "4.1.4", | ||
"ts-jest": "29.1.1", | ||
@@ -67,2 +68,3 @@ "typescript": "5.2.2" | ||
"cjs/", | ||
"src/", | ||
"umd/" | ||
@@ -69,0 +71,0 @@ ], |
@@ -320,2 +320,5 @@ (function (global, factory) { | ||
var MS_VENDOR_PREFIX_REGEX = /^-(ms)-/; | ||
/** | ||
* Checks whether to skip camelCase. | ||
*/ | ||
var skipCamelCase = function (property) { | ||
@@ -326,6 +329,15 @@ return !property || | ||
}; | ||
/** | ||
* Replacer that capitalizes first character. | ||
*/ | ||
var capitalize = function (match, character) { | ||
return character.toUpperCase(); | ||
}; | ||
/** | ||
* Replacer that removes beginning hyphen of vendor prefix property. | ||
*/ | ||
var trimHyphen = function (match, prefix) { return "".concat(prefix, "-"); }; | ||
/** | ||
* CamelCases a CSS property. | ||
*/ | ||
var camelCase = function (property, options) { | ||
@@ -338,5 +350,7 @@ if (options === void 0) { options = {}; } | ||
if (options.reactCompat) { | ||
// `-ms` vendor prefix should not be capitalized | ||
property = property.replace(MS_VENDOR_PREFIX_REGEX, trimHyphen); | ||
} | ||
else { | ||
// for non-React, remove first hyphen so vendor prefix is not capitalized | ||
property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen); | ||
@@ -347,2 +361,5 @@ } | ||
/** | ||
* Parses CSS inline style to JavaScript object (camelCased). | ||
*/ | ||
function StyleToJS(style, options) { | ||
@@ -354,2 +371,3 @@ var output = {}; | ||
StyleToObject(style, function (property, value) { | ||
// skip CSS comment | ||
if (property && value) { | ||
@@ -356,0 +374,0 @@ output[camelCase(property, options)] = value; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59854
19
671