summaryrefslogtreecommitdiff
path: root/node_modules/yaml/dist/schema/core/float.js
diff options
context:
space:
mode:
authorPhilipp Tanlak <philipp.tanlak@gmail.com>2025-11-24 20:54:57 +0100
committerPhilipp Tanlak <philipp.tanlak@gmail.com>2025-11-24 20:57:48 +0100
commitb1e2c8fd5cb5dfa46bc440a12eafaf56cd844b1c (patch)
tree49d360fd6cbc6a2754efe93524ac47ff0fbe0f7d /node_modules/yaml/dist/schema/core/float.js
Docs
Diffstat (limited to 'node_modules/yaml/dist/schema/core/float.js')
-rw-r--r--node_modules/yaml/dist/schema/core/float.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/node_modules/yaml/dist/schema/core/float.js b/node_modules/yaml/dist/schema/core/float.js
new file mode 100644
index 0000000..a1c96dd
--- /dev/null
+++ b/node_modules/yaml/dist/schema/core/float.js
@@ -0,0 +1,47 @@
+'use strict';
+
+var Scalar = require('../../nodes/Scalar.js');
+var stringifyNumber = require('../../stringify/stringifyNumber.js');
+
+const floatNaN = {
+ identify: value => typeof value === 'number',
+ default: true,
+ tag: 'tag:yaml.org,2002:float',
+ test: /^(?:[-+]?\.(?:inf|Inf|INF|nan|NaN|NAN))$/,
+ resolve: str => str.slice(-3).toLowerCase() === 'nan'
+ ? NaN
+ : str[0] === '-'
+ ? Number.NEGATIVE_INFINITY
+ : Number.POSITIVE_INFINITY,
+ stringify: stringifyNumber.stringifyNumber
+};
+const floatExp = {
+ identify: value => typeof value === 'number',
+ default: true,
+ tag: 'tag:yaml.org,2002:float',
+ format: 'EXP',
+ test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
+ resolve: str => parseFloat(str),
+ stringify(node) {
+ const num = Number(node.value);
+ return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node);
+ }
+};
+const float = {
+ identify: value => typeof value === 'number',
+ default: true,
+ tag: 'tag:yaml.org,2002:float',
+ test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
+ resolve(str) {
+ const node = new Scalar.Scalar(parseFloat(str));
+ const dot = str.indexOf('.');
+ if (dot !== -1 && str[str.length - 1] === '0')
+ node.minFractionDigits = str.length - dot - 1;
+ return node;
+ },
+ stringify: stringifyNumber.stringifyNumber
+};
+
+exports.float = float;
+exports.floatExp = floatExp;
+exports.floatNaN = floatNaN;