From 383285ecd5292bf9a825e05904955b937de84cc9 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sat, 4 Jun 2022 08:51:01 +0200 Subject: Initial commit --- .../yaml/browser/dist/stringify/stringifyNumber.js | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 node_modules/yaml/browser/dist/stringify/stringifyNumber.js (limited to 'node_modules/yaml/browser/dist/stringify/stringifyNumber.js') diff --git a/node_modules/yaml/browser/dist/stringify/stringifyNumber.js b/node_modules/yaml/browser/dist/stringify/stringifyNumber.js new file mode 100644 index 0000000..3fa35f9 --- /dev/null +++ b/node_modules/yaml/browser/dist/stringify/stringifyNumber.js @@ -0,0 +1,24 @@ +function stringifyNumber({ format, minFractionDigits, tag, value }) { + if (typeof value === 'bigint') + return String(value); + const num = typeof value === 'number' ? value : Number(value); + if (!isFinite(num)) + return isNaN(num) ? '.nan' : num < 0 ? '-.inf' : '.inf'; + let n = JSON.stringify(value); + if (!format && + minFractionDigits && + (!tag || tag === 'tag:yaml.org,2002:float') && + /^\d/.test(n)) { + let i = n.indexOf('.'); + if (i < 0) { + i = n.length; + n += '.'; + } + let d = minFractionDigits - (n.length - i - 1); + while (d-- > 0) + n += '0'; + } + return n; +} + +export { stringifyNumber }; -- cgit