lambda-live-debugger
Version:
Debug Lambda functions locally like it is running in the cloud
19 lines (18 loc) • 672 B
JavaScript
import { NumericValue } from "@smithy/core/serde";
export function jsonReviver(key, value, context) {
if (context?.source) {
const numericString = context.source;
if (typeof value === "number") {
if (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER || numericString !== String(value)) {
const isFractional = numericString.includes(".");
if (isFractional) {
return new NumericValue(numericString, "bigDecimal");
}
else {
return BigInt(numericString);
}
}
}
}
return value;
}