UNPKG

@enre/pop-runtypes

Version:

runtypes for validating data using simple-runtypes

28 lines (27 loc) 856 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getOrUndefined = void 0; // export function getOrDefault<T, U extends {}>(foo: st.Runtype<T>, v: unknown, defaultValue: T, result: U, key: string) { // // { // let newResult: U & { [key: string]: T }; // try { // const baz = foo(v); // newResult = { ...result, [key]: baz } // return { ...result, ...baz }; // } // catch { // return { ...result, }; // } // } function getOrUndefined(foo, v) { try { const value = foo(v); return value; } catch (_a) { return undefined; } } exports.getOrUndefined = getOrUndefined; // export const ValueOrDefaultRuntype = st.runtype((v) => { }) // const baz = getOrDefault(HasIdDefinition.id, { foo: "bar" }, "blee", {bloop: "bleep"}, "poop");