Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Dec 12, 2024
1 parent 9c2e742 commit ad6b20f
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions packages/npm/json-stable-stringify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { isArray: ArrayIsArray } = Array
const { isFinite: NumberIsFinite } = Number
const { freeze: ObjectFreeze, keys: ObjectKeys } = Object
const { /*freeze: ObjectFreeze,*/ keys: ObjectKeys } = Object
const { isRawJSON, stringify } = JSON

const SUPPORTS_ARRAY_PROTO_TO_SORTED =
Expand All @@ -20,26 +20,26 @@ const TYPE_VALUE = 1
const TYPE_OPEN = 2
const TYPE_CLOSE = 4

let callStackSizeExceededErrorDetails
//let callStackSizeExceededErrorDetails

function getCallStackSizeExceededErrorDetails() {
if (callStackSizeExceededErrorDetails === undefined) {
let limit = 0
try {
;(function r() {
limit += 1
r()
})()
} catch ({ constructor, message }) {
callStackSizeExceededErrorDetails = ObjectFreeze({
Ctor: constructor,
limit,
message
})
}
}
return callStackSizeExceededErrorDetails
}
// function getCallStackSizeExceededErrorDetails() {
// if (callStackSizeExceededErrorDetails === undefined) {
// let limit = 0
// try {
// ;(function r() {
// limit += 1
// r()
// })()
// } catch ({ constructor, message }) {
// callStackSizeExceededErrorDetails = ObjectFreeze({
// Ctor: constructor,
// limit,
// message
// })
// }
// }
// return callStackSizeExceededErrorDetails
// }

function stableStringifyNonRecursive(obj, cmp, cycles, replacer, space) {
let result = ''
Expand Down Expand Up @@ -246,8 +246,8 @@ module.exports = function stableStringify(obj, opts = {}) {
return stableStringifyRecursive(obj, cmp, cycles, replacer, space)
} catch (e) {
if (e) {
const { Ctor, message } = getCallStackSizeExceededErrorDetails()
if (e instanceof Ctor && e.message === message) {
// const { Ctor, message } = getCallStackSizeExceededErrorDetails()
if (e) {
callStackLimitTripped = true
return stableStringifyNonRecursive(obj, cmp, cycles, replacer, space)
}
Expand Down

0 comments on commit ad6b20f

Please sign in to comment.