quick-format-unescaped
Advanced tools
Comparing version 4.0.0 to 4.0.1
15
index.js
@@ -11,5 +11,2 @@ 'use strict' | ||
var offset = 1 | ||
if (typeof f !== 'string') { | ||
return f | ||
} | ||
if (typeof f === 'object' && f !== null) { | ||
@@ -25,2 +22,5 @@ var len = args.length + offset | ||
} | ||
if (typeof f !== 'string') { | ||
return f | ||
} | ||
var argLen = args.length | ||
@@ -35,2 +35,3 @@ if (argLen === 0) return f | ||
if (f.charCodeAt(i) === 37 && i + 1 < flen) { | ||
lastPos = lastPos > -1 ? lastPos : 0 | ||
switch (f.charCodeAt(i + 1)) { | ||
@@ -97,12 +98,4 @@ case 100: // 'd' | ||
} | ||
while (a < argLen) { | ||
x = args[a++] | ||
if (x === null || (typeof x !== 'object')) { | ||
str += ' ' + String(x) | ||
} else { | ||
str += ' ' + ss(x) | ||
} | ||
} | ||
return str | ||
} |
{ | ||
"name": "quick-format-unescaped", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "Solves a problem with util.format", | ||
@@ -10,7 +10,9 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "node test" | ||
"test": "nyc -- node test", | ||
"test:html": "nyc --reporter=html -- node test" | ||
}, | ||
"author": "David Mark Clements", | ||
"devDependencies": { | ||
"fastbench": "^1.0.1" | ||
"fastbench": "^1.0.1", | ||
"nyc": "^15.0.0" | ||
}, | ||
@@ -17,0 +19,0 @@ "dependencies": {}, |
@@ -17,2 +17,7 @@ 'use strict'; | ||
const emptyObj = {} | ||
assert.equal(format(emptyObj, []), emptyObj) | ||
assert.equal(format(emptyObj, ['a', 'b', 'c']), '{} "b" "c" ') | ||
assert.equal(format('', ['a']), '') | ||
// ES6 Symbol handling | ||
@@ -45,2 +50,4 @@ const symbol = Symbol('foo') | ||
assert.equal(format('%d', ['42']), '42'); | ||
assert.equal(format('%d %d', ['42']), '42 %d'); | ||
assert.equal(format('foo %d', ['42']), 'foo 42'); | ||
assert.equal(format('%s', ['42']), '42'); | ||
@@ -60,3 +67,3 @@ // assert.equal(format('%j', ['42']), '"42"'); | ||
assert.equal(format('%s:%s', ['foo', 'bar']), 'foo:bar'); | ||
assert.equal(format('%s:%s', ['foo', 'bar', 'baz']), 'foo:bar baz'); | ||
assert.equal(format('%s:%s', ['foo', 'bar', 'baz']), 'foo:bar'); | ||
assert.equal(format('%s%s', []), '%s%s'); | ||
@@ -66,4 +73,22 @@ assert.equal(format('%s%s', [undefined]), 'undefined%s'); | ||
assert.equal(format('%s%s', ['foo', 'bar']), 'foobar'); | ||
assert.equal(format('%s%s', ['foo', 'bar', 'baz']), 'foobar baz'); | ||
assert.equal(format('%s%s', ['foo', 'bar', 'baz']), 'foobar'); | ||
assert.equal(format('foo %s', ['foo']), 'foo foo') | ||
assert.equal(format('foo %o', [{foo: 'foo'}]), 'foo {"foo":"foo"}') | ||
assert.equal(format('foo %O', [{foo: 'foo'}]), 'foo {"foo":"foo"}') | ||
assert.equal(format('foo %j', [{foo: 'foo'}]), 'foo {"foo":"foo"}') | ||
assert.equal(format('foo %j %j', [{foo: 'foo'}]), 'foo {"foo":"foo"} %j') | ||
assert.equal(format('foo %j', ['foo']), 'foo \'foo\'') // TODO: isn't this wrong? | ||
assert.equal(format('foo %j', [function foo () {}]), 'foo foo') | ||
assert.equal(format('foo %j', [function () {}]), 'foo <anonymous>') | ||
assert.equal(format('foo %j', [{foo: 'foo'}, 'not-printed']), 'foo {"foo":"foo"}') | ||
assert.equal( | ||
format('foo %j', [{ foo: 'foo' }], { stringify () { return 'REPLACED' } }), | ||
'foo REPLACED' | ||
) | ||
const circularObject = {} | ||
circularObject.foo = circularObject | ||
assert.equal(format('foo %j', [circularObject]), 'foo "[Circular]"') | ||
// // assert.equal(format(['%%%s%%', 'hi']), '%hi%'); | ||
@@ -77,1 +102,4 @@ // // assert.equal(format(['%%%s%%%%', 'hi']), '%hi%%'); | ||
// })(); | ||
assert.equal(format('%%', ['foo']), '%') | ||
assert.equal(format('foo %%', ['foo']), 'foo %') |
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
10356
199
2