UNPKG

@foxglove/rosbag2

Version:

ROS 2 (Robot Operating System) bag reader and writer abstract implementation

42 lines 1.59 kB
"use strict"; /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-explicit-any */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseYaml = parseYaml; const js_yaml_1 = __importDefault(require("js-yaml")); // keep most of the original `int` options as is const options = Object.assign({}, js_yaml_1.default.types.int.options); options.construct = (data) => { let value = data, sign = 1n, ch; if (value.includes("_")) { value = value.replace(/_/g, ""); } ch = value[0]; if (ch === "-" || ch === "+") { if (ch === "-") { sign = -1n; } value = value.slice(1); ch = value[0]; } return sign * BigInt(value); }; options.predicate = (object) => { const isBigInt = Object.prototype.toString.call(object) === "[object BigInt]"; return isBigInt || js_yaml_1.default.types.int.options.predicate(object); }; const BigIntType = new js_yaml_1.default.Type("tag:yaml.org,2002:int", options); const SCHEMA = js_yaml_1.default.DEFAULT_SCHEMA.extend({ implicit: [BigIntType] }); /** * Parse a YAML string, parsing any integers as BigInts. * @param yamlString A YAML string to parse * @returns Parsed YAML */ function parseYaml(yamlString) { return js_yaml_1.default.load(yamlString, { schema: SCHEMA }); } //# sourceMappingURL=yaml.js.map