Skip to content

Commit

Permalink
fix: remove leftover deadcode
Browse files Browse the repository at this point in the history
  • Loading branch information
cyyynthia committed May 18, 2023
1 parent 1021f27 commit 340636e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
33 changes: 0 additions & 33 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>, key: string[], seen: Set<any>, allowSuper?: boolean): [ string, Record<string, any> ] | 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 ]
}

0 comments on commit 340636e

Please sign in to comment.