smol-toml 1.2.2 → 1.3.1
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/dist/date.js +1 -5
- package/dist/error.js +1 -5
- package/dist/extract.d.ts +1 -1
- package/dist/extract.js +26 -24
- package/dist/index.cjs +904 -0
- package/dist/index.d.ts +12 -4
- package/dist/index.js +6 -11
- package/dist/parse.d.ts +3 -1
- package/dist/parse.js +16 -19
- package/dist/primitive.js +18 -23
- package/dist/stringify.d.ts +3 -1
- package/dist/stringify.js +26 -20
- package/dist/struct.d.ts +2 -2
- package/dist/struct.js +30 -36
- package/dist/util.js +8 -16
- package/package.json +26 -16
package/dist/util.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*!
|
|
3
2
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
4
3
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -26,17 +25,14 @@
|
|
|
26
25
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
26
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
27
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const error_js_1 = require("./error.js");
|
|
32
|
-
function indexOfNewline(str, start = 0, end = str.length) {
|
|
28
|
+
import { TomlError } from './error.js';
|
|
29
|
+
export function indexOfNewline(str, start = 0, end = str.length) {
|
|
33
30
|
let idx = str.indexOf('\n', start);
|
|
34
31
|
if (str[idx - 1] === '\r')
|
|
35
32
|
idx--;
|
|
36
33
|
return idx <= end ? idx : -1;
|
|
37
34
|
}
|
|
38
|
-
|
|
39
|
-
function skipComment(str, ptr) {
|
|
35
|
+
export function skipComment(str, ptr) {
|
|
40
36
|
for (let i = ptr; i < str.length; i++) {
|
|
41
37
|
let c = str[i];
|
|
42
38
|
if (c === '\n')
|
|
@@ -44,7 +40,7 @@ function skipComment(str, ptr) {
|
|
|
44
40
|
if (c === '\r' && str[i + 1] === '\n')
|
|
45
41
|
return i + 1;
|
|
46
42
|
if ((c < '\x20' && c !== '\t') || c === '\x7f') {
|
|
47
|
-
throw new
|
|
43
|
+
throw new TomlError('control characters are not allowed in comments', {
|
|
48
44
|
toml: str,
|
|
49
45
|
ptr: ptr,
|
|
50
46
|
});
|
|
@@ -52,8 +48,7 @@ function skipComment(str, ptr) {
|
|
|
52
48
|
}
|
|
53
49
|
return str.length;
|
|
54
50
|
}
|
|
55
|
-
|
|
56
|
-
function skipVoid(str, ptr, banNewLines, banComments) {
|
|
51
|
+
export function skipVoid(str, ptr, banNewLines, banComments) {
|
|
57
52
|
let c;
|
|
58
53
|
while ((c = str[ptr]) === ' ' || c === '\t' || (!banNewLines && (c === '\n' || c === '\r' && str[ptr + 1] === '\n')))
|
|
59
54
|
ptr++;
|
|
@@ -61,8 +56,7 @@ function skipVoid(str, ptr, banNewLines, banComments) {
|
|
|
61
56
|
? ptr
|
|
62
57
|
: skipVoid(str, skipComment(str, ptr), banNewLines);
|
|
63
58
|
}
|
|
64
|
-
|
|
65
|
-
function skipUntil(str, ptr, sep, end, banNewLines = false) {
|
|
59
|
+
export function skipUntil(str, ptr, sep, end, banNewLines = false) {
|
|
66
60
|
if (!end) {
|
|
67
61
|
ptr = indexOfNewline(str, ptr);
|
|
68
62
|
return ptr < 0 ? str.length : ptr;
|
|
@@ -82,13 +76,12 @@ function skipUntil(str, ptr, sep, end, banNewLines = false) {
|
|
|
82
76
|
return i;
|
|
83
77
|
}
|
|
84
78
|
}
|
|
85
|
-
throw new
|
|
79
|
+
throw new TomlError('cannot find end of structure', {
|
|
86
80
|
toml: str,
|
|
87
81
|
ptr: ptr
|
|
88
82
|
});
|
|
89
83
|
}
|
|
90
|
-
|
|
91
|
-
function getStringEnd(str, seek) {
|
|
84
|
+
export function getStringEnd(str, seek) {
|
|
92
85
|
let first = str[seek];
|
|
93
86
|
let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2]
|
|
94
87
|
? str.slice(seek, seek + 3)
|
|
@@ -108,4 +101,3 @@ function getStringEnd(str, seek) {
|
|
|
108
101
|
}
|
|
109
102
|
return seek;
|
|
110
103
|
}
|
|
111
|
-
exports.getStringEnd = getStringEnd;
|
package/package.json
CHANGED
|
@@ -1,40 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smol-toml",
|
|
3
|
-
"
|
|
3
|
+
"license": "BSD-3-Clause",
|
|
4
|
+
"version": "1.3.1",
|
|
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",
|
|
4
10
|
"keywords": [
|
|
5
11
|
"toml",
|
|
6
12
|
"parser",
|
|
7
13
|
"serializer"
|
|
8
14
|
],
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+ssh://git@github.com/squirrelchat/smol-toml.git"
|
|
13
|
-
},
|
|
14
|
-
"author": "Cynthia <cyyynthia@borkenware.com>",
|
|
15
|
-
"license": "BSD-3-Clause",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"packageManager": "pnpm@9.12.3",
|
|
16
17
|
"engines": {
|
|
17
18
|
"node": ">= 18"
|
|
18
19
|
},
|
|
19
20
|
"scripts": {
|
|
20
|
-
"build": "tsc",
|
|
21
21
|
"test": "vitest",
|
|
22
22
|
"test-ui": "vitest --ui",
|
|
23
|
-
"bench": "vitest bench"
|
|
23
|
+
"bench": "vitest bench",
|
|
24
|
+
"build": "pnpm run build:mjs && pnpm run build:cjs && node test/package/package-test.mjs",
|
|
25
|
+
"build:mjs": "tsc",
|
|
26
|
+
"build:cjs": "esbuild dist/index.js --bundle --platform=node --target=node18 --format=cjs --outfile=dist/index.cjs"
|
|
24
27
|
},
|
|
25
28
|
"devDependencies": {
|
|
26
29
|
"@iarna/toml": "3.0.0",
|
|
27
30
|
"@ltd/j-toml": "^1.38.0",
|
|
28
|
-
"@tsconfig/node-lts": "^
|
|
31
|
+
"@tsconfig/node-lts": "^22.0.0",
|
|
29
32
|
"@tsconfig/strictest": "^2.0.5",
|
|
30
|
-
"@types/node": "^
|
|
31
|
-
"@vitest/ui": "^1.
|
|
33
|
+
"@types/node": "^22.9.0",
|
|
34
|
+
"@vitest/ui": "^2.1.5",
|
|
35
|
+
"esbuild": "^0.24.0",
|
|
32
36
|
"fast-toml": "^0.5.4",
|
|
33
|
-
"typescript": "^5.
|
|
34
|
-
"vitest": "^1.
|
|
37
|
+
"typescript": "^5.6.3",
|
|
38
|
+
"vitest": "^2.1.5"
|
|
35
39
|
},
|
|
36
|
-
"main": "./dist/index.
|
|
40
|
+
"main": "./dist/index.cjs",
|
|
41
|
+
"module": "./dist/index.js",
|
|
37
42
|
"types": "./dist/index.d.ts",
|
|
43
|
+
"exports": {
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
45
|
+
"import": "./dist/index.js",
|
|
46
|
+
"require": "./dist/index.cjs"
|
|
47
|
+
},
|
|
38
48
|
"files": [
|
|
39
49
|
"README.md",
|
|
40
50
|
"LICENSE",
|