Skip to content

Commit

Permalink
Put the named color map in a variable (saves 37 bytes).
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Mar 2, 2012
1 parent b991fcc commit 4371f83
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/color-namedColors.js
@@ -1,4 +1,5 @@
ONECOLOR.namedColors = { /*global namedColors*/
namedColors = {
aliceblue: '#f0f8ff', aliceblue: '#f0f8ff',
antiquewhite: '#faebd7', antiquewhite: '#faebd7',
aqua: '#00ffff', aqua: '#00ffff',
Expand Down
9 changes: 4 additions & 5 deletions lib/color.js
@@ -1,4 +1,5 @@
var installedColorSpaces = [], var installedColorSpaces = [],
namedColors = {},
channelRegExp = /\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/, channelRegExp = /\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/,
alphaChannelRegExp = /\s*(\.\d+|\d+(?:\.\d+)?)\s*/, alphaChannelRegExp = /\s*(\.\d+|\d+(?:\.\d+)?)\s*/,
cssColorRegExp = new RegExp( cssColorRegExp = new RegExp(
Expand All @@ -20,11 +21,9 @@ function ONECOLOR (obj) {
return new ONECOLOR[obj[0]](obj.slice(1, obj.length)); return new ONECOLOR[obj[0]](obj.slice(1, obj.length));
} }
} else if (obj.charCodeAt) { } else if (obj.charCodeAt) {
if (ONECOLOR.namedColors) { var lowerCased = obj.toLowerCase();
var lowerCased = obj.toLowerCase(); if (namedColors[lowerCased]) {
if (ONECOLOR.namedColors[lowerCased]) { obj = namedColors[lowerCased];
obj = ONECOLOR.namedColors[lowerCased];
}
} }
// Test for CSS rgb(....) string // Test for CSS rgb(....) string
var matchCssSyntax = obj.match(cssColorRegExp); var matchCssSyntax = obj.match(cssColorRegExp);
Expand Down
2 changes: 1 addition & 1 deletion lib/color/_all.js
Expand Up @@ -2,10 +2,10 @@


// This file is purely for the build system // This file is purely for the build system
one.include('lib:color.js'); one.include('lib:color.js');
one.include('lib:color-namedColors.js');
one.include('lib:color/HSV.js'); one.include('lib:color/HSV.js');
one.include('lib:color/HSL.js'); one.include('lib:color/HSL.js');
one.include('lib:color/CMYK.js'); one.include('lib:color/CMYK.js');
one.include('lib:color-namedColors.js');


// Convenience functions // Convenience functions
one.include('lib:color/plugins/clearer.js'); one.include('lib:color/plugins/clearer.js');
Expand Down

0 comments on commit 4371f83

Please sign in to comment.