Comparing version 4.2.1 to 4.2.2
@@ -14,10 +14,10 @@ "use strict"; | ||
const result = prefix + padStart_1.default(number.toString(base), precision || 0, '0'); | ||
return Justify_1.justify(result, prefix, leftJustify, minWidth, zeroPad); | ||
return Justify_1.justify(result, prefix, leftJustify, minWidth, !!zeroPad); | ||
}; | ||
// formatString() | ||
const formatString = (value, leftJustify, minWidth, precision, zeroPad) => { | ||
if (precision != null) { | ||
if (precision) { | ||
value = value.slice(0, precision); | ||
} | ||
return Justify_1.justify(value, '', leftJustify, minWidth, zeroPad); | ||
return Justify_1.justify(value, '', leftJustify, minWidth, !!zeroPad); | ||
}; | ||
@@ -77,3 +77,3 @@ exports.sprintf = (format, ...a) => { | ||
if (!precision) { | ||
precision = 'fFeE'.indexOf(type) > -1 ? 6 : (type == 'd') ? 0 : void (0); | ||
precision = 'fFeE'.indexOf(type) > -1 ? 6 : ((type == 'd') ? 0 : undefined); | ||
} | ||
@@ -87,9 +87,9 @@ else if (typeof precision === "string") { | ||
} | ||
precision = toSafeInteger_1.default(precision); | ||
} | ||
else { | ||
precision = +precision; | ||
precision = toSafeInteger_1.default(+precision); | ||
} | ||
precision = toSafeInteger_1.default(precision); | ||
// grab value using valueIndex if required? | ||
var value = valueIndex ? a[toSafeInteger_1.default(valueIndex.toString().slice(0, -1))] : a[i++]; | ||
var value = valueIndex ? a[toSafeInteger_1.default(valueIndex.toString().slice(0, -1)) - 1] : a[i++]; | ||
switch (type) { | ||
@@ -96,0 +96,0 @@ case 's': return formatString(String(value), leftJustify, minWidth, precision, zeroPad); |
{ | ||
"name": "onix-core", | ||
"version": "4.2.1", | ||
"version": "4.2.2", | ||
"description": "Onix library core", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -9,3 +9,3 @@ import toSafeInteger from 'lodash-es/toSafeInteger'; | ||
// formatBaseX() | ||
const formatBaseX = (value: number, base: RadixType, prefixBaseX: boolean, leftJustify: boolean, minWidth: number, precision: number, zeroPad: boolean) => { | ||
const formatBaseX = (value: number, base: RadixType, prefixBaseX: boolean, leftJustify: boolean, minWidth: number, precision?: number, zeroPad?: boolean) => { | ||
// Note: casts negative numbers to positive ones | ||
@@ -15,12 +15,12 @@ const number = value >>> 0; | ||
const result = prefix + padStart(number.toString(base), precision || 0, '0'); | ||
return justify(result, prefix, leftJustify, minWidth, zeroPad); | ||
return justify(result, prefix, leftJustify, minWidth, !!zeroPad); | ||
} | ||
// formatString() | ||
const formatString = (value: string, leftJustify: boolean, minWidth: number, precision: number, zeroPad: boolean) => { | ||
if (precision != null) { | ||
const formatString = (value: string, leftJustify: boolean, minWidth: number, precision?: number, zeroPad?: boolean) => { | ||
if (precision) { | ||
value = value.slice(0, precision); | ||
} | ||
return justify(value, '', leftJustify, minWidth, zeroPad); | ||
return justify(value, '', leftJustify, minWidth, !!zeroPad); | ||
} | ||
@@ -75,3 +75,3 @@ | ||
if (!precision) { | ||
precision = 'fFeE'.indexOf(<string>type) > -1 ? 6 : (type == 'd') ? 0 : void(0); | ||
precision = 'fFeE'.indexOf(<string>type) > -1 ? 6 : ((type == 'd') ? 0 : undefined); | ||
} else if (typeof precision === "string") { | ||
@@ -83,10 +83,10 @@ if (precision == '*') { | ||
} | ||
precision = toSafeInteger(precision); | ||
} else { | ||
precision = +precision; | ||
precision = toSafeInteger(+precision); | ||
} | ||
precision = toSafeInteger(precision); | ||
// grab value using valueIndex if required? | ||
var value = valueIndex ? a[toSafeInteger(valueIndex.toString().slice(0, -1))] : a[i++]; | ||
var value = valueIndex ? a[toSafeInteger(valueIndex.toString().slice(0, -1)) - 1] : a[i++]; | ||
@@ -93,0 +93,0 @@ switch (type) { |
Sorry, the diff of this file is not supported yet
126294