quick-format-unescaped
Advanced tools
Comparing version 4.0.1 to 4.0.2
20
index.js
@@ -21,8 +21,5 @@ 'use strict' | ||
} | ||
if (typeof f !== 'string') { | ||
return f | ||
} | ||
var argLen = args.length | ||
if (argLen === 0) return f | ||
var x = '' | ||
var argLen = args ? args.length : 0 | ||
if (argLen === 0) return f === undefined ? '' : f | ||
var str = '' | ||
@@ -37,2 +34,3 @@ var a = 1 - offset | ||
case 100: // 'd' | ||
case 102: // 'f' | ||
if (a >= argLen) | ||
@@ -46,2 +44,11 @@ break | ||
break | ||
case 105: // 'i' | ||
if (a >= argLen) | ||
break | ||
if (lastPos < i) | ||
str += f.slice(lastPos, i) | ||
if (args[a] == null) break | ||
str += Math.floor(Number(args[a])) | ||
lastPos = i = i + 2 | ||
break | ||
case 79: // 'O' | ||
@@ -87,2 +94,3 @@ case 111: // 'o' | ||
i++ | ||
a-- | ||
break | ||
@@ -89,0 +97,0 @@ } |
{ | ||
"name": "quick-format-unescaped", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"description": "Solves a problem with util.format", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
'use strict'; | ||
const assert = require('assert'); | ||
const assert = require('assert').strict; | ||
const format = require('../'); | ||
const util = require('util'); | ||
// const symbol = Symbol('foo'); | ||
// assert.equal(format([]), ''); | ||
@@ -34,2 +37,4 @@ // assert.equal(format(['']), ''); | ||
assert.equal(format('%d', [42]), '42'); | ||
assert.equal(format('%f', [42.99]), '42.99'); | ||
assert.equal(format('%i', [42.99]), '42'); | ||
assert.equal(format('%s', [42]), '42'); | ||
@@ -44,2 +49,3 @@ assert.equal(format('%j', [42]), '42'); | ||
assert.equal(format('%d', [null]), '%d'); | ||
assert.equal(format('%i', [null]), '%i'); | ||
assert.equal(format('%s', [null]), 'null'); | ||
@@ -51,3 +57,8 @@ assert.equal(format('%j', [null]), 'null'); | ||
assert.equal(format('%d', ['42']), '42'); | ||
assert.equal(format('%i', ['42']), '42'); | ||
assert.equal(format('%i', ['42.99']), '42'); | ||
assert.equal(format('%s %i', ['foo', 42.99]), 'foo 42'); | ||
assert.equal(format('%d %d', ['42']), '42 %d'); | ||
assert.equal(format('%i %i', ['42']), '42 %i'); | ||
assert.equal(format('%i %i', ['42.99']), '42 %i'); | ||
assert.equal(format('foo %d', ['42']), 'foo 42'); | ||
@@ -77,2 +88,6 @@ assert.equal(format('%s', ['42']), '42'); | ||
assert.equal(format(null, [null, 'foo']), null); | ||
assert.equal(format(null, [undefined, 'foo']), null); | ||
assert.equal(format(), util.format()); | ||
assert.equal(format('foo %o', [{foo: 'foo'}]), 'foo {"foo":"foo"}') | ||
@@ -94,2 +109,3 @@ assert.equal(format('foo %O', [{foo: 'foo'}]), 'foo {"foo":"foo"}') | ||
// // assert.equal(format(['%%%s%%', 'hi']), '%hi%'); | ||
@@ -106,1 +122,2 @@ // // assert.equal(format(['%%%s%%%%', 'hi']), '%hi%%'); | ||
assert.equal(format('foo %%', ['foo']), 'foo %') | ||
assert.equal(format('foo %% %s', ['bar']), 'foo % bar') |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
11563
220
1