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.6 to 1.0.0

.npmignore

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

10

package.json
{
"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"
}
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