Socket
Socket
Sign inDemoInstall

prefix

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prefix - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

.npmignore

70

index.js

@@ -1,5 +0,67 @@

function identity(x) { return x; }
var style = document.createElement('p').style
var prefixes = ['O', 'ms', 'Moz', 'Webkit']
var upper = /([A-Z])/g
var memo = {}
module.exports = identity;
module.exports.dash = identity;
module.exports.dash = identity;
/**
* 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
}
throw new Error('Unable to prefix ' + 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()
}
if (typeof module !== 'undefined' && module.exports){
module.exports = prefixMemozied
module.exports.dash = prefixDashed
}

16

package.json
{
"name": "prefix",
"version": "0.2.4",
"description": "prefix a css attribute",
"version": "0.2.5",
"description": "Prefix CSS attributes",
"dependencies": {},
"devDependencies": {
"mocha": "^2.2.5",
"serve": "jkroso/serve#1.5.1"
"mocha": "^2.4.5",
"serve": "jkroso/serve#1.6.7"
},
"repository": "git://github.com/jkroso/prefix.git",
"main": "index.js",
"browser": "browser.js",
"keywords": ["prefix"],
"keywords": [
"prefix"
],
"author": "Jake Rosoman",
"license": "MIT",
"files": ["index.js"]
"license": "MIT"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc