Comparing version 1.2.2 to 1.3.0
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
/*! | ||
@@ -29,6 +28,4 @@ * Copyright (c) Squirrel Chat et al., All rights reserved. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TomlDate = void 0; | ||
let DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i; | ||
class TomlDate extends Date { | ||
export class TomlDate extends Date { | ||
#hasDate = false; | ||
@@ -130,2 +127,1 @@ #hasTime = false; | ||
} | ||
exports.TomlDate = TomlDate; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
/*! | ||
@@ -29,4 +28,2 @@ * Copyright (c) Squirrel Chat et al., All rights reserved. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TomlError = void 0; | ||
function getLineColFromPtr(string, ptr) { | ||
@@ -55,3 +52,3 @@ let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g); | ||
} | ||
class TomlError extends Error { | ||
export class TomlError extends Error { | ||
line; | ||
@@ -69,2 +66,1 @@ column; | ||
} | ||
exports.TomlError = TomlError; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
/*! | ||
@@ -29,8 +28,6 @@ * Copyright (c) Squirrel Chat et al., All rights reserved. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extractValue = void 0; | ||
const primitive_js_1 = require("./primitive.js"); | ||
const struct_js_1 = require("./struct.js"); | ||
const util_js_1 = require("./util.js"); | ||
const error_js_1 = require("./error.js"); | ||
import { parseString, parseValue } from './primitive.js'; | ||
import { parseArray, parseInlineTable } from './struct.js'; | ||
import { indexOfNewline, skipVoid, skipUntil, skipComment, getStringEnd } from './util.js'; | ||
import { TomlError } from './error.js'; | ||
function sliceAndTrimEndOf(str, startPtr, endPtr, allowNewLines) { | ||
@@ -42,3 +39,3 @@ let value = str.slice(startPtr, endPtr); | ||
// (absence of control characters) | ||
(0, util_js_1.skipComment)(str, commentIdx); | ||
skipComment(str, commentIdx); | ||
value = value.slice(0, commentIdx); | ||
@@ -50,3 +47,3 @@ } | ||
if (newlineIdx > -1) { | ||
throw new error_js_1.TomlError('newlines are not allowed in inline tables', { | ||
throw new TomlError('newlines are not allowed in inline tables', { | ||
toml: str, | ||
@@ -59,13 +56,13 @@ ptr: startPtr + newlineIdx | ||
} | ||
function extractValue(str, ptr, end) { | ||
export function extractValue(str, ptr, end) { | ||
let c = str[ptr]; | ||
if (c === '[' || c === '{') { | ||
let [value, endPtr] = c === '[' | ||
? (0, struct_js_1.parseArray)(str, ptr) | ||
: (0, struct_js_1.parseInlineTable)(str, ptr); | ||
let newPtr = (0, util_js_1.skipUntil)(str, endPtr, ',', end); | ||
? parseArray(str, ptr) | ||
: parseInlineTable(str, ptr); | ||
let newPtr = skipUntil(str, endPtr, ',', end); | ||
if (end === '}') { | ||
let nextNewLine = (0, util_js_1.indexOfNewline)(str, endPtr, newPtr); | ||
let nextNewLine = indexOfNewline(str, endPtr, newPtr); | ||
if (nextNewLine > -1) { | ||
throw new error_js_1.TomlError('newlines are not allowed in inline tables', { | ||
throw new TomlError('newlines are not allowed in inline tables', { | ||
toml: str, | ||
@@ -80,8 +77,8 @@ ptr: nextNewLine | ||
if (c === '"' || c === "'") { | ||
endPtr = (0, util_js_1.getStringEnd)(str, ptr); | ||
let parsed = (0, primitive_js_1.parseString)(str, ptr, endPtr); | ||
endPtr = getStringEnd(str, ptr); | ||
let parsed = parseString(str, ptr, endPtr); | ||
if (end) { | ||
endPtr = (0, util_js_1.skipVoid)(str, endPtr, end !== ']'); | ||
endPtr = skipVoid(str, endPtr, end !== ']'); | ||
if (str[endPtr] && str[endPtr] !== ',' && str[endPtr] !== end && str[endPtr] !== '\n' && str[endPtr] !== '\r') { | ||
throw new error_js_1.TomlError('unexpected character encountered', { | ||
throw new TomlError('unexpected character encountered', { | ||
toml: str, | ||
@@ -95,6 +92,6 @@ ptr: endPtr, | ||
} | ||
endPtr = (0, util_js_1.skipUntil)(str, ptr, ',', end); | ||
endPtr = skipUntil(str, ptr, ',', end); | ||
let slice = sliceAndTrimEndOf(str, ptr, endPtr - (+(str[endPtr - 1] === ',')), end === ']'); | ||
if (!slice[0]) { | ||
throw new error_js_1.TomlError('incomplete key-value declaration: no value specified', { | ||
throw new TomlError('incomplete key-value declaration: no value specified', { | ||
toml: str, | ||
@@ -105,10 +102,9 @@ ptr: ptr | ||
if (end && slice[1] > -1) { | ||
endPtr = (0, util_js_1.skipVoid)(str, ptr + slice[1]); | ||
endPtr = skipVoid(str, ptr + slice[1]); | ||
endPtr += +(str[endPtr] === ','); | ||
} | ||
return [ | ||
(0, primitive_js_1.parseValue)(slice[0], str, ptr), | ||
parseValue(slice[0], str, ptr), | ||
endPtr, | ||
]; | ||
} | ||
exports.extractValue = extractValue; |
@@ -28,6 +28,14 @@ /*! | ||
*/ | ||
export { TomlError } from './error.js'; | ||
export { TomlDate } from './date.js'; | ||
export { parse } from './parse.js'; | ||
export { stringify } from './stringify.js'; | ||
import { parse } from './parse.js'; | ||
import { stringify } from './stringify.js'; | ||
import { TomlDate } from './date.js'; | ||
import { TomlError } from './error.js'; | ||
export type { TomlPrimitive } from './util.js'; | ||
declare const _default: { | ||
parse: typeof parse; | ||
stringify: typeof stringify; | ||
TomlDate: typeof TomlDate; | ||
TomlError: typeof TomlError; | ||
}; | ||
export default _default; | ||
export { parse, stringify, TomlDate, TomlError }; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
/*! | ||
@@ -29,11 +28,7 @@ * Copyright (c) Squirrel Chat et al., All rights reserved. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stringify = exports.parse = exports.TomlDate = exports.TomlError = void 0; | ||
var error_js_1 = require("./error.js"); | ||
Object.defineProperty(exports, "TomlError", { enumerable: true, get: function () { return error_js_1.TomlError; } }); | ||
var date_js_1 = require("./date.js"); | ||
Object.defineProperty(exports, "TomlDate", { enumerable: true, get: function () { return date_js_1.TomlDate; } }); | ||
var parse_js_1 = require("./parse.js"); | ||
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parse_js_1.parse; } }); | ||
var stringify_js_1 = require("./stringify.js"); | ||
Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return stringify_js_1.stringify; } }); | ||
import { parse } from './parse.js'; | ||
import { stringify } from './stringify.js'; | ||
import { TomlDate } from './date.js'; | ||
import { TomlError } from './error.js'; | ||
export default { parse, stringify, TomlDate, TomlError }; | ||
export { parse, stringify, TomlDate, TomlError }; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
/*! | ||
@@ -29,8 +28,6 @@ * Copyright (c) Squirrel Chat et al., All rights reserved. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parse = void 0; | ||
const struct_js_1 = require("./struct.js"); | ||
const extract_js_1 = require("./extract.js"); | ||
const util_js_1 = require("./util.js"); | ||
const error_js_1 = require("./error.js"); | ||
import { parseKey } from './struct.js'; | ||
import { extractValue } from './extract.js'; | ||
import { skipVoid } from './util.js'; | ||
import { TomlError } from './error.js'; | ||
function peekTable(key, table, meta, type) { | ||
@@ -100,3 +97,3 @@ let t = table; | ||
} | ||
function parse(toml) { | ||
export function parse(toml) { | ||
let res = {}; | ||
@@ -106,9 +103,9 @@ let meta = {}; | ||
let m = meta; | ||
for (let ptr = (0, util_js_1.skipVoid)(toml, 0); ptr < toml.length;) { | ||
for (let ptr = skipVoid(toml, 0); ptr < toml.length;) { | ||
if (toml[ptr] === '[') { | ||
let isTableArray = toml[++ptr] === '['; | ||
let k = (0, struct_js_1.parseKey)(toml, ptr += +isTableArray, ']'); | ||
let k = parseKey(toml, ptr += +isTableArray, ']'); | ||
if (isTableArray) { | ||
if (toml[k[1] - 1] !== ']') { | ||
throw new error_js_1.TomlError('expected end of table declaration', { | ||
throw new TomlError('expected end of table declaration', { | ||
toml: toml, | ||
@@ -122,3 +119,3 @@ ptr: k[1] - 1, | ||
if (!p) { | ||
throw new error_js_1.TomlError('trying to redefine an already defined table or value', { | ||
throw new TomlError('trying to redefine an already defined table or value', { | ||
toml: toml, | ||
@@ -133,6 +130,6 @@ ptr: ptr, | ||
else { | ||
let k = (0, struct_js_1.parseKey)(toml, ptr); | ||
let k = parseKey(toml, ptr); | ||
let p = peekTable(k[0], tbl, m, 0 /* Type.DOTTED */); | ||
if (!p) { | ||
throw new error_js_1.TomlError('trying to redefine an already defined table or value', { | ||
throw new TomlError('trying to redefine an already defined table or value', { | ||
toml: toml, | ||
@@ -142,9 +139,9 @@ ptr: ptr, | ||
} | ||
let v = (0, extract_js_1.extractValue)(toml, k[1]); | ||
let v = extractValue(toml, k[1]); | ||
p[1][p[0]] = v[0]; | ||
ptr = v[1]; | ||
} | ||
ptr = (0, util_js_1.skipVoid)(toml, ptr, true); | ||
ptr = skipVoid(toml, ptr, true); | ||
if (toml[ptr] && toml[ptr] !== '\n' && toml[ptr] !== '\r') { | ||
throw new error_js_1.TomlError('each key-value declaration must be followed by an end-of-line', { | ||
throw new TomlError('each key-value declaration must be followed by an end-of-line', { | ||
toml: toml, | ||
@@ -154,6 +151,5 @@ ptr: ptr | ||
} | ||
ptr = (0, util_js_1.skipVoid)(toml, ptr); | ||
ptr = skipVoid(toml, ptr); | ||
} | ||
return res; | ||
} | ||
exports.parse = parse; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
/*! | ||
@@ -29,7 +28,5 @@ * Copyright (c) Squirrel Chat et al., All rights reserved. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseValue = exports.parseString = void 0; | ||
const util_js_1 = require("./util.js"); | ||
const date_js_1 = require("./date.js"); | ||
const error_js_1 = require("./error.js"); | ||
import { skipVoid } from './util.js'; | ||
import { TomlDate } from './date.js'; | ||
import { TomlError } from './error.js'; | ||
let INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/; | ||
@@ -48,3 +45,3 @@ let FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/; | ||
}; | ||
function parseString(str, ptr = 0, endPtr = str.length) { | ||
export function parseString(str, ptr = 0, endPtr = str.length) { | ||
let isLiteral = str[ptr] === "'"; | ||
@@ -67,3 +64,3 @@ let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1]; | ||
if (!isMultiline) { | ||
throw new error_js_1.TomlError('newlines are not allowed in strings', { | ||
throw new TomlError('newlines are not allowed in strings', { | ||
toml: str, | ||
@@ -75,3 +72,3 @@ ptr: ptr - 1 | ||
else if ((c < '\x20' && c !== '\t') || c === '\x7f') { | ||
throw new error_js_1.TomlError('control characters are not allowed in strings', { | ||
throw new TomlError('control characters are not allowed in strings', { | ||
toml: str, | ||
@@ -87,3 +84,3 @@ ptr: ptr - 1 | ||
if (!ESCAPE_REGEX.test(code)) { | ||
throw new error_js_1.TomlError('invalid unicode escape', { | ||
throw new TomlError('invalid unicode escape', { | ||
toml: str, | ||
@@ -97,3 +94,3 @@ ptr: tmp | ||
catch { | ||
throw new error_js_1.TomlError('invalid unicode escape', { | ||
throw new TomlError('invalid unicode escape', { | ||
toml: str, | ||
@@ -106,5 +103,5 @@ ptr: tmp | ||
// Multiline escape | ||
ptr = (0, util_js_1.skipVoid)(str, ptr - 1, true); | ||
ptr = skipVoid(str, ptr - 1, true); | ||
if (str[ptr] !== '\n' && str[ptr] !== '\r') { | ||
throw new error_js_1.TomlError('invalid escape: only line-ending whitespace may be escaped', { | ||
throw new TomlError('invalid escape: only line-ending whitespace may be escaped', { | ||
toml: str, | ||
@@ -114,3 +111,3 @@ ptr: tmp | ||
} | ||
ptr = (0, util_js_1.skipVoid)(str, ptr); | ||
ptr = skipVoid(str, ptr); | ||
} | ||
@@ -122,3 +119,3 @@ else if (c in ESC_MAP) { | ||
else { | ||
throw new error_js_1.TomlError('unrecognized escape sequence', { | ||
throw new TomlError('unrecognized escape sequence', { | ||
toml: str, | ||
@@ -138,4 +135,3 @@ ptr: tmp | ||
} | ||
exports.parseString = parseString; | ||
function parseValue(value, toml, ptr) { | ||
export function parseValue(value, toml, ptr) { | ||
// Constant values | ||
@@ -158,3 +154,3 @@ if (value === 'true') | ||
if (LEADING_ZERO.test(value)) { | ||
throw new error_js_1.TomlError('leading zeroes are not allowed', { | ||
throw new TomlError('leading zeroes are not allowed', { | ||
toml: toml, | ||
@@ -166,3 +162,3 @@ ptr: ptr | ||
if (isNaN(numeric)) { | ||
throw new error_js_1.TomlError('invalid number', { | ||
throw new TomlError('invalid number', { | ||
toml: toml, | ||
@@ -173,3 +169,3 @@ ptr: ptr | ||
if (isInt && !Number.isSafeInteger(numeric)) { | ||
throw new error_js_1.TomlError('integer value cannot be represented losslessly', { | ||
throw new TomlError('integer value cannot be represented losslessly', { | ||
toml: toml, | ||
@@ -181,5 +177,5 @@ ptr: ptr | ||
} | ||
let date = new date_js_1.TomlDate(value); | ||
let date = new TomlDate(value); | ||
if (!date.isValid()) { | ||
throw new error_js_1.TomlError('invalid value', { | ||
throw new TomlError('invalid value', { | ||
toml: toml, | ||
@@ -191,2 +187,1 @@ ptr: ptr | ||
} | ||
exports.parseValue = parseValue; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
/*! | ||
@@ -29,4 +28,2 @@ * Copyright (c) Squirrel Chat et al., All rights reserved. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stringify = void 0; | ||
const BARE_KEY = /^[a-z0-9-_]+$/i; | ||
@@ -151,3 +148,3 @@ function extendedTypeOf(obj) { | ||
} | ||
function stringify(obj) { | ||
export function stringify(obj) { | ||
if (extendedTypeOf(obj) !== 'object') { | ||
@@ -158,2 +155,1 @@ throw new TypeError('stringify can only be called with an object'); | ||
} | ||
exports.stringify = stringify; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
/*! | ||
@@ -29,10 +28,8 @@ * Copyright (c) Squirrel Chat et al., All rights reserved. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseArray = exports.parseInlineTable = exports.parseKey = void 0; | ||
const primitive_js_1 = require("./primitive.js"); | ||
const extract_js_1 = require("./extract.js"); | ||
const util_js_1 = require("./util.js"); | ||
const error_js_1 = require("./error.js"); | ||
import { parseString } from './primitive.js'; | ||
import { extractValue } from './extract.js'; | ||
import { skipComment, indexOfNewline, getStringEnd, skipVoid } from './util.js'; | ||
import { TomlError } from './error.js'; | ||
let KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/; | ||
function parseKey(str, ptr, end = '=') { | ||
export function parseKey(str, ptr, end = '=') { | ||
let dot = ptr - 1; | ||
@@ -42,3 +39,3 @@ let parsed = []; | ||
if (endPtr < 0) { | ||
throw new error_js_1.TomlError('incomplete key-value: cannot find end of key', { | ||
throw new TomlError('incomplete key-value: cannot find end of key', { | ||
toml: str, | ||
@@ -55,3 +52,3 @@ ptr: ptr | ||
if (c === str[ptr + 1] && c === str[ptr + 2]) { | ||
throw new error_js_1.TomlError('multiline strings are not allowed in keys', { | ||
throw new TomlError('multiline strings are not allowed in keys', { | ||
toml: str, | ||
@@ -61,5 +58,5 @@ ptr: ptr, | ||
} | ||
let eos = (0, util_js_1.getStringEnd)(str, ptr); | ||
let eos = getStringEnd(str, ptr); | ||
if (eos < 0) { | ||
throw new error_js_1.TomlError('unfinished string encountered', { | ||
throw new TomlError('unfinished string encountered', { | ||
toml: str, | ||
@@ -71,5 +68,5 @@ ptr: ptr, | ||
let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot); | ||
let newLine = (0, util_js_1.indexOfNewline)(strEnd); | ||
let newLine = indexOfNewline(strEnd); | ||
if (newLine > -1) { | ||
throw new error_js_1.TomlError('newlines are not allowed in keys', { | ||
throw new TomlError('newlines are not allowed in keys', { | ||
toml: str, | ||
@@ -80,3 +77,3 @@ ptr: ptr + dot + newLine, | ||
if (strEnd.trimStart()) { | ||
throw new error_js_1.TomlError('found extra tokens after the string part', { | ||
throw new TomlError('found extra tokens after the string part', { | ||
toml: str, | ||
@@ -89,3 +86,3 @@ ptr: eos, | ||
if (endPtr < 0) { | ||
throw new error_js_1.TomlError('incomplete key-value: cannot find end of key', { | ||
throw new TomlError('incomplete key-value: cannot find end of key', { | ||
toml: str, | ||
@@ -96,3 +93,3 @@ ptr: ptr, | ||
} | ||
parsed.push((0, primitive_js_1.parseString)(str, ptr, eos)); | ||
parsed.push(parseString(str, ptr, eos)); | ||
} | ||
@@ -104,3 +101,3 @@ else { | ||
if (!KEY_PART_RE.test(part)) { | ||
throw new error_js_1.TomlError('only letter, numbers, dashes and underscores are allowed in keys', { | ||
throw new TomlError('only letter, numbers, dashes and underscores are allowed in keys', { | ||
toml: str, | ||
@@ -115,6 +112,5 @@ ptr: ptr, | ||
} while (dot + 1 && dot < endPtr); | ||
return [parsed, (0, util_js_1.skipVoid)(str, endPtr + 1, true, true)]; | ||
return [parsed, skipVoid(str, endPtr + 1, true, true)]; | ||
} | ||
exports.parseKey = parseKey; | ||
function parseInlineTable(str, ptr) { | ||
export function parseInlineTable(str, ptr) { | ||
let res = {}; | ||
@@ -127,3 +123,3 @@ let seen = new Set(); | ||
if (c === '\n') { | ||
throw new error_js_1.TomlError('newlines are not allowed in inline tables', { | ||
throw new TomlError('newlines are not allowed in inline tables', { | ||
toml: str, | ||
@@ -134,3 +130,3 @@ ptr: ptr - 1 | ||
else if (c === '#') { | ||
throw new error_js_1.TomlError('inline tables cannot contain comments', { | ||
throw new TomlError('inline tables cannot contain comments', { | ||
toml: str, | ||
@@ -141,3 +137,3 @@ ptr: ptr - 1 | ||
else if (c === ',') { | ||
throw new error_js_1.TomlError('expected key-value, found comma', { | ||
throw new TomlError('expected key-value, found comma', { | ||
toml: str, | ||
@@ -157,3 +153,3 @@ ptr: ptr - 1 | ||
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== 'object' || seen.has(t[k]))) { | ||
throw new error_js_1.TomlError('trying to redefine an already defined value', { | ||
throw new TomlError('trying to redefine an already defined value', { | ||
toml: str, | ||
@@ -168,3 +164,3 @@ ptr: ptr | ||
if (hasOwn) { | ||
throw new error_js_1.TomlError('trying to redefine an already defined value', { | ||
throw new TomlError('trying to redefine an already defined value', { | ||
toml: str, | ||
@@ -174,3 +170,3 @@ ptr: ptr | ||
} | ||
let [value, valueEndPtr] = (0, extract_js_1.extractValue)(str, keyEndPtr, '}'); | ||
let [value, valueEndPtr] = extractValue(str, keyEndPtr, '}'); | ||
seen.add(value); | ||
@@ -183,3 +179,3 @@ t[k] = value; | ||
if (comma) { | ||
throw new error_js_1.TomlError('trailing commas are not allowed in inline tables', { | ||
throw new TomlError('trailing commas are not allowed in inline tables', { | ||
toml: str, | ||
@@ -190,3 +186,3 @@ ptr: comma | ||
if (!c) { | ||
throw new error_js_1.TomlError('unfinished table encountered', { | ||
throw new TomlError('unfinished table encountered', { | ||
toml: str, | ||
@@ -198,4 +194,3 @@ ptr: ptr | ||
} | ||
exports.parseInlineTable = parseInlineTable; | ||
function parseArray(str, ptr) { | ||
export function parseArray(str, ptr) { | ||
let res = []; | ||
@@ -206,3 +201,3 @@ let c; | ||
if (c === ',') { | ||
throw new error_js_1.TomlError('expected value, found comma', { | ||
throw new TomlError('expected value, found comma', { | ||
toml: str, | ||
@@ -213,5 +208,5 @@ ptr: ptr - 1 | ||
else if (c === '#') | ||
ptr = (0, util_js_1.skipComment)(str, ptr); | ||
ptr = skipComment(str, ptr); | ||
else if (c !== ' ' && c !== '\t' && c !== '\n' && c !== '\r') { | ||
let e = (0, extract_js_1.extractValue)(str, ptr - 1, ']'); | ||
let e = extractValue(str, ptr - 1, ']'); | ||
res.push(e[0]); | ||
@@ -222,3 +217,3 @@ ptr = e[1]; | ||
if (!c) { | ||
throw new error_js_1.TomlError('unfinished array encountered', { | ||
throw new TomlError('unfinished array encountered', { | ||
toml: str, | ||
@@ -230,2 +225,1 @@ ptr: ptr | ||
} | ||
exports.parseArray = parseArray; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
/*! | ||
@@ -29,6 +28,4 @@ * Copyright (c) Squirrel Chat et al., All rights reserved. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getStringEnd = exports.skipUntil = exports.skipVoid = exports.skipComment = exports.indexOfNewline = void 0; | ||
const error_js_1 = require("./error.js"); | ||
function indexOfNewline(str, start = 0, end = str.length) { | ||
import { TomlError } from './error.js'; | ||
export function indexOfNewline(str, start = 0, end = str.length) { | ||
let idx = str.indexOf('\n', start); | ||
@@ -39,4 +36,3 @@ if (str[idx - 1] === '\r') | ||
} | ||
exports.indexOfNewline = indexOfNewline; | ||
function skipComment(str, ptr) { | ||
export function skipComment(str, ptr) { | ||
for (let i = ptr; i < str.length; i++) { | ||
@@ -49,3 +45,3 @@ let c = str[i]; | ||
if ((c < '\x20' && c !== '\t') || c === '\x7f') { | ||
throw new error_js_1.TomlError('control characters are not allowed in comments', { | ||
throw new TomlError('control characters are not allowed in comments', { | ||
toml: str, | ||
@@ -58,4 +54,3 @@ ptr: ptr, | ||
} | ||
exports.skipComment = skipComment; | ||
function skipVoid(str, ptr, banNewLines, banComments) { | ||
export function skipVoid(str, ptr, banNewLines, banComments) { | ||
let c; | ||
@@ -68,4 +63,3 @@ while ((c = str[ptr]) === ' ' || c === '\t' || (!banNewLines && (c === '\n' || c === '\r' && str[ptr + 1] === '\n'))) | ||
} | ||
exports.skipVoid = skipVoid; | ||
function skipUntil(str, ptr, sep, end, banNewLines = false) { | ||
export function skipUntil(str, ptr, sep, end, banNewLines = false) { | ||
if (!end) { | ||
@@ -90,3 +84,3 @@ ptr = indexOfNewline(str, ptr); | ||
} | ||
throw new error_js_1.TomlError('cannot find end of structure', { | ||
throw new TomlError('cannot find end of structure', { | ||
toml: str, | ||
@@ -96,4 +90,3 @@ ptr: ptr | ||
} | ||
exports.skipUntil = skipUntil; | ||
function getStringEnd(str, seek) { | ||
export function getStringEnd(str, seek) { | ||
let first = str[seek]; | ||
@@ -118,2 +111,1 @@ let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] | ||
} | ||
exports.getStringEnd = getStringEnd; |
{ | ||
"name": "smol-toml", | ||
"version": "1.2.2", | ||
"license": "BSD-3-Clause", | ||
"version": "1.3.0", | ||
"description": "A small, fast, and correct TOML parser/serializer", | ||
"author": "Cynthia <cyyynthia@borkenware.com>", | ||
"repository": "github:squirrelchat/smol-toml", | ||
"bugs": "https://github.com/squirrelchat/smol-toml/issues", | ||
"funding": "https://github.com/sponsors/cyyynthia", | ||
"keywords": [ | ||
@@ -9,9 +15,4 @@ "toml", | ||
], | ||
"description": "A small, fast, and correct TOML parser/serializer", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://git@github.com/squirrelchat/smol-toml.git" | ||
}, | ||
"author": "Cynthia <cyyynthia@borkenware.com>", | ||
"license": "BSD-3-Clause", | ||
"type": "module", | ||
"packageManager": "pnpm@9.4.0", | ||
"engines": { | ||
@@ -21,6 +22,8 @@ "node": ">= 18" | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "vitest", | ||
"test-ui": "vitest --ui", | ||
"bench": "vitest bench" | ||
"bench": "vitest bench", | ||
"build": "pnpm run build:mjs && pnpm run build:cjs && node test/package/package-test.mjs", | ||
"build:mjs": "tsc", | ||
"build:cjs": "esbuild dist/index.js --bundle --platform=node --target=node18 --format=cjs --outfile=dist/index.cjs" | ||
}, | ||
@@ -32,10 +35,17 @@ "devDependencies": { | ||
"@tsconfig/strictest": "^2.0.5", | ||
"@types/node": "^20.12.11", | ||
"@vitest/ui": "^1.6.0", | ||
"@types/node": "^20.14.10", | ||
"@vitest/ui": "^2.0.3", | ||
"esbuild": "^0.23.0", | ||
"fast-toml": "^0.5.4", | ||
"typescript": "^5.4.5", | ||
"vitest": "^1.6.0" | ||
"typescript": "^5.5.3", | ||
"vitest": "^2.0.3" | ||
}, | ||
"main": "./dist/index.js", | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.js", | ||
"require": "./dist/index.cjs" | ||
}, | ||
"files": [ | ||
@@ -42,0 +52,0 @@ "README.md", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
97278
22
2279
Yes
10
1