Comparing version 1.0.1 to 1.0.2
@@ -5,4 +5,6 @@ { | ||
"require-jsdoc": 0, | ||
"eqeqeq": 0 | ||
"eqeqeq": 0, | ||
"no-constant-condition": 0, | ||
"no-negated-condition": 0 | ||
} | ||
} |
{ | ||
"name": "tartan", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Library to render tartan pattern using its textual descriptor", | ||
@@ -5,0 +5,0 @@ "keywords": ["tartan", "scotland"], |
@@ -20,4 +20,4 @@ 'use strict'; | ||
source: source, | ||
offset: parseInt(offset) || 0, | ||
length: parseInt(length) || 0 | ||
offset: parseInt(offset, 10) || 0, | ||
length: parseInt(length, 10) || 0 | ||
}; | ||
@@ -24,0 +24,0 @@ } |
'use strict'; | ||
var pattern1 = /^([a-z])#([0-9a-f]{6})/im; | ||
var pattern2 = /^([a-z])#([0-9a-f]{3})/im; | ||
var pattern1 = /^([a-z])#([0-9a-f]{6})/i; | ||
var pattern2 = /^([a-z])#([0-9a-f]{3})/i; | ||
@@ -20,3 +20,3 @@ function parser(str, offset) { | ||
length: matches[0].length | ||
} | ||
}; | ||
} | ||
@@ -33,3 +33,3 @@ | ||
length: matches[0].length | ||
} | ||
}; | ||
} | ||
@@ -36,0 +36,0 @@ } |
@@ -14,3 +14,3 @@ 'use strict'; | ||
// whitespaces - we'll capture them on next turn | ||
var matches = /^\s+/im.exec(str.substr(offset, 10)); | ||
var matches = /^\s+/i.exec(str.substr(offset, 10)); | ||
if (matches) { | ||
@@ -21,3 +21,3 @@ return { | ||
length: matches[0].length | ||
} | ||
}; | ||
} | ||
@@ -43,5 +43,21 @@ } | ||
tokens: tokens | ||
} | ||
}; | ||
} | ||
function executeParsers(str, parsers, offset, result) { | ||
_.each(parsers, function(parser) { | ||
var token = parser(str, offset); | ||
if (_.isObject(token)) { | ||
if (token.token != 'space') { | ||
token.source = str; | ||
result.push(token); | ||
} | ||
offset = token.offset + token.length; | ||
return false; | ||
} | ||
}); | ||
return offset; | ||
} | ||
function factory(parsers, processors, defaultColors) { | ||
@@ -59,14 +75,5 @@ parsers = _.filter(parsers, _.isFunction); | ||
var offset = 0; | ||
while (offset < str.length) { | ||
_.each(parsers, function(parser) { | ||
var token = parser(str, offset); | ||
if (_.isObject(token)) { | ||
if (token.token != 'space') { | ||
token.source = str; | ||
result.push(token); | ||
} | ||
offset = token.offset + token.length; | ||
return false; | ||
} | ||
}); | ||
offset = executeParsers(str, parsers, offset, result); | ||
} | ||
@@ -73,0 +80,0 @@ |
'use strict'; | ||
var pattern = /^([a-z])\/([0-9]+)/im; | ||
var errors = require('../errors'); | ||
var pattern = /^([a-z])\/([0-9]+)/i; | ||
function parser(str, offset) { | ||
@@ -19,3 +21,3 @@ // Hope nobody will try to add stripe with 1e8 lines... | ||
length: matches[0].length | ||
} | ||
}; | ||
} | ||
@@ -22,0 +24,0 @@ } |
@@ -10,3 +10,3 @@ 'use strict'; | ||
length: 1 | ||
} | ||
}; | ||
} | ||
@@ -13,0 +13,0 @@ } |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var pattern = /^([a-z])([0-9]+)/im; | ||
var pattern = /^([a-z])([0-9]+)/i; | ||
@@ -22,3 +22,3 @@ function parser(str, offset) { | ||
length: matches[0].length | ||
} | ||
}; | ||
} | ||
@@ -25,0 +25,0 @@ } |
@@ -12,3 +12,3 @@ 'use strict'; | ||
}); | ||
} | ||
}; | ||
} | ||
@@ -15,0 +15,0 @@ |
@@ -126,10 +126,23 @@ 'use strict'; | ||
function optimize(tokens) { | ||
var flag = true; | ||
function executeProcessors(tokens, processors) { | ||
var temp; | ||
var flag = false; | ||
_.each(processors, function(processor) { | ||
temp = processor(tokens); | ||
// If processor returned array and it is not source array - | ||
// decide that is contains modified data. Once all processors | ||
// did not perform any actions - break `while` loop | ||
if (_.isArray(temp) && (temp !== tokens)) { | ||
tokens = temp; | ||
flag = true; | ||
} | ||
}); | ||
return flag ? tokens : false; | ||
} | ||
function optimize(tokens) { | ||
tokens = _.filter(tokens, _.isObject); | ||
// Run `removeZeroWidthStripes` only once | ||
temp = removeZeroWidthStripes(tokens); | ||
var temp = removeZeroWidthStripes(tokens); | ||
if (temp) { | ||
@@ -139,14 +152,9 @@ tokens = temp; | ||
while (flag) { | ||
flag = false; | ||
_.each(processors, function(processor) { | ||
temp = processor(tokens); | ||
// If processor returned array and it is not source array - | ||
// decide that is contains modified data. Once all processors | ||
// did not perform any actions - break `while` loop | ||
if (_.isArray(temp) && (temp !== tokens)) { | ||
tokens = temp; | ||
flag = true; | ||
} | ||
}); | ||
while (true) { | ||
temp = executeProcessors(tokens, processors); | ||
if (_.isArray(temp)) { | ||
tokens = temp; | ||
} else { | ||
break; | ||
} | ||
} | ||
@@ -153,0 +161,0 @@ |
@@ -66,4 +66,4 @@ 'use strict'; | ||
return function(tokens) { | ||
return convertPivotsToSquareBraces(tokens, options) | ||
return convertPivotsToSquareBraces(tokens, options); | ||
}; | ||
}; |
'use strict'; | ||
var _ = require('lodash'); | ||
var pivotsToSquareBraces = require('./pivots-to-square-braces'); | ||
@@ -4,0 +6,0 @@ |
@@ -9,3 +9,3 @@ 'use strict'; | ||
function trim(str) { | ||
return str.replace(/^\s+/im, '').replace(/\s+$/im, ''); | ||
return str.replace(/^\s+/i, '').replace(/\s+$/i, ''); | ||
} | ||
@@ -33,3 +33,3 @@ | ||
tokens = tokens.replace(/\[\s/img, '[').replace(/\s\]/img, ']'); | ||
tokens = tokens.replace(/\[\s/ig, '[').replace(/\s\]/ig, ']'); | ||
@@ -45,5 +45,5 @@ return trim(colors + '\n' + tokens); | ||
return render(tokens, _.extend({}, colors), options); | ||
} | ||
}; | ||
} | ||
module.exports = factory; |
@@ -22,7 +22,7 @@ 'use strict'; | ||
} else { | ||
return; | ||
return null; | ||
} | ||
} | ||
if (token.count <= 0) { | ||
return; | ||
return null; | ||
} | ||
@@ -35,3 +35,3 @@ // Try to find color | ||
} else { | ||
return; | ||
return null; | ||
} | ||
@@ -43,3 +43,3 @@ } | ||
} else { | ||
return; | ||
return null; | ||
} | ||
@@ -64,5 +64,5 @@ } | ||
return render(tokens, _.extend({}, defaultColors, colors), options); | ||
} | ||
}; | ||
} | ||
module.exports = factory; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var pattern = /^#[0-9a-f]{3}([0-9a-f]{3})?$/im; | ||
var pattern = /^#[0-9a-f]{3}([0-9a-f]{3})?$/i; | ||
@@ -8,0 +8,0 @@ module.exports = function(str) { |
'use strict'; | ||
var _ = require('lodash'); | ||
var isValidColor = require('./is-valid-color'); | ||
module.exports = function(colors) { | ||
var pattern = /^[a-z]$/im; | ||
var pattern = /^[a-z]$/i; | ||
@@ -13,6 +14,7 @@ return _.chain(colors) | ||
if (value.length == 4) { | ||
value = value.replace(/[0-9a-f]/g, '$&$&'); | ||
value = value.replace(/[0-9a-f]/ig, '$&$&'); | ||
} | ||
return [key.toUpperCase(), value.toLowerCase()]; | ||
} | ||
return null; | ||
}) | ||
@@ -19,0 +21,0 @@ .filter() |
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
32047
909