@flourish/interpreter
Advanced tools
Comparing version 8.0.0 to 8.0.1
{ | ||
"plugins": [ | ||
"@flourish/flourish" | ||
], | ||
"extends": "plugin:@flourish/flourish/flourish", | ||
"env": { "browser": true } | ||
"extends": "../../.eslintrc" | ||
} |
@@ -236,2 +236,4 @@ (function (global, factory) { | ||
"f": formatMicroseconds, | ||
"g": formatYearISO, | ||
"G": formatFullYearISO, | ||
"H": formatHour24, | ||
@@ -270,2 +272,4 @@ "I": formatHour12, | ||
"f": formatUTCMicroseconds, | ||
"g": formatUTCYearISO, | ||
"G": formatUTCFullYearISO, | ||
"H": formatUTCHour24, | ||
@@ -304,2 +308,4 @@ "I": formatUTCHour12, | ||
"f": parseMicroseconds, | ||
"g": parseYear, | ||
"G": parseFullYear, | ||
"H": parseHour24, | ||
@@ -726,5 +732,9 @@ "I": parseHour24, | ||
function dISO(d) { | ||
var day = d.getDay(); | ||
return (day >= 4 || day === 0) ? thursday(d) : thursday.ceil(d); | ||
} | ||
function formatWeekNumberISO(d, p) { | ||
var day = d.getDay(); | ||
d = (day >= 4 || day === 0) ? thursday(d) : thursday.ceil(d); | ||
d = dISO(d); | ||
return pad(thursday.count(year(d), d) + (year(d).getDay() === 4), p, 2); | ||
@@ -745,2 +755,7 @@ } | ||
function formatYearISO(d, p) { | ||
d = dISO(d); | ||
return pad(d.getFullYear() % 100, p, 2); | ||
} | ||
function formatFullYear(d, p) { | ||
@@ -750,2 +765,8 @@ return pad(d.getFullYear() % 10000, p, 4); | ||
function formatFullYearISO(d, p) { | ||
var day = d.getDay(); | ||
d = (day >= 4 || day === 0) ? thursday(d) : thursday.ceil(d); | ||
return pad(d.getFullYear() % 10000, p, 4); | ||
} | ||
function formatZone(d) { | ||
@@ -803,5 +824,9 @@ var z = d.getTimezoneOffset(); | ||
function UTCdISO(d) { | ||
var day = d.getUTCDay(); | ||
return (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d); | ||
} | ||
function formatUTCWeekNumberISO(d, p) { | ||
var day = d.getUTCDay(); | ||
d = (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d); | ||
d = UTCdISO(d); | ||
return pad(utcThursday.count(utcYear(d), d) + (utcYear(d).getUTCDay() === 4), p, 2); | ||
@@ -822,2 +847,7 @@ } | ||
function formatUTCYearISO(d, p) { | ||
d = UTCdISO(d); | ||
return pad(d.getUTCFullYear() % 100, p, 2); | ||
} | ||
function formatUTCFullYear(d, p) { | ||
@@ -827,2 +857,8 @@ return pad(d.getUTCFullYear() % 10000, p, 4); | ||
function formatUTCFullYearISO(d, p) { | ||
var day = d.getUTCDay(); | ||
d = (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d); | ||
return pad(d.getUTCFullYear() % 10000, p, 4); | ||
} | ||
function formatUTCZone() { | ||
@@ -1102,6 +1138,12 @@ return "+0000"; | ||
function formatDecimal(x) { | ||
return Math.abs(x = Math.round(x)) >= 1e21 | ||
? x.toLocaleString("en").replace(/,/g, "") | ||
: x.toString(10); | ||
} | ||
// Computes the decimal coefficient and exponent of the specified number x with | ||
// significant digits p, where x is positive and p is in [1, 21] or undefined. | ||
// For example, formatDecimal(1.23) returns ["123", 0]. | ||
function formatDecimal(x, p) { | ||
// For example, formatDecimalParts(1.23) returns ["123", 0]. | ||
function formatDecimalParts(x, p) { | ||
if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity | ||
@@ -1119,3 +1161,3 @@ var i, coefficient = x.slice(0, i); | ||
function exponent(x) { | ||
return x = formatDecimal(Math.abs(x)), x ? x[1] : NaN; | ||
return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN; | ||
} | ||
@@ -1213,3 +1255,3 @@ | ||
function formatPrefixAuto(x, p) { | ||
var d = formatDecimal(x, p); | ||
var d = formatDecimalParts(x, p); | ||
if (!d) return x + ""; | ||
@@ -1223,7 +1265,7 @@ var coefficient = d[0], | ||
: i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) | ||
: "0." + new Array(1 - i).join("0") + formatDecimal(x, Math.max(0, p + i - 1))[0]; // less than 1y! | ||
: "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0]; // less than 1y! | ||
} | ||
function formatRounded(x, p) { | ||
var d = formatDecimal(x, p); | ||
var d = formatDecimalParts(x, p); | ||
if (!d) return x + ""; | ||
@@ -1241,3 +1283,3 @@ var coefficient = d[0], | ||
"c": function(x) { return x + ""; }, | ||
"d": function(x) { return Math.round(x).toString(10); }, | ||
"d": formatDecimal, | ||
"e": function(x, p) { return x.toExponential(p); }, | ||
@@ -1324,4 +1366,6 @@ "f": function(x, p) { return x.toFixed(p); }, | ||
// Determine the sign. -0 is not less than 0, but 1 / -0 is! | ||
var valueNegative = value < 0 || 1 / value < 0; | ||
// Perform the initial formatting. | ||
var valueNegative = value < 0; | ||
value = isNaN(value) ? nan : formatType(Math.abs(value), precision); | ||
@@ -1332,8 +1376,7 @@ | ||
// If a negative value rounds to zero during formatting, treat as positive. | ||
if (valueNegative && +value === 0) valueNegative = false; | ||
// If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign. | ||
if (valueNegative && +value === 0 && sign !== "+") valueNegative = false; | ||
// Compute the prefix and suffix. | ||
valuePrefix = (valueNegative ? (sign === "(" ? sign : minus) : sign === "-" || sign === "(" ? "" : sign) + valuePrefix; | ||
valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : ""); | ||
@@ -1406,2 +1449,3 @@ | ||
return function(value, spec) { | ||
if (value === null) return ""; | ||
if (!spec) spec = ",.2f"; | ||
@@ -1408,0 +1452,0 @@ if (spec !== specifier) { |
{ | ||
"name": "@flourish/interpreter", | ||
"version": "8.0.0", | ||
"version": "8.0.1", | ||
"description": "Does a best guess at the type of data supplied", | ||
@@ -28,12 +28,8 @@ "main": "interpreter.js", | ||
"chai": "^4.2.0", | ||
"eslint": "^6.5.1", | ||
"eslint": "^8.35.0", | ||
"mocha": "^6.2.2", | ||
"pre-commit": "^1.2.2", | ||
"rollup": "^1.25.2", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"uglify-js": "^3.6.4" | ||
}, | ||
"precommit": [ | ||
"lint" | ||
] | ||
} | ||
} |
@@ -0,1 +1,4 @@ | ||
# 8.0.1 | ||
* Format empty cells in number columns as empty strings | ||
# 8.0.0 | ||
@@ -2,0 +5,0 @@ * Make datetime parsing and output consistent across locales |
@@ -12,2 +12,3 @@ import { shield } from "./common"; | ||
return function(value, spec) { | ||
if (value === null) return ""; | ||
if (!spec) spec = ",.2f"; | ||
@@ -14,0 +15,0 @@ if (spec !== specifier) { |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
98558
7
2128
1