Comparing version 1.0.4 to 1.0.5
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } | ||
var _colourNames = require('./lib/colourNames'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _colourNames2 = _interopRequireDefault(_colourNames); | ||
var _libColourNames = require('./lib/colourNames'); | ||
var _toShorthand = require('./lib/toShorthand'); | ||
var _libColourNames2 = _interopRequireDefault(_libColourNames); | ||
var _toShorthand2 = _interopRequireDefault(_toShorthand); | ||
var _libToShorthand = require('./lib/toShorthand'); | ||
var _colourType = require('./lib/colourType'); | ||
var _libToShorthand2 = _interopRequireDefault(_libToShorthand); | ||
var ctype = _interopRequireWildcard(_colourType); | ||
var _libColourType = require('./lib/colourType'); | ||
var ctype = _interopRequireWildcard(_libColourType); | ||
var _color = require('color'); | ||
@@ -27,12 +21,16 @@ | ||
var _libStripWhitespace = require('./lib/stripWhitespace'); | ||
var _stripWhitespace = require('./lib/stripWhitespace'); | ||
var _libStripWhitespace2 = _interopRequireDefault(_libStripWhitespace); | ||
var _stripWhitespace2 = _interopRequireDefault(_stripWhitespace); | ||
var _libTrimLeadingZero = require('./lib/trimLeadingZero'); | ||
var _trimLeadingZero = require('./lib/trimLeadingZero'); | ||
var _libTrimLeadingZero2 = _interopRequireDefault(_libTrimLeadingZero); | ||
var _trimLeadingZero2 = _interopRequireDefault(_trimLeadingZero); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var filterColor = function filterColor(callback) { | ||
return Object.keys(_libColourNames2['default']).filter(callback); | ||
return Object.keys(_colourNames2.default).filter(callback); | ||
}; | ||
@@ -43,5 +41,5 @@ var shorter = function shorter(a, b) { | ||
exports['default'] = function (colour) { | ||
exports.default = function (colour) { | ||
if (ctype.isRGBorHSL(colour)) { | ||
var c = (0, _color2['default'])(colour); | ||
var c = (0, _color2.default)(colour); | ||
if (c.alpha() === 1) { | ||
@@ -57,13 +55,13 @@ // At full alpha, just use hex | ||
var rgba = c.rgbString(); | ||
return (0, _libTrimLeadingZero2['default'])((0, _libStripWhitespace2['default'])(hsla.length < rgba.length ? hsla : rgba)); | ||
return (0, _trimLeadingZero2.default)((0, _stripWhitespace2.default)(hsla.length < rgba.length ? hsla : rgba)); | ||
} | ||
} | ||
if (ctype.isHex(colour)) { | ||
colour = (0, _libToShorthand2['default'])(colour.toLowerCase()); | ||
colour = (0, _toShorthand2.default)(colour.toLowerCase()); | ||
var keyword = filterColor(function (key) { | ||
return _libColourNames2['default'][key] === colour; | ||
return _colourNames2.default[key] === colour; | ||
})[0]; | ||
return shorter(keyword, colour); | ||
} else if (ctype.isKeyword(colour)) { | ||
var hex = _libColourNames2['default'][filterColor(function (k) { | ||
var hex = _colourNames2.default[filterColor(function (k) { | ||
return k === colour.toLowerCase(); | ||
@@ -70,0 +68,0 @@ })[0]]; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _cssColorNames = require('css-color-names'); | ||
@@ -17,6 +13,8 @@ | ||
Object.keys(_cssColorNames2['default']).forEach(function (c) { | ||
return _cssColorNames2['default'][c] = (0, _toShorthand2['default'])(_cssColorNames2['default'][c]); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
Object.keys(_cssColorNames2.default).forEach(function (c) { | ||
return _cssColorNames2.default[c] = (0, _toShorthand2.default)(_cssColorNames2.default[c]); | ||
}); | ||
exports['default'] = _cssColorNames2['default']; | ||
exports.default = _cssColorNames2.default; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
exports.isKeyword = exports.isRGBorHSL = exports.isHex = undefined; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _colourNames = require('./colourNames'); | ||
@@ -17,5 +14,7 @@ | ||
var isHex = function isHex(colour) { | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var isHex = exports.isHex = function isHex(colour) { | ||
if (colour[0] === '#') { | ||
var c = (0, _toLonghand2['default'])(colour).substring(1); | ||
var c = (0, _toLonghand2.default)(colour).substring(1); | ||
return c.length === 6 && !isNaN(parseInt(c, 16)); | ||
@@ -26,4 +25,3 @@ } | ||
exports.isHex = isHex; | ||
var isRGBorHSL = function isRGBorHSL(colour) { | ||
var isRGBorHSL = exports.isRGBorHSL = function isRGBorHSL(colour) { | ||
return (/^(rgb|hsl)a?\(.*?\)/.test(colour) | ||
@@ -33,6 +31,4 @@ ); | ||
exports.isRGBorHSL = isRGBorHSL; | ||
var isKeyword = function isKeyword(colour) { | ||
return ~Object.keys(_colourNames2['default']).indexOf(colour.toLowerCase()); | ||
}; | ||
exports.isKeyword = isKeyword; | ||
var isKeyword = exports.isKeyword = function isKeyword(colour) { | ||
return ~Object.keys(_colourNames2.default).indexOf(colour.toLowerCase()); | ||
}; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
exports['default'] = function (str) { | ||
exports.default = function (str) { | ||
return str.replace(/\s/g, ''); | ||
@@ -9,0 +7,0 @@ }; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
exports['default'] = function (hex) { | ||
var h = hex.substring(1); | ||
var r = h[0]; | ||
var g = h[1]; | ||
var b = h[2]; | ||
return h.length === 3 && '#' + r + r + g + g + b + b || hex; | ||
exports.default = function (hex) { | ||
if (hex.length !== 4) { | ||
return hex; | ||
} | ||
var r = hex[1]; | ||
var g = hex[2]; | ||
var b = hex[3]; | ||
return '#' + r + r + g + g + b + b; | ||
}; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
exports['default'] = function (hex) { | ||
if (hex[1] === hex[2] && hex[3] === hex[4] && hex[5] === hex[6]) { | ||
exports.default = function (hex) { | ||
if (hex.length === 7 && hex[1] === hex[2] && hex[3] === hex[4] && hex[5] === hex[6]) { | ||
return '#' + hex[2] + hex[4] + hex[6]; | ||
@@ -10,0 +8,0 @@ } |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
exports['default'] = function (str) { | ||
exports.default = function (str) { | ||
return str.replace(/([^\d])0(\.\d*)/g, '$1$2'); | ||
@@ -9,0 +7,0 @@ }; |
{ | ||
"name": "colormin", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Turn a CSS color into its smallest representation.", | ||
@@ -11,5 +11,5 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"prepublish": "babel src --out-dir dist --ignore /__tests__/", | ||
"test-unformatted": "babel-tape-runner \"src/**/__tests__/*.js\"", | ||
"test": "npm run test-unformatted | faucet" | ||
"lint": "eslint src", | ||
"prepublish": "de dist && babel src --out-dir dist --ignore /__tests__/", | ||
"test": "npm run lint && babel src --out-dir dist && ava dist/__tests__" | ||
}, | ||
@@ -32,11 +32,15 @@ "homepage": "https://github.com/ben-eb/colormin", | ||
"color": "^0.10.1", | ||
"css-color-names": "0.0.1" | ||
"css-color-names": "0.0.3" | ||
}, | ||
"devDependencies": { | ||
"babel": "^5.8.20", | ||
"babel-tape-runner": "^1.1.0", | ||
"faucet": "0.0.1", | ||
"tape": "^4.0.1" | ||
"ava": "sindresorhus/ava#945dbea40a6a500a24d54ebcc7e10dcd75647fc7", | ||
"babel-cli": "^6.3.17", | ||
"babel-core": "^6.3.26", | ||
"babel-plugin-add-module-exports": "^0.1.2", | ||
"babel-preset-es2015-loose": "^6.1.4", | ||
"babel-preset-stage-0": "^6.3.13", | ||
"del-cli": "^0.1.2", | ||
"eslint": "^1.10.3" | ||
}, | ||
"repository": "ben-eb/colormin" | ||
} |
@@ -13,2 +13,3 @@ # colormin [![Build Status](https://travis-ci.org/ben-eb/colormin.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/colormin.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/colormin.svg)][deps] | ||
## Example | ||
@@ -24,5 +25,6 @@ | ||
colormin works for rgb, rgba, hsl, hsla, hex & css color keywords. See more | ||
example output in the [tests](test.js). Note that colormin does not convert | ||
invalid CSS colors; it is not a color validator itself. | ||
example output in the [tests](src/__tests__/index.js). Note that colormin does | ||
not convert invalid CSS colors, as it is not a color validator. | ||
## Contributing | ||
@@ -33,2 +35,3 @@ | ||
## License | ||
@@ -35,0 +38,0 @@ |
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
41
8075
8
114
+ Addedcss-color-names@0.0.3(transitive)
- Removedcss-color-names@0.0.1(transitive)
Updatedcss-color-names@0.0.3