UNPKG

@bemedev/decompose

Version:
29 lines (28 loc) 1.07 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const require_decompose = require("../decompose.cjs"); const require_contexts_constants = require("./constants.cjs"); //#region src/contexts/get.ts const _getByKey = (obj, key) => { return require_decompose.decompose.low(obj, require_contexts_constants.DEFAULT_OPTIONS)[key]; }; /** * Retrieves a value from an object by a specified key. * @param obj The object to retrieve the value from * @param key The key to retrieve the value for, can be a nested key (e.g. 'a.b.c') * @returns The value associated with the specified key in the object * * @see {@linkcode Decompose} for more details on object decomposition. */ const getByKey = (obj, key) => _getByKey(obj, key); getByKey.low = getByKey; getByKey.typed = getByKey; getByKey.defined = getByKey; getByKey.options = (options) => (obj, key) => { return require_decompose.decompose.low(obj, { ...require_contexts_constants.DEFAULT_OPTIONS, ...options })[key]; }; //#endregion exports.getByKey = getByKey; //# sourceMappingURL=get.cjs.map