string-template
Advanced tools
Comparing version 0.2.1 to 1.0.0
@@ -27,3 +27,3 @@ var template = require("./index") | ||
function compile(string, inline) { | ||
var replacements = string.match(nargs) | ||
var replacements = string.match(nargs) || [] | ||
var interleave = string.split(nargs) | ||
@@ -33,4 +33,4 @@ var replace = [] | ||
for (var i = 0; i < interleave.length; i++) { | ||
var current = interleave[i]; | ||
var replacement = replacements[i]; | ||
var current = interleave[i] | ||
var replacement = replacements[i] | ||
var escapeLeft = current.charAt(current.length - 1) | ||
@@ -46,3 +46,3 @@ var escapeRight = (interleave[i + 1] || "").charAt(0) | ||
} else { | ||
replace.push(current); | ||
replace.push(current) | ||
if (replacement) { | ||
@@ -122,5 +122,4 @@ replace.push({ name: replacement }) | ||
function escape(string) { | ||
string = '' + string; | ||
return string.replace(whitespaceRegex, escapedWhitespace); | ||
string = '' + string | ||
return string.replace(whitespaceRegex, escapedWhitespace) | ||
} | ||
@@ -127,0 +126,0 @@ |
@@ -1,3 +0,2 @@ | ||
var nargs = /\{([0-9a-zA-Z]+)\}/g | ||
var slice = Array.prototype.slice | ||
var nargs = /\{([0-9a-zA-Z_]+)\}/g | ||
@@ -12,3 +11,6 @@ module.exports = template | ||
} else { | ||
args = slice.call(arguments, 1) | ||
args = new Array(arguments.length - 1) | ||
for (var i = 1; i < arguments.length; ++i) { | ||
args[i - 1] = arguments[i] | ||
} | ||
} | ||
@@ -15,0 +17,0 @@ |
{ | ||
"name": "string-template", | ||
"version": "0.2.1", | ||
"version": "1.0.0", | ||
"description": "A simple string template function based on named or indexed arguments", | ||
@@ -27,10 +27,7 @@ "keywords": [ | ||
"devDependencies": { | ||
"istanbul": "^0.4.1", | ||
"opn": "^3.0.3", | ||
"tape": "~1.1.1" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://github.com/Matt-Esch/string-template/raw/master/LICENSE" | ||
} | ||
], | ||
"license": "MIT", | ||
"scripts": { | ||
@@ -40,3 +37,3 @@ "test": "node ./test/index.js", | ||
"cover": "istanbul cover --report none --print detail ./test/index.js", | ||
"view-cover": "istanbul report html && google-chrome ./coverage/index.html" | ||
"view-cover": "istanbul report html && opn --no-wait ./coverage/index.html" | ||
}, | ||
@@ -43,0 +40,0 @@ "testling": { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
78908
17
562
0
3
2