UNPKG

@messari/sdk

Version:

Messari SDK provides a type-safe, intuitive interface for accessing Messari's suite of crypto data and AI APIs.

37 lines 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isObject = exports.pick = exports.assertNever = void 0; /** * Utility for enforcing exhaustiveness checks in the type system. * * @see https://basarat.gitbook.io/typescript/type-system/discriminated-unions#throw-in-exhaustive-checks * * @param value The variable with no remaining values */ const assertNever = (value) => { throw new Error(`Unexpected value should never occur: ${value}`); }; exports.assertNever = assertNever; /** * Utility for picking specific keys from an object. * * @param base The object to pick keys from. * @param keys The keys to pick from the object. * @returns A new object containing only the picked keys. */ const pick = (base, keys) => { const entries = keys.map((key) => [key, base?.[key]]).filter(([_, value]) => value !== undefined); return Object.fromEntries(entries); }; exports.pick = pick; /** * Utility for checking if a value is an object. * * @param o The value to check. * @returns True if the value is an object, false otherwise. */ const isObject = (o) => { return typeof o === "object" && o !== null; }; exports.isObject = isObject; //# sourceMappingURL=utils.js.map