Innovenergy_trunk/frontend/node_modules/io-ts/lib/Schemable.js

37 lines
981 B
JavaScript
Raw Normal View History

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.intersect_ = exports.memoize = void 0;
/**
* @since 2.2.0
*/
function memoize(f) {
var cache = new Map();
return function (a) {
if (!cache.has(a)) {
var b = f(a);
cache.set(a, b);
return b;
}
return cache.get(a);
};
}
exports.memoize = memoize;
// -------------------------------------------------------------------------------------
// utils
// -------------------------------------------------------------------------------------
var typeOf = function (x) { return (x === null ? 'null' : typeof x); };
/**
* @internal
*/
var intersect_ = function (a, b) {
if (a !== undefined && b !== undefined) {
var tx = typeOf(a);
var ty = typeOf(b);
if (tx === 'object' || ty === 'object') {
return Object.assign({}, a, b);
}
}
return b;
};
exports.intersect_ = intersect_;