{"name":"toml","version":"4.3.0","keywords":["toml","parser"],"author":{"name":"Michelle Tilley","email":"michelle@michelletilley.net"},"license":"MIT","_id":"toml@4.3.0","maintainers":[{"name":"binarymuse","email":"michelle@michelletilley.net"}],"homepage":"https://github.com/BinaryMuse/toml-node#readme","bugs":{"url":"https://github.com/BinaryMuse/toml-node/issues"},"dist":{"shasum":"10e2ff83296ec17d8935bf02364e4969cfeaae67","tarball":"http://registry-npm.ywwl.com/toml/download/toml-4.3.0.tgz","fileCount":7,"integrity":"sha512-lVb8X9BsPVuH0M4BKeS91tXAmJvCjQ5UIyAbQFaxkKGyUFK2RPkhwaFSQH8vbpl1d23eu/IBH+dwVMHWaq9A5A==","signatures":[{"sig":"MEUCIQCudtG5GB+GNMn46TTRaasBwVnxezypPLvQuihUuN7vPwIgWryMSfVIfgCn3KIPJTw32DPtJnYdMbMXsOq2bFiHF6M=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":131789,"size":18246,"noattachment":false,"key":"/toml/-/toml-4.3.0.tgz"},"main":"index.js","types":"index.d.ts","engines":{"node":">=20"},"gitHead":"38fb4e6342b2134081e6554411312278d312b338","scripts":{"test":"node --test test/test_toml.js","build":"peggy -o lib/parser.js src/toml.pegjs","test:all":"node --test test/test_toml.js && node test/spec-test.js","test:spec":"node test/spec-test.js","prepublishOnly":"npm run build","test:spec:fresh":"node scripts/test-spec-fresh.js","test:spec:failures":"node test/spec-test.js --failures"},"_npmUser":{"name":"binarymuse","email":"michelle@michelletilley.net"},"repository":{"url":"git://github.com/BinaryMuse/toml-node.git","type":"git"},"_npmVersion":"11.16.0","description":"TOML parser for Node.js (TOML v1.1.0 compliant)","directories":{},"_nodeVersion":"24.11.1","_hasShrinkwrap":false,"devDependencies":{"peggy":"^5.1.0","@js-temporal/polyfill":"^0.5.1"},"_npmOperationalInternal":{"tmp":"tmp/toml_4.3.0_1783982951115_0.5460989819285655","host":"s3://npm-registry-packages-npm-production"},"readme":"TOML Parser for Node.js\n=======================\n\n[![CI](https://github.com/BinaryMuse/toml-node/actions/workflows/ci.yml/badge.svg)](https://github.com/BinaryMuse/toml-node/actions/workflows/ci.yml)\n\nIf you haven't heard of TOML, well you're just missing out. [Go check it out now.](https://toml.io) Back? Good.\n\nTOML Spec Support\n-----------------\n\ntoml-node supports [TOML v1.1.0](https://toml.io/en/v1.1.0), scoring **702/708 (99.2%)** on the official [toml-test](https://github.com/toml-lang/toml-test) compliance suite:\n\n| | Pass | Total | Rate |\n|---|---|---|---|\n| Valid tests | 218 | 218 | 100% |\n| Invalid tests | 484 | 490 | 98.8% |\n| **Total** | **702** | **708** | **99.2%** |\n\nThe 6 remaining failures are inherent JavaScript platform limitations shared by all JS TOML parsers: they cover UTF-8 encoding validation, which Node.js handles at the engine level before the parser sees the data.\n\nNote that integers beyond `Number.MAX_SAFE_INTEGER` require the [`bigint` option](#integer-range-and-bigint) to parse losslessly; without it they throw a parse error rather than silently losing precision.\n\n### Feature Support\n\n- **Strings**: basic, literal, multiline, all escape sequences (`\\uXXXX`, `\\UXXXXXXXX`, `\\xHH`, `\\e`)\n- **Integers**: decimal, hexadecimal (`0xDEADBEEF`), octal (`0o755`), binary (`0b11010110`)\n- **Floats**: decimal, scientific notation, `inf`, `-inf`, `nan`\n- **Booleans**: `true`, `false`\n- **Dates/Times**: offset date-time, local date-time, local date, local time; seconds optional\n- **Arrays**: mixed types allowed\n- **Tables**: standard, inline (with dotted/quoted keys, newlines, trailing commas), array of tables\n- **Keys**: bare, quoted, dotted (`fruit.apple.color = \"red\"`)\n- **Comments**: `# line comments`\n\nInstallation\n------------\n\n```\nnpm install toml\n```\n\nRequires Node.js 20 or later. Zero runtime dependencies.\n\nUsage\n-----\n\n```javascript\nconst toml = require('toml');\nconst data = toml.parse(someTomlString);\n```\n\n`toml.parse` throws an exception on parse errors with `line` and `column` properties:\n\n```javascript\ntry {\n  toml.parse(someBadToml);\n} catch (e) {\n  console.error(`Parsing error on line ${e.line}, column ${e.column}: ${e.message}`);\n}\n```\n\n### Nesting Depth Limit\n\nTo guard against stack overflow on maliciously deep input, arrays and inline tables may nest at most 500 levels deep by default; input past the limit throws a normal parse error. Adjust the limit with the `maxDepth` option:\n\n```javascript\ntoml.parse(someTomlString, { maxDepth: 100 });\n```\n\n### Integer Range and BigInt\n\nTOML requires parsers to handle the full range of 64-bit signed integers, but JavaScript's `number` type can only represent integers up to `Number.MAX_SAFE_INTEGER` (2⁵³ − 1) losslessly. By default, `toml.parse` returns integers as `number` and throws a parse error when a value falls outside the safe range, rather than silently returning a rounded value:\n\n```javascript\ntoml.parse('id = 771752188537605140');\n// Error: Integer 771752188537605140 cannot be represented losslessly\n// as a JavaScript number. Use the `bigint` option to parse integers\n// as BigInt values.\n```\n\nPass `bigint: true` to instead parse **all** integers as `BigInt`, preserving the full 64-bit range:\n\n```javascript\nconst data = toml.parse('id = 771752188537605140\\ncount = 3', { bigint: true });\ndata.id     // 771752188537605140n\ndata.count  // 3n\n```\n\nIntegers outside the 64-bit signed range always throw, in either mode, as required by the spec. Floats are unaffected by all of this: TOML floats are IEEE 754 binary64 values, which is exactly what a JavaScript `number` is, so every TOML float is represented as faithfully as the spec intends.\n\n### Date/Time Values\n\nOffset date-times are returned as JavaScript `Date` objects. Local date-times, local dates, and local times are returned as strings since they have no timezone information and can't be losslessly represented as `Date`:\n\n```javascript\nconst data = toml.parse(`\nodt = 1979-05-27T07:32:00Z       # Date object\nldt = 1979-05-27T07:32:00        # string: \"1979-05-27T07:32:00\"\nld  = 1979-05-27                  # string: \"1979-05-27\"\nlt  = 07:32:00                    # string: \"07:32:00\"\n`);\n\ndata.odt instanceof Date  // true\ntypeof data.ldt            // \"string\"\ntypeof data.ld             // \"string\"\ntypeof data.lt             // \"string\"\n```\n\n#### Temporal Support\n\nPass `useTemporal: true` to have date/time values returned as\n[Temporal](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Temporal)\nobjects instead:\n\n| TOML type        | Returned as               |\n| ---------------- | ------------------------- |\n| Offset date-time | `Temporal.ZonedDateTime`  |\n| Local date-time  | `Temporal.PlainDateTime`  |\n| Local date       | `Temporal.PlainDate`      |\n| Local time       | `Temporal.PlainTime`      |\n\n```javascript\nconst data = toml.parse(`\nodt = 1979-05-27T00:32:00-07:00\nldt = 1979-05-27T07:32:00\nld  = 1979-05-27\nlt  = 07:32:00\n`, { useTemporal: true });\n\ndata.odt.toString()  // \"1979-05-27T00:32:00-07:00[-07:00]\"\ndata.ldt.toString()  // \"1979-05-27T07:32:00\"\ndata.ld.toString()   // \"1979-05-27\"\ndata.lt.toString()   // \"07:32:00\"\n```\n\nOffset date-times become `Temporal.ZonedDateTime` values whose time zone is\nthe original UTC offset (`Z` maps to the `UTC` time zone), so the offset\nwritten in the TOML document is preserved — unlike the default `Date`\nrepresentation, which loses it. Fractional seconds beyond nanosecond\nprecision are truncated, as permitted by the TOML spec.\n\n`useTemporal` requires a runtime with the `Temporal` global. On runtimes\nthat don't provide it yet, pass an implementation such as\n[`@js-temporal/polyfill`](https://www.npmjs.com/package/@js-temporal/polyfill)\nvia the `temporal` option:\n\n```javascript\nconst { Temporal } = require('@js-temporal/polyfill');\nconst data = toml.parse(someTomlString, { useTemporal: true, temporal: Temporal });\n```\n\nOnce `Temporal` is broadly available, Temporal output is expected to become\nthe default behavior in a future major version.\n\n### Special Float Values\n\n`inf` and `nan` are returned as JavaScript `Infinity` and `NaN`:\n\n```javascript\nconst data = toml.parse(`\npos_inf = inf\nneg_inf = -inf\nnot_a_number = nan\n`);\n\ndata.pos_inf === Infinity   // true\ndata.neg_inf === -Infinity  // true\nNumber.isNaN(data.not_a_number) // true\n```\n\n### Requiring .toml Files\n\nYou can use the [toml-require package](https://github.com/BinaryMuse/toml-require) to `require()` your `.toml` files with Node.js.\n\nBuilding & Testing\n------------------\n\ntoml-node uses the [Peggy parser generator](https://peggyjs.org/) (successor to PEG.js).\n\n```\nnpm install\nnpm run build\nnpm test\nnpm run test:spec           # run toml-test compliance suite\nnpm run test:spec:failures  # show failure details\n```\n\nChanges to `src/toml.pegjs` require a rebuild with `npm run build`.\n\nLicense\n-------\n\ntoml-node is licensed under the MIT license agreement. See the LICENSE file for more information.\n","publish_time":1783982951270,"_cnpm_publish_time":1783982951270,"dist-tags":{"latest":"5.0.1"}}