quick-format
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -32,3 +32,4 @@ var safeStringify = require('fast-safe-stringify') | ||
str += f.slice(lastPos, i) | ||
str += Number(args[a++]) | ||
if (args[a] == null) break | ||
str += Number(args[a]) | ||
lastPos = i = i + 2 | ||
@@ -41,3 +42,4 @@ break | ||
str += f.slice(lastPos, i) | ||
x = JSON.stringify(ss(args[a++])) | ||
if (args[a] === undefined) break | ||
x = JSON.stringify(ss(args[a])) | ||
str += x.substr(1, x.length - 2) | ||
@@ -51,3 +53,3 @@ lastPos = i = i + 2 | ||
str += f.slice(lastPos, i) | ||
x = JSON.stringify(String(args[a++])) | ||
x = JSON.stringify(String(args[a])) | ||
str += x.substr(1, x.length - 2) | ||
@@ -63,2 +65,3 @@ lastPos = i = i + 2 | ||
} | ||
++a | ||
} | ||
@@ -65,0 +68,0 @@ ++i |
{ | ||
"name": "quick-format", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,50 +6,60 @@ 'use strict'; | ||
assert.equal(format([]), ''); | ||
assert.equal(format(['']), ''); | ||
assert.equal(format([[]]), '[]'); | ||
assert.equal(format([{}]), '{}'); | ||
assert.equal(format([null]), 'null'); | ||
assert.equal(format([true]), 'true'); | ||
assert.equal(format([false]), 'false'); | ||
assert.equal(format(['test']), 'test'); | ||
// assert.equal(format([]), ''); | ||
// assert.equal(format(['']), ''); | ||
// assert.equal(format([[]]), '[]'); | ||
// assert.equal(format([{}]), '{}'); | ||
// assert.equal(format([null]), 'null'); | ||
// assert.equal(format([true]), 'true'); | ||
// assert.equal(format([false]), 'false'); | ||
// assert.equal(format(['test']), 'test'); | ||
// // CHECKME this is for console.log() compatibility - but is it *right*? | ||
assert.equal(format(['foo', 'bar', 'baz']), 'foo bar baz'); | ||
// // // CHECKME this is for console.log() compatibility - but is it *right*? | ||
// assert.equal(format(['foo', 'bar', 'baz']), 'foo bar baz'); | ||
// ES6 Symbol handling | ||
// assert.equal(format([symbol]), 'Symbol(foo)'); | ||
// assert.equal(format(['foo', symbol]), 'foo Symbol(foo)'); | ||
// assert.equal(format(['%s', symbol]), 'Symbol(foo)'); | ||
// assert.equal(format(['%j', symbol]), 'undefined'); | ||
// assert.throws(function() { | ||
// format(['%d', symbol]); | ||
// }, TypeError); | ||
// // ES6 Symbol handling | ||
// // assert.equal(format([symbol]), 'Symbol(foo)'); | ||
// // assert.equal(format(['foo', symbol]), 'foo Symbol(foo)'); | ||
// // assert.equal(format(['%s', symbol]), 'Symbol(foo)'); | ||
// // assert.equal(format(['%j', symbol]), 'undefined'); | ||
// // assert.throws(function() { | ||
// // format(['%d', symbol]); | ||
// // }, TypeError); | ||
assert.equal(format(['%d', 42.0]), '42'); | ||
assert.equal(format(['%d', 42]), '42'); | ||
assert.equal(format(['%s', 42]), '42'); | ||
assert.equal(format(['%j', 42]), '42'); | ||
// assert.equal(format(['%d', 42.0]), '42'); | ||
// assert.equal(format(['%d', 42]), '42'); | ||
// assert.equal(format(['%s', 42]), '42'); | ||
// assert.equal(format(['%j', 42]), '42'); | ||
assert.equal(format(['%d', '42.0']), '42'); | ||
assert.equal(format(['%d', '42']), '42'); | ||
assert.equal(format(['%s', '42']), '42'); | ||
assert.equal(format(['%j', '42']), '"42"'); | ||
assert.equal(format(['%d', undefined]), '%d'); | ||
assert.equal(format(['%s', undefined]), 'undefined'); | ||
assert.equal(format(['%j', undefined]), '%j'); | ||
assert.equal(format(['%%s%s', 'foo']), '%sfoo'); | ||
assert.equal(format(['%s']), '%s'); | ||
assert.equal(format(['%s', undefined]), 'undefined'); | ||
assert.equal(format(['%s', 'foo']), 'foo'); | ||
assert.equal(format(['%s:%s']), '%s:%s'); | ||
assert.equal(format(['%s:%s', undefined]), 'undefined:%s'); | ||
assert.equal(format(['%s:%s', 'foo']), 'foo:%s'); | ||
assert.equal(format(['%s:%s', 'foo', 'bar']), 'foo:bar'); | ||
assert.equal(format(['%s:%s', 'foo', 'bar', 'baz']), 'foo:bar baz'); | ||
// assert.equal(format(['%%%s%%', 'hi']), '%hi%'); | ||
// assert.equal(format(['%%%s%%%%', 'hi']), '%hi%%'); | ||
assert.equal(format(['%d', null]), '%d'); | ||
assert.equal(format(['%s', null]), 'null'); | ||
assert.equal(format(['%j', null]), 'null'); | ||
(function() { | ||
var o = {}; | ||
o.o = o; | ||
assert.equal(format(['%j', o]), '[Circular]'); | ||
})(); | ||
// assert.equal(format(['%d', '42.0']), '42'); | ||
// assert.equal(format(['%d', '42']), '42'); | ||
// assert.equal(format(['%s', '42']), '42'); | ||
// assert.equal(format(['%j', '42']), '"42"'); | ||
// assert.equal(format(['%%s%s', 'foo']), '%sfoo'); | ||
// assert.equal(format(['%s']), '%s'); | ||
// assert.equal(format(['%s', undefined]), 'undefined'); | ||
// assert.equal(format(['%s', 'foo']), 'foo'); | ||
// assert.equal(format(['%s:%s']), '%s:%s'); | ||
// assert.equal(format(['%s:%s', undefined]), 'undefined:%s'); | ||
// assert.equal(format(['%s:%s', 'foo']), 'foo:%s'); | ||
// assert.equal(format(['%s:%s', 'foo', 'bar']), 'foo:bar'); | ||
// assert.equal(format(['%s:%s', 'foo', 'bar', 'baz']), 'foo:bar baz'); | ||
// // assert.equal(format(['%%%s%%', 'hi']), '%hi%'); | ||
// // assert.equal(format(['%%%s%%%%', 'hi']), '%hi%%'); | ||
// (function() { | ||
// var o = {}; | ||
// o.o = o; | ||
// assert.equal(format(['%j', o]), '[Circular]'); | ||
// })(); |
7484
159