1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.removeUndefinedValuesFromObject = exports.getPropertyByPath = exports.emplace = void 0;
|
4 |
|
5 |
|
6 |
|
7 | function emplace(map, key, fn) {
|
8 | const cached = map.get(key);
|
9 | if (cached !== undefined) {
|
10 | return cached;
|
11 | }
|
12 | const result = fn();
|
13 | map.set(key, result);
|
14 | return result;
|
15 | }
|
16 | exports.emplace = emplace;
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | function getPropertyByPath(source, path) {
|
26 | if (typeof path === 'string' &&
|
27 | Object.prototype.hasOwnProperty.call(source, path)) {
|
28 | return source[path];
|
29 | }
|
30 | const parsedPath = typeof path === 'string' ? path.split('.') : path;
|
31 |
|
32 | return parsedPath.reduce((previous, key) => {
|
33 | if (previous === undefined) {
|
34 | return previous;
|
35 | }
|
36 | return previous[key];
|
37 | }, source);
|
38 | }
|
39 | exports.getPropertyByPath = getPropertyByPath;
|
40 |
|
41 | function removeUndefinedValuesFromObject(options) {
|
42 |
|
43 | if (!options) {
|
44 | return undefined;
|
45 | }
|
46 | return Object.fromEntries(Object.entries(options).filter(([, value]) => value !== undefined));
|
47 | }
|
48 | exports.removeUndefinedValuesFromObject = removeUndefinedValuesFromObject;
|
49 |
|
\ | No newline at end of file |