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.3 to 0.2.4

77

index.js

@@ -0,74 +1,5 @@

function identity(x) { return x; }
var style = document.createElement('p').style
var prefixes = 'O ms Moz Webkit'.split(' ')
var upper = /([A-Z])/g
var memo = {}
/**
* memoized `prefix`
*
* @param {String} key
* @return {String}
* @api public
*/
module.exports = exports = function(key){
return key in memo
? memo[key]
: memo[key] = prefix(key)
}
exports.prefix = prefix
exports.dash = dashedPrefix
/**
* 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 = capitalize(key)
var i = prefixes.length
while (i--) {
var name = prefixes[i] + Key
if (style[name] !== undefined) return name
}
throw new Error('unable to prefix ' + key)
}
function capitalize(str){
return str.charAt(0).toUpperCase() + str.slice(1)
}
/**
* create a dasherized prefix
*
* @param {String} key
* @return {String}
* @api public
*/
function dashedPrefix(key){
key = prefix(key)
if (upper.test(key)) {
key = '-' + key.replace(upper, '-$1')
upper.lastIndex = 0 // fix #1
}
return key.toLowerCase()
}
module.exports = identity;
module.exports.dash = identity;
module.exports.dash = identity;

4

package.json
{
"name": "prefix",
"version": "0.2.3",
"version": "0.2.4",
"description": "prefix a css attribute",

@@ -11,2 +11,4 @@ "dependencies": {},

"repository": "git://github.com/jkroso/prefix.git",
"main": "index.js",
"browser": "browser.js",
"keywords": ["prefix"],

@@ -13,0 +15,0 @@ "author": "Jake Rosoman",

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