Path: blob/main/components/gitpod-protocol/src/util/stringify.ts
2500 views
/**1* Copyright (c) 2024 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56export namespace BigIntToJson {7export const BIGINT_KEY = "bigint:";8export function replacer(key: string, value: any) {9if (typeof value === "bigint") {10return `${BIGINT_KEY}${value.toString()}`;11}12return value;13}14export function reviver(key: string, value: any) {15if (typeof value === "string" && value.startsWith(BIGINT_KEY)) {16const v: string = value.substring(7);17return BigInt(v);18}19return value;20}21}222324