smol-toml 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/extract.d.ts +1 -1
- package/dist/extract.js +1 -1
- package/dist/index.cjs +9 -9
- package/dist/struct.d.ts +2 -2
- package/dist/struct.js +2 -2
- package/dist/util.js +1 -1
- package/package.json +53 -52
package/README.md
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
[](https://npm.im/smol-toml)
|
|
5
5
|
[](https://github.com/squirrelchat/smol-toml/actions/workflows/build.yml)
|
|
6
6
|
|
|
7
|
+
[](https://github.com/sponsors/cyyynthia)
|
|
8
|
+
[](https://npm.im/smol-toml)
|
|
9
|
+
[](https://npm.im/smol-toml)
|
|
10
|
+
|
|
7
11
|
A small, fast, and correct TOML parser and serializer. smol-toml is fully(ish) spec-compliant with TOML v1.0.0.
|
|
8
12
|
|
|
9
13
|
Why yet another TOML parser? Well, the ecosystem of TOML parsers in JavaScript is quite underwhelming, most likely due
|
package/dist/extract.d.ts
CHANGED
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
27
|
*/
|
|
28
28
|
import { type TomlPrimitive } from './util.js';
|
|
29
|
-
export declare function extractValue(str: string, ptr: number, end
|
|
29
|
+
export declare function extractValue(str: string, ptr: number, end?: string | undefined, depth?: number): [TomlPrimitive, number];
|
package/dist/extract.js
CHANGED
|
@@ -50,7 +50,7 @@ function sliceAndTrimEndOf(str, startPtr, endPtr, allowNewLines) {
|
|
|
50
50
|
}
|
|
51
51
|
return [trimmed, commentIdx];
|
|
52
52
|
}
|
|
53
|
-
export function extractValue(str, ptr, end, depth) {
|
|
53
|
+
export function extractValue(str, ptr, end, depth = -1) {
|
|
54
54
|
if (depth === 0) {
|
|
55
55
|
throw new TomlError('document contains excessively nested structures. aborting.', {
|
|
56
56
|
toml: str,
|
package/dist/index.cjs
CHANGED
|
@@ -18,15 +18,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// dist/index.js
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
TomlDate: () => TomlDate,
|
|
24
24
|
TomlError: () => TomlError,
|
|
25
|
-
default: () =>
|
|
25
|
+
default: () => index_default,
|
|
26
26
|
parse: () => parse,
|
|
27
27
|
stringify: () => stringify
|
|
28
28
|
});
|
|
29
|
-
module.exports = __toCommonJS(
|
|
29
|
+
module.exports = __toCommonJS(index_exports);
|
|
30
30
|
|
|
31
31
|
// dist/error.js
|
|
32
32
|
function getLineColFromPtr(string, ptr) {
|
|
@@ -125,7 +125,7 @@ function getStringEnd(str, seek) {
|
|
|
125
125
|
seek += target.length - 1;
|
|
126
126
|
do
|
|
127
127
|
seek = str.indexOf(target, ++seek);
|
|
128
|
-
while (seek > -1 && first !== "'" && str[seek - 1] === "\\" && str[seek - 2] !== "\\");
|
|
128
|
+
while (seek > -1 && first !== "'" && str[seek - 1] === "\\" && (str[seek - 2] !== "\\" || str[seek - 3] === "\\"));
|
|
129
129
|
if (seek > -1) {
|
|
130
130
|
seek += target.length;
|
|
131
131
|
if (target.length > 1) {
|
|
@@ -382,7 +382,7 @@ function sliceAndTrimEndOf(str, startPtr, endPtr, allowNewLines) {
|
|
|
382
382
|
}
|
|
383
383
|
return [trimmed, commentIdx];
|
|
384
384
|
}
|
|
385
|
-
function extractValue(str, ptr, end, depth) {
|
|
385
|
+
function extractValue(str, ptr, end, depth = -1) {
|
|
386
386
|
if (depth === 0) {
|
|
387
387
|
throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
388
388
|
toml: str,
|
|
@@ -507,7 +507,7 @@ function parseKey(str, ptr, end = "=") {
|
|
|
507
507
|
} while (dot + 1 && dot < endPtr);
|
|
508
508
|
return [parsed, skipVoid(str, endPtr + 1, true, true)];
|
|
509
509
|
}
|
|
510
|
-
function parseInlineTable(str, ptr, depth) {
|
|
510
|
+
function parseInlineTable(str, ptr, depth = -1) {
|
|
511
511
|
let res = {};
|
|
512
512
|
let seen = /* @__PURE__ */ new Set();
|
|
513
513
|
let c;
|
|
@@ -575,7 +575,7 @@ function parseInlineTable(str, ptr, depth) {
|
|
|
575
575
|
}
|
|
576
576
|
return [res, ptr];
|
|
577
577
|
}
|
|
578
|
-
function parseArray(str, ptr, depth) {
|
|
578
|
+
function parseArray(str, ptr, depth = -1) {
|
|
579
579
|
let res = [];
|
|
580
580
|
let c;
|
|
581
581
|
ptr++;
|
|
@@ -867,7 +867,7 @@ function stringify(obj, opts) {
|
|
|
867
867
|
}
|
|
868
868
|
|
|
869
869
|
// dist/index.js
|
|
870
|
-
var
|
|
870
|
+
var index_default = { parse, stringify, TomlDate, TomlError };
|
|
871
871
|
// Annotate the CommonJS export names for ESM import in node:
|
|
872
872
|
0 && (module.exports = {
|
|
873
873
|
TomlDate,
|
package/dist/struct.d.ts
CHANGED
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
*/
|
|
28
28
|
import { type TomlPrimitive } from './util.js';
|
|
29
29
|
export declare function parseKey(str: string, ptr: number, end?: string): [string[], number];
|
|
30
|
-
export declare function parseInlineTable(str: string, ptr: number, depth
|
|
31
|
-
export declare function parseArray(str: string, ptr: number, depth
|
|
30
|
+
export declare function parseInlineTable(str: string, ptr: number, depth?: number): [Record<string, TomlPrimitive>, number];
|
|
31
|
+
export declare function parseArray(str: string, ptr: number, depth?: number): [TomlPrimitive[], number];
|
package/dist/struct.js
CHANGED
|
@@ -102,7 +102,7 @@ export function parseKey(str, ptr, end = '=') {
|
|
|
102
102
|
} while (dot + 1 && dot < endPtr);
|
|
103
103
|
return [parsed, skipVoid(str, endPtr + 1, true, true)];
|
|
104
104
|
}
|
|
105
|
-
export function parseInlineTable(str, ptr, depth) {
|
|
105
|
+
export function parseInlineTable(str, ptr, depth = -1) {
|
|
106
106
|
let res = {};
|
|
107
107
|
let seen = new Set();
|
|
108
108
|
let c;
|
|
@@ -173,7 +173,7 @@ export function parseInlineTable(str, ptr, depth) {
|
|
|
173
173
|
}
|
|
174
174
|
return [res, ptr];
|
|
175
175
|
}
|
|
176
|
-
export function parseArray(str, ptr, depth) {
|
|
176
|
+
export function parseArray(str, ptr, depth = -1) {
|
|
177
177
|
let res = [];
|
|
178
178
|
let c;
|
|
179
179
|
ptr++;
|
package/dist/util.js
CHANGED
|
@@ -89,7 +89,7 @@ export function getStringEnd(str, seek) {
|
|
|
89
89
|
seek += target.length - 1;
|
|
90
90
|
do
|
|
91
91
|
seek = str.indexOf(target, ++seek);
|
|
92
|
-
while (seek > -1 && first !== "'" && str[seek - 1] === '\\' && str[seek - 2] !== '\\');
|
|
92
|
+
while (seek > -1 && first !== "'" && str[seek - 1] === '\\' && (str[seek - 2] !== '\\' || str[seek - 3] === '\\'));
|
|
93
93
|
if (seek > -1) {
|
|
94
94
|
seek += target.length;
|
|
95
95
|
if (target.length > 1) {
|
package/package.json
CHANGED
|
@@ -1,53 +1,54 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
2
|
+
"name": "smol-toml",
|
|
3
|
+
"license": "BSD-3-Clause",
|
|
4
|
+
"version": "1.3.3",
|
|
5
|
+
"description": "A small, fast, and correct TOML parser/serializer",
|
|
6
|
+
"author": "Cynthia <cyyynthia@borkenware.com>",
|
|
7
|
+
"repository": "github:squirrelchat/smol-toml",
|
|
8
|
+
"bugs": "https://github.com/squirrelchat/smol-toml/issues",
|
|
9
|
+
"funding": "https://github.com/sponsors/cyyynthia",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"toml",
|
|
12
|
+
"parser",
|
|
13
|
+
"serializer"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">= 18"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@iarna/toml": "3.0.0",
|
|
21
|
+
"@ltd/j-toml": "^1.38.0",
|
|
22
|
+
"@tsconfig/node-lts": "^22.0.1",
|
|
23
|
+
"@tsconfig/strictest": "^2.0.5",
|
|
24
|
+
"@types/node": "^22.14.1",
|
|
25
|
+
"@vitest/ui": "^3.1.1",
|
|
26
|
+
"esbuild": "^0.25.2",
|
|
27
|
+
"fast-toml": "^0.5.4",
|
|
28
|
+
"pin-github-action": "^3.1.2",
|
|
29
|
+
"typescript": "^5.8.3",
|
|
30
|
+
"vitest": "^3.1.1"
|
|
31
|
+
},
|
|
32
|
+
"main": "./dist/index.cjs",
|
|
33
|
+
"module": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"exports": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.js",
|
|
38
|
+
"require": "./dist/index.cjs"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"README.md",
|
|
42
|
+
"LICENSE",
|
|
43
|
+
"dist"
|
|
44
|
+
],
|
|
45
|
+
"scripts": {
|
|
46
|
+
"test": "vitest",
|
|
47
|
+
"test-ui": "vitest --ui",
|
|
48
|
+
"bench": "vitest bench",
|
|
49
|
+
"build": "pnpm run build:mjs && pnpm run build:cjs && node test/package/package-test.mjs",
|
|
50
|
+
"build:mjs": "tsc",
|
|
51
|
+
"build:cjs": "esbuild dist/index.js --bundle --platform=node --target=node18 --format=cjs --outfile=dist/index.cjs",
|
|
52
|
+
"update-gha": "pin-github-action .github/workflows"
|
|
53
|
+
}
|
|
54
|
+
}
|