diff --git a/src/index.ts b/src/index.ts index fbe6d6b..106a12d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,7 +28,7 @@ import { parseKey } from './struct.js' import { extractValue } from './parse.js' -import { type TomlPrimitive, skipVoid, peekTable as _peekTable } from './util.js' +import { type TomlPrimitive, skipVoid } from './util.js' import TomlError from './error.js' export { default as TomlDate } from './date.js' diff --git a/src/util.ts b/src/util.ts index ba9606e..406a63e 100644 --- a/src/util.ts +++ b/src/util.ts @@ -115,36 +115,3 @@ export function getStringEnd (str: string, seek: number) { return seek } - -let DESCRIPTOR = { enumerable: true, configurable: true, writable: true } -export function peekTable (table: Record, key: string[], seen: Set, allowSuper?: boolean): [ string, Record ] | null { - let k = '' - let v - let hasOwn - let hadOwn - for (let i = 0; i < key.length; i++) { - if (i) { - if (!(hadOwn = hasOwn)) { - if (k === '__proto__') Object.defineProperty(table, k, DESCRIPTOR) - table[k] = {} - } - - table = table[k] - if (Array.isArray(table)) table = table[table.length - 1] - } - - k = key[i]! - hasOwn = Object.hasOwn(table, k) - v = hasOwn ? table[k] : void 0 - if (v !== void 0 && (typeof v !== 'object' || seen.has(v))) { - return null - } - } - - if (hasOwn && (!allowSuper || (hadOwn && !Array.isArray(v)))) { - return null - } - - if (!hasOwn && k === '__proto__') Object.defineProperty(table, k, DESCRIPTOR) - return [ k, table ] -}