Comparing version 0.2.6 to 1.0.0
72
index.js
@@ -1,5 +0,69 @@ | ||
function identity(x) { return x; } | ||
// check document first so it doesn't error in node.js | ||
var style = typeof document != 'undefined' | ||
? document.createElement('p').style | ||
: {} | ||
module.exports = identity; | ||
module.exports.dash = identity; | ||
module.exports.dash = identity; | ||
var prefixes = ['O', 'ms', 'Moz', 'Webkit'] | ||
var upper = /([A-Z])/g | ||
var memo = {} | ||
/** | ||
* prefix `key` | ||
* | ||
* prefix('transform') // => WebkitTransform | ||
* | ||
* @param {String} key | ||
* @return {String} | ||
* @api public | ||
*/ | ||
function prefix(key){ | ||
// Camel case | ||
key = key.replace(/-([a-z])/g, function(_, char){ | ||
return char.toUpperCase() | ||
}) | ||
// Without prefix | ||
if (style[key] !== undefined) return key | ||
// With prefix | ||
var Key = key.charAt(0).toUpperCase() + key.slice(1) | ||
var i = prefixes.length | ||
while (i--) { | ||
var name = prefixes[i] + Key | ||
if (style[name] !== undefined) return name | ||
} | ||
return key | ||
} | ||
/** | ||
* Memoized version of `prefix` | ||
* | ||
* @param {String} key | ||
* @return {String} | ||
* @api public | ||
*/ | ||
function prefixMemozied(key){ | ||
return key in memo | ||
? memo[key] | ||
: memo[key] = prefix(key) | ||
} | ||
/** | ||
* Create a dashed prefix | ||
* | ||
* @param {String} key | ||
* @return {String} | ||
* @api public | ||
*/ | ||
function prefixDashed(key){ | ||
key = prefix(key) | ||
if (upper.test(key)) { | ||
key = '-' + key.replace(upper, '-$1') | ||
upper.lastIndex = 0 | ||
} | ||
return key.toLowerCase() | ||
} | ||
module.exports = prefixMemozied | ||
module.exports.dash = prefixDashed |
{ | ||
"name": "prefix", | ||
"version": "0.2.6", | ||
"description": "prefix a css attribute", | ||
"version": "1.0.0", | ||
"description": "Prefix CSS attributes", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"mocha": "^2.2.5", | ||
"mocha": "^2.4.5", | ||
"serve": "jkroso/serve#1.5.1" | ||
@@ -12,7 +12,5 @@ }, | ||
"main": "index.js", | ||
"browser": "browser.js", | ||
"keywords": ["prefix"], | ||
"author": "Jake Rosoman", | ||
"license": "MIT", | ||
"files": ["index.js"] | ||
"license": "MIT" | ||
} |
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5953
9
119
1
0