hyphenate-style-name
Advanced tools
Comparing version 1.0.2 to 1.0.3
27
index.js
@@ -1,16 +0,19 @@ | ||
'use strict'; | ||
/* eslint-disable no-var, prefer-template */ | ||
var uppercasePattern = /[A-Z]/g | ||
var msPattern = /^ms-/ | ||
var cache = {} | ||
var uppercasePattern = /[A-Z]/g; | ||
var msPattern = /^ms-/; | ||
var cache = {}; | ||
function toHyphenLower(match) { | ||
return '-' + match.toLowerCase() | ||
} | ||
function hyphenateStyleName(string) { | ||
return string in cache | ||
? cache[string] | ||
: cache[string] = string | ||
.replace(uppercasePattern, '-$&') | ||
.toLowerCase() | ||
.replace(msPattern, '-ms-'); | ||
function hyphenateStyleName(name) { | ||
if (cache.hasOwnProperty(name)) { | ||
return cache[name] | ||
} | ||
var hName = name.replace(uppercasePattern, toHyphenLower) | ||
return (cache[name] = msPattern.test(hName) ? '-' + hName : hName) | ||
} | ||
module.exports = hyphenateStyleName; | ||
export default hyphenateStyleName |
{ | ||
"name": "hyphenate-style-name", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Hyphenates a camelcased CSS property name", | ||
"main": "index.js", | ||
"main": "index.cjs.js", | ||
"module": "index.js", | ||
"scripts": { | ||
"build": "rollup --input index.js --file index.cjs.js --format cjs", | ||
"coverage": "nyc tape -- test/**/*.test.js", | ||
"lint": "eslint .", | ||
"lint": "eslint . --ignore-path .gitignore", | ||
"test": "tape test/**/*.test.js", | ||
"pretest": "npm run lint" | ||
"precoverage": "npm run build", | ||
"pretest": "npm run lint && npm run build", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
@@ -29,7 +33,10 @@ "repository": { | ||
"devDependencies": { | ||
"eslint": "^3.8.1", | ||
"eslint-config-vaffel": "^5.0.0", | ||
"nyc": "^8.3.2", | ||
"eslint": "^4.6.0", | ||
"eslint-config-prettier": "^3.3.0", | ||
"eslint-config-sanity": "^0.140.0", | ||
"nyc": "^13.1.0", | ||
"prettier": "^1.15.2", | ||
"rollup": "^1.1.2", | ||
"tape": "^4.6.2" | ||
} | ||
} |
# hyphenate-style-name | ||
[![npm version](http://img.shields.io/npm/v/hyphenate-style-name.svg?style=flat-square)](http://browsenpm.org/package/hyphenate-style-name)[![Build Status](http://img.shields.io/travis/rexxars/hyphenate-style-name/master.svg?style=flat-square)](https://travis-ci.org/rexxars/hyphenate-style-name)[![Coverage Status](http://img.shields.io/codeclimate/coverage/github/rexxars/hyphenate-style-name.svg?style=flat-square)](https://codeclimate.com/github/rexxars/hyphenate-style-name)[![Code Climate](http://img.shields.io/codeclimate/github/rexxars/hyphenate-style-name.svg?style=flat-square)](https://codeclimate.com/github/rexxars/hyphenate-style-name/) | ||
[![npm version](http://img.shields.io/npm/v/hyphenate-style-name.svg?style=flat-square)](http://browsenpm.org/package/hyphenate-style-name)[![Build Status](http://img.shields.io/travis/rexxars/hyphenate-style-name/master.svg?style=flat-square)](https://travis-ci.org/rexxars/hyphenate-style-name) | ||
@@ -21,5 +21,5 @@ Hyphenates a camelcased CSS property name. For example: | ||
```js | ||
var hyphenateStyleName = require('hyphenate-style-name'); | ||
var hyphenateStyleName = require('hyphenate-style-name') | ||
console.log(hyphenateStyleName('MozTransition')); // -moz-transition | ||
console.log(hyphenateStyleName('MozTransition')) // -moz-transition | ||
``` | ||
@@ -26,0 +26,0 @@ |
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
82796
8
31
7