UNPKG

981 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.intersect_ = exports.memoize = void 0;
4/**
5 * @since 2.2.0
6 */
7function memoize(f) {
8 var cache = new Map();
9 return function (a) {
10 if (!cache.has(a)) {
11 var b = f(a);
12 cache.set(a, b);
13 return b;
14 }
15 return cache.get(a);
16 };
17}
18exports.memoize = memoize;
19// -------------------------------------------------------------------------------------
20// utils
21// -------------------------------------------------------------------------------------
22var typeOf = function (x) { return (x === null ? 'null' : typeof x); };
23/**
24 * @internal
25 */
26var intersect_ = function (a, b) {
27 if (a !== undefined && b !== undefined) {
28 var tx = typeOf(a);
29 var ty = typeOf(b);
30 if (tx === 'object' || ty === 'object') {
31 return Object.assign({}, a, b);
32 }
33 }
34 return b;
35};
36exports.intersect_ = intersect_;