summaryrefslogtreecommitdiff
path: root/node_modules/yaml/dist/schema/core/int.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/int.js
Docs
Diffstat (limited to 'node_modules/yaml/dist/schema/core/int.js')
-rw-r--r--node_modules/yaml/dist/schema/core/int.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/node_modules/yaml/dist/schema/core/int.js b/node_modules/yaml/dist/schema/core/int.js
new file mode 100644
index 0000000..fe4c9ca
--- /dev/null
+++ b/node_modules/yaml/dist/schema/core/int.js
@@ -0,0 +1,42 @@
+'use strict';
+
+var stringifyNumber = require('../../stringify/stringifyNumber.js');
+
+const intIdentify = (value) => typeof value === 'bigint' || Number.isInteger(value);
+const intResolve = (str, offset, radix, { intAsBigInt }) => (intAsBigInt ? BigInt(str) : parseInt(str.substring(offset), radix));
+function intStringify(node, radix, prefix) {
+ const { value } = node;
+ if (intIdentify(value) && value >= 0)
+ return prefix + value.toString(radix);
+ return stringifyNumber.stringifyNumber(node);
+}
+const intOct = {
+ identify: value => intIdentify(value) && value >= 0,
+ default: true,
+ tag: 'tag:yaml.org,2002:int',
+ format: 'OCT',
+ test: /^0o[0-7]+$/,
+ resolve: (str, _onError, opt) => intResolve(str, 2, 8, opt),
+ stringify: node => intStringify(node, 8, '0o')
+};
+const int = {
+ identify: intIdentify,
+ default: true,
+ tag: 'tag:yaml.org,2002:int',
+ test: /^[-+]?[0-9]+$/,
+ resolve: (str, _onError, opt) => intResolve(str, 0, 10, opt),
+ stringify: stringifyNumber.stringifyNumber
+};
+const intHex = {
+ identify: value => intIdentify(value) && value >= 0,
+ default: true,
+ tag: 'tag:yaml.org,2002:int',
+ format: 'HEX',
+ test: /^0x[0-9a-fA-F]+$/,
+ resolve: (str, _onError, opt) => intResolve(str, 2, 16, opt),
+ stringify: node => intStringify(node, 16, '0x')
+};
+
+exports.int = int;
+exports.intHex = intHex;
+exports.intOct = intOct;