UNPKG

lambda-live-debugger

Version:

Debug Lambda functions locally like it is running in the cloud

26 lines (25 loc) 808 B
const format = /^-?\d*(\.\d+)?$/; export class NumericValue { string; type; constructor(string, type) { this.string = string; this.type = type; if (!format.test(string)) { throw new Error(`@smithy/core/serde - NumericValue must only contain [0-9], at most one decimal point ".", and an optional negation prefix "-".`); } } toString() { return this.string; } static [Symbol.hasInstance](object) { if (!object || typeof object !== "object") { return false; } const _nv = object; return NumericValue.prototype.isPrototypeOf(object) || (_nv.type === "bigDecimal" && format.test(_nv.string)); } } export function nv(input) { return new NumericValue(String(input), "bigDecimal"); }