Files
NapCatQQ/.pnpm-store/v3/files/4f/10b66a492e56762e711b7379f27f34595c9c37d925e50d348db45d86e042298030753365b6d21a38a70ac469687bd78e21ad46545fea38ddf5c14493c256b6
T
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

58 lines
1.8 KiB
Plaintext

/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { CALL, CONSTRUCT, READ } = require("@eslint-community/eslint-utils")
const unprefixNodeColon = require("./unprefix-node-colon")
/** @typedef {import('../unsupported-features/types.js').DeprecatedInfoTraceMap} DeprecatedInfoTraceMap */
/** @typedef {import('../unsupported-features/types.js').SupportVersionTraceMap} SupportVersionTraceMap */
/**
* @template {SupportVersionTraceMap | DeprecatedInfoTraceMap} TraceMap
* Enumerate property names of a given object recursively.
* @param {TraceMap} traceMap The map for APIs to enumerate.
* @param {string[]} [path] The path to the current map.
* @param {{ [key: string]: WeakSet<TraceMap> }} [recursion] An object to block recursion (per module)
* @returns {IterableIterator<string>} The property names of the map.
*/
function* enumeratePropertyNames(traceMap, path = [], recursion = {}) {
const recursionSet =
typeof path[0] === "string"
? (recursion[path[0]] ??= new WeakSet())
: undefined
if (recursionSet?.has(traceMap)) {
return
}
for (const key of Object.getOwnPropertyNames(traceMap)) {
const childValue = traceMap[key]
const childPath = [...path, key]
const childName = unprefixNodeColon(childPath.join("."))
if (childValue == null) {
continue
}
if (childValue[CALL]) {
yield `${childName}()`
}
if (childValue[CONSTRUCT]) {
yield `new ${childName}()`
}
if (childValue[READ]) {
yield childName
}
recursionSet?.add(traceMap)
yield* enumeratePropertyNames(childValue, childPath, recursion)
}
}
module.exports = enumeratePropertyNames