PHP 8.2.30
Preview: to-json.js Size: 1.53 KB
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/@jsdevtools/ono/esm/to-json.js

const nonJsonTypes = ["function", "symbol", "undefined"];
const protectedProps = ["constructor", "prototype", "__proto__"];
const objectPrototype = Object.getPrototypeOf({});
/**
 * Custom JSON serializer for Error objects.
 * Returns all built-in error properties, as well as extended properties.
 */
export function toJSON() {
    // HACK: We have to cast the objects to `any` so we can use symbol indexers.
    // see https://github.com/Microsoft/TypeScript/issues/1863
    let pojo = {};
    let error = this;
    for (let key of getDeepKeys(error)) {
        if (typeof key === "string") {
            let value = error[key];
            let type = typeof value;
            if (!nonJsonTypes.includes(type)) {
                pojo[key] = value;
            }
        }
    }
    return pojo;
}
/**
 * Returns own, inherited, enumerable, non-enumerable, string, and symbol keys of `obj`.
 * Does NOT return members of the base Object prototype, or the specified omitted keys.
 */
export function getDeepKeys(obj, omit = []) {
    let keys = [];
    // Crawl the prototype chain, finding all the string and symbol keys
    while (obj && obj !== objectPrototype) {
        keys = keys.concat(Object.getOwnPropertyNames(obj), Object.getOwnPropertySymbols(obj));
        obj = Object.getPrototypeOf(obj);
    }
    // De-duplicate the list of keys
    let uniqueKeys = new Set(keys);
    // Remove any omitted keys
    for (let key of omit.concat(protectedProps)) {
        uniqueKeys.delete(key);
    }
    return uniqueKeys;
}
//# sourceMappingURL=to-json.js.map

Directory Contents

Dirs: 0 × Files: 30

Name Size Perms Modified Actions
116 B lrw-r--r-- 2026-02-23 15:45:46
Edit Download
1.57 KB lrw-r--r-- 2026-02-23 15:45:44
Edit Download
1.20 KB lrw-r--r-- 2026-02-23 15:45:46
Edit Download
482 B lrw-r--r-- 2026-02-23 15:45:46
Edit Download
2.84 KB lrw-r--r-- 2026-02-23 15:45:44
Edit Download
1.64 KB lrw-r--r-- 2026-02-23 15:45:46
Edit Download
133 B lrw-r--r-- 2026-02-23 15:45:46
Edit Download
374 B lrw-r--r-- 2026-02-23 15:45:44
Edit Download
458 B lrw-r--r-- 2026-02-23 15:45:46
Edit Download
574 B lrw-r--r-- 2026-02-23 15:45:46
Edit Download
604 B lrw-r--r-- 2026-02-23 15:45:44
Edit Download
239 B lrw-r--r-- 2026-02-23 15:45:46
Edit Download
523 B lrw-r--r-- 2026-02-23 15:45:48
Edit Download
1.53 KB lrw-r--r-- 2026-02-23 15:45:44
Edit Download
853 B lrw-r--r-- 2026-02-23 15:45:46
Edit Download
507 B lrw-r--r-- 2026-02-23 15:45:48
Edit Download
1.70 KB lrw-r--r-- 2026-02-23 15:45:44
Edit Download
1.60 KB lrw-r--r-- 2026-02-23 15:45:46
Edit Download
108 B lrw-r--r-- 2026-02-23 15:45:48
Edit Download
1.46 KB lrw-r--r-- 2026-02-23 15:45:44
Edit Download
1.29 KB lrw-r--r-- 2026-02-23 15:45:46
Edit Download
933 B lrw-r--r-- 2026-02-23 15:45:48
Edit Download
2.98 KB lrw-r--r-- 2026-02-23 15:45:46
Edit Download
2.14 KB lrw-r--r-- 2026-02-23 15:45:46
Edit Download
540 B lrw-r--r-- 2026-02-23 15:45:48
Edit Download
1.53 KB lrw-r--r-- 2026-02-23 15:45:46
Edit Download
1.22 KB lrw-r--r-- 2026-02-23 15:45:46
Edit Download
8.09 KB lrw-r--r-- 2026-02-23 15:45:48
Edit Download
65 B lrw-r--r-- 2026-02-23 15:45:46
Edit Download
141 B lrw-r--r-- 2026-02-23 15:45:46
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).