🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
605
node_modules/deepmerge-ts/dist/node/index.cjs
generated
vendored
Normal file
605
node_modules/deepmerge-ts/dist/node/index.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,605 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
/**
|
||||
* Special values that tell deepmerge to perform a certain action.
|
||||
*/
|
||||
const actions = {
|
||||
defaultMerge: Symbol("deepmerge-ts: default merge"),
|
||||
skip: Symbol("deepmerge-ts: skip"),
|
||||
};
|
||||
/**
|
||||
* Special values that tell deepmergeInto to perform a certain action.
|
||||
*/
|
||||
const actionsInto = {
|
||||
defaultMerge: actions.defaultMerge,
|
||||
};
|
||||
|
||||
/**
|
||||
* The default function to update meta data.
|
||||
*/
|
||||
function defaultMetaDataUpdater(previousMeta, metaMeta) {
|
||||
return metaMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the given object.
|
||||
*
|
||||
* @param object - The object to get the type of.
|
||||
* @returns The type of the given object.
|
||||
*/
|
||||
function getObjectType(object) {
|
||||
if (typeof object !== "object" || object === null) {
|
||||
return 0 /* ObjectType.NOT */;
|
||||
}
|
||||
if (Array.isArray(object)) {
|
||||
return 2 /* ObjectType.ARRAY */;
|
||||
}
|
||||
if (isRecord(object)) {
|
||||
return 1 /* ObjectType.RECORD */;
|
||||
}
|
||||
if (object instanceof Set) {
|
||||
return 3 /* ObjectType.SET */;
|
||||
}
|
||||
if (object instanceof Map) {
|
||||
return 4 /* ObjectType.MAP */;
|
||||
}
|
||||
return 5 /* ObjectType.OTHER */;
|
||||
}
|
||||
/**
|
||||
* Get the keys of the given objects including symbol keys.
|
||||
*
|
||||
* Note: Only keys to enumerable properties are returned.
|
||||
*
|
||||
* @param objects - An array of objects to get the keys of.
|
||||
* @returns A set containing all the keys of all the given objects.
|
||||
*/
|
||||
function getKeys(objects) {
|
||||
const keys = new Set();
|
||||
/* eslint-disable functional/no-loop-statements -- using a loop here is more efficient. */
|
||||
for (const object of objects) {
|
||||
for (const key of [
|
||||
...Object.keys(object),
|
||||
...Object.getOwnPropertySymbols(object),
|
||||
]) {
|
||||
keys.add(key);
|
||||
}
|
||||
}
|
||||
/* eslint-enable functional/no-loop-statements */
|
||||
return keys;
|
||||
}
|
||||
/**
|
||||
* Does the given object have the given property.
|
||||
*
|
||||
* @param object - The object to test.
|
||||
* @param property - The property to test.
|
||||
* @returns Whether the object has the property.
|
||||
*/
|
||||
function objectHasProperty(object, property) {
|
||||
return (typeof object === "object" &&
|
||||
Object.prototype.propertyIsEnumerable.call(object, property));
|
||||
}
|
||||
/**
|
||||
* Get an iterable object that iterates over the given iterables.
|
||||
*/
|
||||
function getIterableOfIterables(iterables) {
|
||||
return {
|
||||
*[Symbol.iterator]() {
|
||||
// eslint-disable-next-line functional/no-loop-statements
|
||||
for (const iterable of iterables) {
|
||||
// eslint-disable-next-line functional/no-loop-statements
|
||||
for (const value of iterable) {
|
||||
yield value;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
const validRecordToStringValues = new Set([
|
||||
"[object Object]",
|
||||
"[object Module]",
|
||||
]);
|
||||
/**
|
||||
* Does the given object appear to be a record.
|
||||
*/
|
||||
function isRecord(value) {
|
||||
// All records are objects.
|
||||
if (!validRecordToStringValues.has(Object.prototype.toString.call(value))) {
|
||||
return false;
|
||||
}
|
||||
const { constructor } = value;
|
||||
// If has modified constructor.
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
if (constructor === undefined) {
|
||||
return true;
|
||||
}
|
||||
// eslint-disable-next-line prefer-destructuring
|
||||
const prototype = constructor.prototype;
|
||||
// If has modified prototype.
|
||||
if (prototype === null ||
|
||||
typeof prototype !== "object" ||
|
||||
!validRecordToStringValues.has(Object.prototype.toString.call(prototype))) {
|
||||
return false;
|
||||
}
|
||||
// If constructor does not have an Object-specific method.
|
||||
// eslint-disable-next-line sonarjs/prefer-single-boolean-return, no-prototype-builtins
|
||||
if (!prototype.hasOwnProperty("isPrototypeOf")) {
|
||||
return false;
|
||||
}
|
||||
// Most likely a record.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default strategy to merge records.
|
||||
*
|
||||
* @param values - The records.
|
||||
*/
|
||||
function mergeRecords$2(values, utils, meta) {
|
||||
const result = {};
|
||||
/* eslint-disable functional/no-loop-statements, functional/no-conditional-statements -- using a loop here is more performant. */
|
||||
for (const key of getKeys(values)) {
|
||||
const propValues = [];
|
||||
for (const value of values) {
|
||||
if (objectHasProperty(value, key)) {
|
||||
propValues.push(value[key]);
|
||||
}
|
||||
}
|
||||
if (propValues.length === 0) {
|
||||
continue;
|
||||
}
|
||||
const updatedMeta = utils.metaDataUpdater(meta, {
|
||||
key,
|
||||
parents: values,
|
||||
});
|
||||
const propertyResult = mergeUnknowns(propValues, utils, updatedMeta);
|
||||
if (propertyResult === actions.skip) {
|
||||
continue;
|
||||
}
|
||||
if (key === "__proto__") {
|
||||
Object.defineProperty(result, key, {
|
||||
value: propertyResult,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
else {
|
||||
result[key] = propertyResult;
|
||||
}
|
||||
}
|
||||
/* eslint-enable functional/no-loop-statements, functional/no-conditional-statements */
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge arrays.
|
||||
*
|
||||
* @param values - The arrays.
|
||||
*/
|
||||
function mergeArrays$2(values) {
|
||||
return values.flat();
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge sets.
|
||||
*
|
||||
* @param values - The sets.
|
||||
*/
|
||||
function mergeSets$2(values) {
|
||||
return new Set(getIterableOfIterables(values));
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge maps.
|
||||
*
|
||||
* @param values - The maps.
|
||||
*/
|
||||
function mergeMaps$2(values) {
|
||||
return new Map(getIterableOfIterables(values));
|
||||
}
|
||||
/**
|
||||
* Get the last value in the given array.
|
||||
*/
|
||||
function mergeOthers$2(values) {
|
||||
return values[values.length - 1];
|
||||
}
|
||||
|
||||
var defaultMergeFunctions = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
mergeRecords: mergeRecords$2,
|
||||
mergeArrays: mergeArrays$2,
|
||||
mergeSets: mergeSets$2,
|
||||
mergeMaps: mergeMaps$2,
|
||||
mergeOthers: mergeOthers$2
|
||||
});
|
||||
|
||||
/**
|
||||
* Deeply merge objects.
|
||||
*
|
||||
* @param objects - The objects to merge.
|
||||
*/
|
||||
function deepmerge(...objects) {
|
||||
return deepmergeCustom({})(...objects);
|
||||
}
|
||||
function deepmergeCustom(options, rootMetaData) {
|
||||
const utils = getUtils(options, customizedDeepmerge);
|
||||
/**
|
||||
* The customized deepmerge function.
|
||||
*/
|
||||
function customizedDeepmerge(...objects) {
|
||||
return mergeUnknowns(objects, utils, rootMetaData);
|
||||
}
|
||||
return customizedDeepmerge;
|
||||
}
|
||||
/**
|
||||
* The the utils that are available to the merge functions.
|
||||
*
|
||||
* @param options - The options the user specified
|
||||
*/
|
||||
function getUtils(options, customizedDeepmerge) {
|
||||
var _a, _b;
|
||||
return {
|
||||
defaultMergeFunctions,
|
||||
mergeFunctions: {
|
||||
...defaultMergeFunctions,
|
||||
...Object.fromEntries(Object.entries(options)
|
||||
.filter(([key, option]) => Object.prototype.hasOwnProperty.call(defaultMergeFunctions, key))
|
||||
.map(([key, option]) => option === false
|
||||
? [key, mergeOthers$2]
|
||||
: [key, option])),
|
||||
},
|
||||
metaDataUpdater: ((_a = options.metaDataUpdater) !== null && _a !== void 0 ? _a : defaultMetaDataUpdater),
|
||||
deepmerge: customizedDeepmerge,
|
||||
useImplicitDefaultMerging: (_b = options.enableImplicitDefaultMerging) !== null && _b !== void 0 ? _b : false,
|
||||
actions,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Merge unknown things.
|
||||
*
|
||||
* @param values - The values.
|
||||
*/
|
||||
function mergeUnknowns(values, utils, meta) {
|
||||
if (values.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
if (values.length === 1) {
|
||||
return mergeOthers$1(values, utils, meta);
|
||||
}
|
||||
const type = getObjectType(values[0]);
|
||||
// eslint-disable-next-line functional/no-conditional-statements -- add an early escape for better performance.
|
||||
if (type !== 0 /* ObjectType.NOT */ && type !== 5 /* ObjectType.OTHER */) {
|
||||
// eslint-disable-next-line functional/no-loop-statements -- using a loop here is more performant than mapping every value and then testing every value.
|
||||
for (let m_index = 1; m_index < values.length; m_index++) {
|
||||
if (getObjectType(values[m_index]) === type) {
|
||||
continue;
|
||||
}
|
||||
return mergeOthers$1(values, utils, meta);
|
||||
}
|
||||
}
|
||||
switch (type) {
|
||||
case 1 /* ObjectType.RECORD */: {
|
||||
return mergeRecords$1(values, utils, meta);
|
||||
}
|
||||
case 2 /* ObjectType.ARRAY */: {
|
||||
return mergeArrays$1(values, utils, meta);
|
||||
}
|
||||
case 3 /* ObjectType.SET */: {
|
||||
return mergeSets$1(values, utils, meta);
|
||||
}
|
||||
case 4 /* ObjectType.MAP */: {
|
||||
return mergeMaps$1(values, utils, meta);
|
||||
}
|
||||
default: {
|
||||
return mergeOthers$1(values, utils, meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge records.
|
||||
*
|
||||
* @param values - The records.
|
||||
*/
|
||||
function mergeRecords$1(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeRecords(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeRecords !==
|
||||
utils.defaultMergeFunctions.mergeRecords)) {
|
||||
return utils.defaultMergeFunctions.mergeRecords(values, utils, meta);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge arrays.
|
||||
*
|
||||
* @param values - The arrays.
|
||||
*/
|
||||
function mergeArrays$1(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeArrays(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeArrays !==
|
||||
utils.defaultMergeFunctions.mergeArrays)) {
|
||||
return utils.defaultMergeFunctions.mergeArrays(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge sets.
|
||||
*
|
||||
* @param values - The sets.
|
||||
*/
|
||||
function mergeSets$1(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeSets(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeSets !== utils.defaultMergeFunctions.mergeSets)) {
|
||||
return utils.defaultMergeFunctions.mergeSets(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge maps.
|
||||
*
|
||||
* @param values - The maps.
|
||||
*/
|
||||
function mergeMaps$1(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeMaps(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeMaps !== utils.defaultMergeFunctions.mergeMaps)) {
|
||||
return utils.defaultMergeFunctions.mergeMaps(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge other things.
|
||||
*
|
||||
* @param values - The other things.
|
||||
*/
|
||||
function mergeOthers$1(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeOthers(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeOthers !==
|
||||
utils.defaultMergeFunctions.mergeOthers)) {
|
||||
return utils.defaultMergeFunctions.mergeOthers(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default strategy to merge records into a target record.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this record
|
||||
* @param values - The records (including the target's value if there is one).
|
||||
*/
|
||||
function mergeRecords(m_target, values, utils, meta) {
|
||||
/* eslint-disable functional/no-loop-statements, functional/no-conditional-statements -- using a loop here is more performant. */
|
||||
for (const key of getKeys(values)) {
|
||||
const propValues = [];
|
||||
for (const value of values) {
|
||||
if (objectHasProperty(value, key)) {
|
||||
propValues.push(value[key]);
|
||||
}
|
||||
}
|
||||
if (propValues.length === 0) {
|
||||
continue;
|
||||
}
|
||||
const updatedMeta = utils.metaDataUpdater(meta, {
|
||||
key,
|
||||
parents: values,
|
||||
});
|
||||
const propertyTarget = { value: propValues[0] };
|
||||
mergeUnknownsInto(propertyTarget, propValues, utils, updatedMeta);
|
||||
if (key === "__proto__") {
|
||||
Object.defineProperty(m_target, key, {
|
||||
value: propertyTarget.value,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
else {
|
||||
m_target.value[key] = propertyTarget.value;
|
||||
}
|
||||
}
|
||||
/* eslint-enable functional/no-loop-statements, functional/no-conditional-statements */
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge arrays into a target array.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this array
|
||||
* @param values - The arrays (including the target's value if there is one).
|
||||
*/
|
||||
function mergeArrays(m_target, values) {
|
||||
m_target.value.push(...values.slice(1).flat());
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge sets into a target set.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this set
|
||||
* @param values - The sets (including the target's value if there is one).
|
||||
*/
|
||||
function mergeSets(m_target, values) {
|
||||
for (const value of getIterableOfIterables(values.slice(1))) {
|
||||
m_target.value.add(value);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge maps into a target map.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this map
|
||||
* @param values - The maps (including the target's value if there is one).
|
||||
*/
|
||||
function mergeMaps(m_target, values) {
|
||||
for (const [key, value] of getIterableOfIterables(values.slice(1))) {
|
||||
m_target.value.set(key, value);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set the target to the last value.
|
||||
*/
|
||||
function mergeOthers(m_target, values) {
|
||||
m_target.value = values[values.length - 1];
|
||||
}
|
||||
|
||||
var defaultMergeIntoFunctions = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
mergeRecords: mergeRecords,
|
||||
mergeArrays: mergeArrays,
|
||||
mergeSets: mergeSets,
|
||||
mergeMaps: mergeMaps,
|
||||
mergeOthers: mergeOthers
|
||||
});
|
||||
|
||||
function deepmergeInto(target, ...objects) {
|
||||
return void deepmergeIntoCustom({})(target, ...objects);
|
||||
}
|
||||
function deepmergeIntoCustom(options, rootMetaData) {
|
||||
const utils = getIntoUtils(options, customizedDeepmergeInto);
|
||||
/**
|
||||
* The customized deepmerge function.
|
||||
*/
|
||||
function customizedDeepmergeInto(target, ...objects) {
|
||||
mergeUnknownsInto({ value: target }, [target, ...objects], utils, rootMetaData);
|
||||
}
|
||||
return customizedDeepmergeInto;
|
||||
}
|
||||
/**
|
||||
* The the utils that are available to the merge functions.
|
||||
*
|
||||
* @param options - The options the user specified
|
||||
*/
|
||||
function getIntoUtils(options, customizedDeepmergeInto) {
|
||||
var _a;
|
||||
return {
|
||||
defaultMergeFunctions: defaultMergeIntoFunctions,
|
||||
mergeFunctions: {
|
||||
...defaultMergeIntoFunctions,
|
||||
...Object.fromEntries(Object.entries(options)
|
||||
.filter(([key, option]) => Object.prototype.hasOwnProperty.call(defaultMergeIntoFunctions, key))
|
||||
.map(([key, option]) => option === false
|
||||
? [key, mergeOthers]
|
||||
: [key, option])),
|
||||
},
|
||||
metaDataUpdater: ((_a = options.metaDataUpdater) !== null && _a !== void 0 ? _a : defaultMetaDataUpdater),
|
||||
deepmergeInto: customizedDeepmergeInto,
|
||||
actions: actionsInto,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Merge unknown things into a target.
|
||||
*
|
||||
* @param m_target - The target to merge into.
|
||||
* @param values - The values.
|
||||
*/
|
||||
function mergeUnknownsInto(m_target, values, utils, meta
|
||||
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
||||
) {
|
||||
if (values.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (values.length === 1) {
|
||||
return void mergeOthersInto(m_target, values, utils, meta);
|
||||
}
|
||||
const type = getObjectType(m_target.value);
|
||||
// eslint-disable-next-line functional/no-conditional-statements -- add an early escape for better performance.
|
||||
if (type !== 0 /* ObjectType.NOT */ && type !== 5 /* ObjectType.OTHER */) {
|
||||
// eslint-disable-next-line functional/no-loop-statements -- using a loop here is more performant than mapping every value and then testing every value.
|
||||
for (let m_index = 1; m_index < values.length; m_index++) {
|
||||
if (getObjectType(values[m_index]) === type) {
|
||||
continue;
|
||||
}
|
||||
return void mergeOthersInto(m_target, values, utils, meta);
|
||||
}
|
||||
}
|
||||
switch (type) {
|
||||
case 1 /* ObjectType.RECORD */: {
|
||||
return void mergeRecordsInto(m_target, values, utils, meta);
|
||||
}
|
||||
case 2 /* ObjectType.ARRAY */: {
|
||||
return void mergeArraysInto(m_target, values, utils, meta);
|
||||
}
|
||||
case 3 /* ObjectType.SET */: {
|
||||
return void mergeSetsInto(m_target, values, utils, meta);
|
||||
}
|
||||
case 4 /* ObjectType.MAP */: {
|
||||
return void mergeMapsInto(m_target, values, utils, meta);
|
||||
}
|
||||
default: {
|
||||
return void mergeOthersInto(m_target, values, utils, meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge records into a target record.
|
||||
*
|
||||
* @param m_target - The target to merge into.
|
||||
* @param values - The records.
|
||||
*/
|
||||
function mergeRecordsInto(m_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeRecords(m_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeRecords(m_target, values, utils, meta);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge arrays into a target array.
|
||||
*
|
||||
* @param m_target - The target to merge into.
|
||||
* @param values - The arrays.
|
||||
*/
|
||||
function mergeArraysInto(m_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeArrays(m_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeArrays(m_target, values);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge sets into a target set.
|
||||
*
|
||||
* @param m_target - The target to merge into.
|
||||
* @param values - The sets.
|
||||
*/
|
||||
function mergeSetsInto(m_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeSets(m_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeSets(m_target, values);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge maps into a target map.
|
||||
*
|
||||
* @param m_target - The target to merge into.
|
||||
* @param values - The maps.
|
||||
*/
|
||||
function mergeMapsInto(m_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeMaps(m_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeMaps(m_target, values);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge other things into a target.
|
||||
*
|
||||
* @param m_target - The target to merge into.
|
||||
* @param values - The other things.
|
||||
*/
|
||||
function mergeOthersInto(m_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeOthers(m_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge ||
|
||||
m_target.value === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeOthers(m_target, values);
|
||||
}
|
||||
}
|
||||
|
||||
exports.deepmerge = deepmerge;
|
||||
exports.deepmergeCustom = deepmergeCustom;
|
||||
exports.deepmergeInto = deepmergeInto;
|
||||
exports.deepmergeIntoCustom = deepmergeIntoCustom;
|
||||
598
node_modules/deepmerge-ts/dist/node/index.mjs
generated
vendored
Normal file
598
node_modules/deepmerge-ts/dist/node/index.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,598 @@
|
|||
/**
|
||||
* Special values that tell deepmerge to perform a certain action.
|
||||
*/
|
||||
const actions = {
|
||||
defaultMerge: Symbol("deepmerge-ts: default merge"),
|
||||
skip: Symbol("deepmerge-ts: skip"),
|
||||
};
|
||||
/**
|
||||
* Special values that tell deepmergeInto to perform a certain action.
|
||||
*/
|
||||
const actionsInto = {
|
||||
defaultMerge: actions.defaultMerge,
|
||||
};
|
||||
|
||||
/**
|
||||
* The default function to update meta data.
|
||||
*/
|
||||
function defaultMetaDataUpdater(previousMeta, metaMeta) {
|
||||
return metaMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the given object.
|
||||
*
|
||||
* @param object - The object to get the type of.
|
||||
* @returns The type of the given object.
|
||||
*/
|
||||
function getObjectType(object) {
|
||||
if (typeof object !== "object" || object === null) {
|
||||
return 0 /* ObjectType.NOT */;
|
||||
}
|
||||
if (Array.isArray(object)) {
|
||||
return 2 /* ObjectType.ARRAY */;
|
||||
}
|
||||
if (isRecord(object)) {
|
||||
return 1 /* ObjectType.RECORD */;
|
||||
}
|
||||
if (object instanceof Set) {
|
||||
return 3 /* ObjectType.SET */;
|
||||
}
|
||||
if (object instanceof Map) {
|
||||
return 4 /* ObjectType.MAP */;
|
||||
}
|
||||
return 5 /* ObjectType.OTHER */;
|
||||
}
|
||||
/**
|
||||
* Get the keys of the given objects including symbol keys.
|
||||
*
|
||||
* Note: Only keys to enumerable properties are returned.
|
||||
*
|
||||
* @param objects - An array of objects to get the keys of.
|
||||
* @returns A set containing all the keys of all the given objects.
|
||||
*/
|
||||
function getKeys(objects) {
|
||||
const keys = new Set();
|
||||
/* eslint-disable functional/no-loop-statements -- using a loop here is more efficient. */
|
||||
for (const object of objects) {
|
||||
for (const key of [
|
||||
...Object.keys(object),
|
||||
...Object.getOwnPropertySymbols(object),
|
||||
]) {
|
||||
keys.add(key);
|
||||
}
|
||||
}
|
||||
/* eslint-enable functional/no-loop-statements */
|
||||
return keys;
|
||||
}
|
||||
/**
|
||||
* Does the given object have the given property.
|
||||
*
|
||||
* @param object - The object to test.
|
||||
* @param property - The property to test.
|
||||
* @returns Whether the object has the property.
|
||||
*/
|
||||
function objectHasProperty(object, property) {
|
||||
return (typeof object === "object" &&
|
||||
Object.prototype.propertyIsEnumerable.call(object, property));
|
||||
}
|
||||
/**
|
||||
* Get an iterable object that iterates over the given iterables.
|
||||
*/
|
||||
function getIterableOfIterables(iterables) {
|
||||
return {
|
||||
*[Symbol.iterator]() {
|
||||
// eslint-disable-next-line functional/no-loop-statements
|
||||
for (const iterable of iterables) {
|
||||
// eslint-disable-next-line functional/no-loop-statements
|
||||
for (const value of iterable) {
|
||||
yield value;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
const validRecordToStringValues = new Set([
|
||||
"[object Object]",
|
||||
"[object Module]",
|
||||
]);
|
||||
/**
|
||||
* Does the given object appear to be a record.
|
||||
*/
|
||||
function isRecord(value) {
|
||||
// All records are objects.
|
||||
if (!validRecordToStringValues.has(Object.prototype.toString.call(value))) {
|
||||
return false;
|
||||
}
|
||||
const { constructor } = value;
|
||||
// If has modified constructor.
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
if (constructor === undefined) {
|
||||
return true;
|
||||
}
|
||||
// eslint-disable-next-line prefer-destructuring
|
||||
const prototype = constructor.prototype;
|
||||
// If has modified prototype.
|
||||
if (prototype === null ||
|
||||
typeof prototype !== "object" ||
|
||||
!validRecordToStringValues.has(Object.prototype.toString.call(prototype))) {
|
||||
return false;
|
||||
}
|
||||
// If constructor does not have an Object-specific method.
|
||||
// eslint-disable-next-line sonarjs/prefer-single-boolean-return, no-prototype-builtins
|
||||
if (!prototype.hasOwnProperty("isPrototypeOf")) {
|
||||
return false;
|
||||
}
|
||||
// Most likely a record.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default strategy to merge records.
|
||||
*
|
||||
* @param values - The records.
|
||||
*/
|
||||
function mergeRecords$2(values, utils, meta) {
|
||||
const result = {};
|
||||
/* eslint-disable functional/no-loop-statements, functional/no-conditional-statements -- using a loop here is more performant. */
|
||||
for (const key of getKeys(values)) {
|
||||
const propValues = [];
|
||||
for (const value of values) {
|
||||
if (objectHasProperty(value, key)) {
|
||||
propValues.push(value[key]);
|
||||
}
|
||||
}
|
||||
if (propValues.length === 0) {
|
||||
continue;
|
||||
}
|
||||
const updatedMeta = utils.metaDataUpdater(meta, {
|
||||
key,
|
||||
parents: values,
|
||||
});
|
||||
const propertyResult = mergeUnknowns(propValues, utils, updatedMeta);
|
||||
if (propertyResult === actions.skip) {
|
||||
continue;
|
||||
}
|
||||
if (key === "__proto__") {
|
||||
Object.defineProperty(result, key, {
|
||||
value: propertyResult,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
else {
|
||||
result[key] = propertyResult;
|
||||
}
|
||||
}
|
||||
/* eslint-enable functional/no-loop-statements, functional/no-conditional-statements */
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge arrays.
|
||||
*
|
||||
* @param values - The arrays.
|
||||
*/
|
||||
function mergeArrays$2(values) {
|
||||
return values.flat();
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge sets.
|
||||
*
|
||||
* @param values - The sets.
|
||||
*/
|
||||
function mergeSets$2(values) {
|
||||
return new Set(getIterableOfIterables(values));
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge maps.
|
||||
*
|
||||
* @param values - The maps.
|
||||
*/
|
||||
function mergeMaps$2(values) {
|
||||
return new Map(getIterableOfIterables(values));
|
||||
}
|
||||
/**
|
||||
* Get the last value in the given array.
|
||||
*/
|
||||
function mergeOthers$2(values) {
|
||||
return values[values.length - 1];
|
||||
}
|
||||
|
||||
var defaultMergeFunctions = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
mergeRecords: mergeRecords$2,
|
||||
mergeArrays: mergeArrays$2,
|
||||
mergeSets: mergeSets$2,
|
||||
mergeMaps: mergeMaps$2,
|
||||
mergeOthers: mergeOthers$2
|
||||
});
|
||||
|
||||
/**
|
||||
* Deeply merge objects.
|
||||
*
|
||||
* @param objects - The objects to merge.
|
||||
*/
|
||||
function deepmerge(...objects) {
|
||||
return deepmergeCustom({})(...objects);
|
||||
}
|
||||
function deepmergeCustom(options, rootMetaData) {
|
||||
const utils = getUtils(options, customizedDeepmerge);
|
||||
/**
|
||||
* The customized deepmerge function.
|
||||
*/
|
||||
function customizedDeepmerge(...objects) {
|
||||
return mergeUnknowns(objects, utils, rootMetaData);
|
||||
}
|
||||
return customizedDeepmerge;
|
||||
}
|
||||
/**
|
||||
* The the utils that are available to the merge functions.
|
||||
*
|
||||
* @param options - The options the user specified
|
||||
*/
|
||||
function getUtils(options, customizedDeepmerge) {
|
||||
var _a, _b;
|
||||
return {
|
||||
defaultMergeFunctions,
|
||||
mergeFunctions: {
|
||||
...defaultMergeFunctions,
|
||||
...Object.fromEntries(Object.entries(options)
|
||||
.filter(([key, option]) => Object.prototype.hasOwnProperty.call(defaultMergeFunctions, key))
|
||||
.map(([key, option]) => option === false
|
||||
? [key, mergeOthers$2]
|
||||
: [key, option])),
|
||||
},
|
||||
metaDataUpdater: ((_a = options.metaDataUpdater) !== null && _a !== void 0 ? _a : defaultMetaDataUpdater),
|
||||
deepmerge: customizedDeepmerge,
|
||||
useImplicitDefaultMerging: (_b = options.enableImplicitDefaultMerging) !== null && _b !== void 0 ? _b : false,
|
||||
actions,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Merge unknown things.
|
||||
*
|
||||
* @param values - The values.
|
||||
*/
|
||||
function mergeUnknowns(values, utils, meta) {
|
||||
if (values.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
if (values.length === 1) {
|
||||
return mergeOthers$1(values, utils, meta);
|
||||
}
|
||||
const type = getObjectType(values[0]);
|
||||
// eslint-disable-next-line functional/no-conditional-statements -- add an early escape for better performance.
|
||||
if (type !== 0 /* ObjectType.NOT */ && type !== 5 /* ObjectType.OTHER */) {
|
||||
// eslint-disable-next-line functional/no-loop-statements -- using a loop here is more performant than mapping every value and then testing every value.
|
||||
for (let m_index = 1; m_index < values.length; m_index++) {
|
||||
if (getObjectType(values[m_index]) === type) {
|
||||
continue;
|
||||
}
|
||||
return mergeOthers$1(values, utils, meta);
|
||||
}
|
||||
}
|
||||
switch (type) {
|
||||
case 1 /* ObjectType.RECORD */: {
|
||||
return mergeRecords$1(values, utils, meta);
|
||||
}
|
||||
case 2 /* ObjectType.ARRAY */: {
|
||||
return mergeArrays$1(values, utils, meta);
|
||||
}
|
||||
case 3 /* ObjectType.SET */: {
|
||||
return mergeSets$1(values, utils, meta);
|
||||
}
|
||||
case 4 /* ObjectType.MAP */: {
|
||||
return mergeMaps$1(values, utils, meta);
|
||||
}
|
||||
default: {
|
||||
return mergeOthers$1(values, utils, meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge records.
|
||||
*
|
||||
* @param values - The records.
|
||||
*/
|
||||
function mergeRecords$1(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeRecords(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeRecords !==
|
||||
utils.defaultMergeFunctions.mergeRecords)) {
|
||||
return utils.defaultMergeFunctions.mergeRecords(values, utils, meta);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge arrays.
|
||||
*
|
||||
* @param values - The arrays.
|
||||
*/
|
||||
function mergeArrays$1(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeArrays(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeArrays !==
|
||||
utils.defaultMergeFunctions.mergeArrays)) {
|
||||
return utils.defaultMergeFunctions.mergeArrays(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge sets.
|
||||
*
|
||||
* @param values - The sets.
|
||||
*/
|
||||
function mergeSets$1(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeSets(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeSets !== utils.defaultMergeFunctions.mergeSets)) {
|
||||
return utils.defaultMergeFunctions.mergeSets(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge maps.
|
||||
*
|
||||
* @param values - The maps.
|
||||
*/
|
||||
function mergeMaps$1(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeMaps(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeMaps !== utils.defaultMergeFunctions.mergeMaps)) {
|
||||
return utils.defaultMergeFunctions.mergeMaps(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge other things.
|
||||
*
|
||||
* @param values - The other things.
|
||||
*/
|
||||
function mergeOthers$1(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeOthers(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeOthers !==
|
||||
utils.defaultMergeFunctions.mergeOthers)) {
|
||||
return utils.defaultMergeFunctions.mergeOthers(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default strategy to merge records into a target record.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this record
|
||||
* @param values - The records (including the target's value if there is one).
|
||||
*/
|
||||
function mergeRecords(m_target, values, utils, meta) {
|
||||
/* eslint-disable functional/no-loop-statements, functional/no-conditional-statements -- using a loop here is more performant. */
|
||||
for (const key of getKeys(values)) {
|
||||
const propValues = [];
|
||||
for (const value of values) {
|
||||
if (objectHasProperty(value, key)) {
|
||||
propValues.push(value[key]);
|
||||
}
|
||||
}
|
||||
if (propValues.length === 0) {
|
||||
continue;
|
||||
}
|
||||
const updatedMeta = utils.metaDataUpdater(meta, {
|
||||
key,
|
||||
parents: values,
|
||||
});
|
||||
const propertyTarget = { value: propValues[0] };
|
||||
mergeUnknownsInto(propertyTarget, propValues, utils, updatedMeta);
|
||||
if (key === "__proto__") {
|
||||
Object.defineProperty(m_target, key, {
|
||||
value: propertyTarget.value,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
else {
|
||||
m_target.value[key] = propertyTarget.value;
|
||||
}
|
||||
}
|
||||
/* eslint-enable functional/no-loop-statements, functional/no-conditional-statements */
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge arrays into a target array.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this array
|
||||
* @param values - The arrays (including the target's value if there is one).
|
||||
*/
|
||||
function mergeArrays(m_target, values) {
|
||||
m_target.value.push(...values.slice(1).flat());
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge sets into a target set.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this set
|
||||
* @param values - The sets (including the target's value if there is one).
|
||||
*/
|
||||
function mergeSets(m_target, values) {
|
||||
for (const value of getIterableOfIterables(values.slice(1))) {
|
||||
m_target.value.add(value);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge maps into a target map.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this map
|
||||
* @param values - The maps (including the target's value if there is one).
|
||||
*/
|
||||
function mergeMaps(m_target, values) {
|
||||
for (const [key, value] of getIterableOfIterables(values.slice(1))) {
|
||||
m_target.value.set(key, value);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set the target to the last value.
|
||||
*/
|
||||
function mergeOthers(m_target, values) {
|
||||
m_target.value = values[values.length - 1];
|
||||
}
|
||||
|
||||
var defaultMergeIntoFunctions = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
mergeRecords: mergeRecords,
|
||||
mergeArrays: mergeArrays,
|
||||
mergeSets: mergeSets,
|
||||
mergeMaps: mergeMaps,
|
||||
mergeOthers: mergeOthers
|
||||
});
|
||||
|
||||
function deepmergeInto(target, ...objects) {
|
||||
return void deepmergeIntoCustom({})(target, ...objects);
|
||||
}
|
||||
function deepmergeIntoCustom(options, rootMetaData) {
|
||||
const utils = getIntoUtils(options, customizedDeepmergeInto);
|
||||
/**
|
||||
* The customized deepmerge function.
|
||||
*/
|
||||
function customizedDeepmergeInto(target, ...objects) {
|
||||
mergeUnknownsInto({ value: target }, [target, ...objects], utils, rootMetaData);
|
||||
}
|
||||
return customizedDeepmergeInto;
|
||||
}
|
||||
/**
|
||||
* The the utils that are available to the merge functions.
|
||||
*
|
||||
* @param options - The options the user specified
|
||||
*/
|
||||
function getIntoUtils(options, customizedDeepmergeInto) {
|
||||
var _a;
|
||||
return {
|
||||
defaultMergeFunctions: defaultMergeIntoFunctions,
|
||||
mergeFunctions: {
|
||||
...defaultMergeIntoFunctions,
|
||||
...Object.fromEntries(Object.entries(options)
|
||||
.filter(([key, option]) => Object.prototype.hasOwnProperty.call(defaultMergeIntoFunctions, key))
|
||||
.map(([key, option]) => option === false
|
||||
? [key, mergeOthers]
|
||||
: [key, option])),
|
||||
},
|
||||
metaDataUpdater: ((_a = options.metaDataUpdater) !== null && _a !== void 0 ? _a : defaultMetaDataUpdater),
|
||||
deepmergeInto: customizedDeepmergeInto,
|
||||
actions: actionsInto,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Merge unknown things into a target.
|
||||
*
|
||||
* @param m_target - The target to merge into.
|
||||
* @param values - The values.
|
||||
*/
|
||||
function mergeUnknownsInto(m_target, values, utils, meta
|
||||
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
||||
) {
|
||||
if (values.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (values.length === 1) {
|
||||
return void mergeOthersInto(m_target, values, utils, meta);
|
||||
}
|
||||
const type = getObjectType(m_target.value);
|
||||
// eslint-disable-next-line functional/no-conditional-statements -- add an early escape for better performance.
|
||||
if (type !== 0 /* ObjectType.NOT */ && type !== 5 /* ObjectType.OTHER */) {
|
||||
// eslint-disable-next-line functional/no-loop-statements -- using a loop here is more performant than mapping every value and then testing every value.
|
||||
for (let m_index = 1; m_index < values.length; m_index++) {
|
||||
if (getObjectType(values[m_index]) === type) {
|
||||
continue;
|
||||
}
|
||||
return void mergeOthersInto(m_target, values, utils, meta);
|
||||
}
|
||||
}
|
||||
switch (type) {
|
||||
case 1 /* ObjectType.RECORD */: {
|
||||
return void mergeRecordsInto(m_target, values, utils, meta);
|
||||
}
|
||||
case 2 /* ObjectType.ARRAY */: {
|
||||
return void mergeArraysInto(m_target, values, utils, meta);
|
||||
}
|
||||
case 3 /* ObjectType.SET */: {
|
||||
return void mergeSetsInto(m_target, values, utils, meta);
|
||||
}
|
||||
case 4 /* ObjectType.MAP */: {
|
||||
return void mergeMapsInto(m_target, values, utils, meta);
|
||||
}
|
||||
default: {
|
||||
return void mergeOthersInto(m_target, values, utils, meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge records into a target record.
|
||||
*
|
||||
* @param m_target - The target to merge into.
|
||||
* @param values - The records.
|
||||
*/
|
||||
function mergeRecordsInto(m_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeRecords(m_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeRecords(m_target, values, utils, meta);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge arrays into a target array.
|
||||
*
|
||||
* @param m_target - The target to merge into.
|
||||
* @param values - The arrays.
|
||||
*/
|
||||
function mergeArraysInto(m_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeArrays(m_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeArrays(m_target, values);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge sets into a target set.
|
||||
*
|
||||
* @param m_target - The target to merge into.
|
||||
* @param values - The sets.
|
||||
*/
|
||||
function mergeSetsInto(m_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeSets(m_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeSets(m_target, values);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge maps into a target map.
|
||||
*
|
||||
* @param m_target - The target to merge into.
|
||||
* @param values - The maps.
|
||||
*/
|
||||
function mergeMapsInto(m_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeMaps(m_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeMaps(m_target, values);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge other things into a target.
|
||||
*
|
||||
* @param m_target - The target to merge into.
|
||||
* @param values - The other things.
|
||||
*/
|
||||
function mergeOthersInto(m_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeOthers(m_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge ||
|
||||
m_target.value === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeOthers(m_target, values);
|
||||
}
|
||||
}
|
||||
|
||||
export { deepmerge, deepmergeCustom, deepmergeInto, deepmergeIntoCustom };
|
||||
531
node_modules/deepmerge-ts/dist/node/types/current/index.d.cts
generated
vendored
Normal file
531
node_modules/deepmerge-ts/dist/node/types/current/index.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,531 @@
|
|||
/**
|
||||
* Flatten a complex type such as a union or intersection of objects into a
|
||||
* single object.
|
||||
*/
|
||||
type FlatternAlias<T> = Is<T, unknown> extends true ? T : {
|
||||
[P in keyof T]: T[P];
|
||||
} & {};
|
||||
/**
|
||||
* Get the value of the given key in the given object.
|
||||
*/
|
||||
type ValueOfKey<T extends Record<PropertyKey, unknown>, K extends PropertyKey> = K extends keyof T ? T[K] : never;
|
||||
/**
|
||||
* Safely test whether or not the first given types extends the second.
|
||||
*
|
||||
* Needed in particular for testing if a type is "never".
|
||||
*/
|
||||
type Is<T1, T2> = [T1] extends [T2] ? true : false;
|
||||
/**
|
||||
* Safely test whether or not the given type is "never".
|
||||
*/
|
||||
type IsNever<T> = Is<T, never>;
|
||||
/**
|
||||
* Returns whether or not the given type a record.
|
||||
*/
|
||||
type IsRecord<T> = And<Not<IsNever<T>>, T extends Readonly<Record<PropertyKey, unknown>> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are records.
|
||||
*/
|
||||
type EveryIsRecord<Ts extends ReadonlyArray<unknown>> = Ts extends readonly [infer Head, ...infer Rest] ? IsRecord<Head> extends true ? Rest extends ReadonlyArray<unknown> ? EveryIsRecord<Rest> : true : false : true;
|
||||
/**
|
||||
* Returns whether or not the given type is an array.
|
||||
*/
|
||||
type IsArray<T> = And<Not<IsNever<T>>, T extends ReadonlyArray<unknown> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are arrays.
|
||||
*/
|
||||
type EveryIsArray<Ts extends ReadonlyArray<unknown>> = Ts extends readonly [infer T1] ? IsArray<T1> : Ts extends readonly [infer Head, ...infer Rest] ? IsArray<Head> extends true ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? EveryIsArray<Rest> : false : false : false;
|
||||
/**
|
||||
* Returns whether or not the given type is an set.
|
||||
*
|
||||
* Note: This may also return true for Maps.
|
||||
*/
|
||||
type IsSet<T> = And<Not<IsNever<T>>, T extends Readonly<ReadonlySet<unknown>> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are sets.
|
||||
*
|
||||
* Note: This may also return true if all are maps.
|
||||
*/
|
||||
type EveryIsSet<Ts extends ReadonlyArray<unknown>> = Ts extends Readonly<readonly [infer T1]> ? IsSet<T1> : Ts extends readonly [infer Head, ...infer Rest] ? IsSet<Head> extends true ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? EveryIsSet<Rest> : false : false : false;
|
||||
/**
|
||||
* Returns whether or not the given type is an map.
|
||||
*/
|
||||
type IsMap<T> = And<Not<IsNever<T>>, T extends Readonly<ReadonlyMap<unknown, unknown>> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are maps.
|
||||
*/
|
||||
type EveryIsMap<Ts extends ReadonlyArray<unknown>> = Ts extends Readonly<readonly [infer T1]> ? IsMap<T1> : Ts extends readonly [infer Head, ...infer Rest] ? IsMap<Head> extends true ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? EveryIsMap<Rest> : false : false : false;
|
||||
/**
|
||||
* And operator for types.
|
||||
*/
|
||||
type And<T1 extends boolean, T2 extends boolean> = T1 extends false ? false : T2;
|
||||
/**
|
||||
* Not operator for types.
|
||||
*/
|
||||
type Not<T extends boolean> = T extends true ? false : true;
|
||||
/**
|
||||
* Union of the sets' values' types
|
||||
*/
|
||||
type UnionSetValues<Ts extends ReadonlyArray<unknown>> = UnionSetValuesHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for UnionSetValues.
|
||||
*/
|
||||
type UnionSetValuesHelper<Ts extends ReadonlyArray<unknown>, Acc> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Readonly<ReadonlySet<infer V1>> ? Rest extends ReadonlyArray<unknown> ? UnionSetValuesHelper<Rest, Acc | V1> : Acc | V1 : never : Acc;
|
||||
/**
|
||||
* Union of the maps' values' types
|
||||
*/
|
||||
type UnionMapKeys<Ts extends ReadonlyArray<unknown>> = UnionMapKeysHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for UnionMapKeys.
|
||||
*/
|
||||
type UnionMapKeysHelper<Ts extends ReadonlyArray<unknown>, Acc> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Readonly<ReadonlyMap<infer K1, unknown>> ? Rest extends readonly [] ? Acc | K1 : UnionMapKeysHelper<Rest, Acc | K1> : never : Acc;
|
||||
/**
|
||||
* Union of the maps' keys' types
|
||||
*/
|
||||
type UnionMapValues<Ts extends ReadonlyArray<unknown>> = UnionMapValuesHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for UnionMapValues.
|
||||
*/
|
||||
type UnionMapValuesHelper<Ts extends ReadonlyArray<unknown>, Acc> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Readonly<ReadonlyMap<unknown, infer V1>> ? Rest extends readonly [] ? Acc | V1 : UnionMapValuesHelper<Rest, Acc | V1> : never : Acc;
|
||||
/**
|
||||
* Get the keys of the type what match a certain criteria.
|
||||
*/
|
||||
type KeysOfType<T, U> = {
|
||||
[K in keyof T]: T[K] extends U ? K : never;
|
||||
}[keyof T];
|
||||
/**
|
||||
* Get the required keys of the type.
|
||||
*/
|
||||
type RequiredKeys<T> = Exclude<KeysOfType<T, Exclude<T[keyof T], undefined>>, undefined>;
|
||||
/**
|
||||
* Get all the required keys on the types in the tuple.
|
||||
*/
|
||||
type RequiredKeysOf<Ts extends readonly [unknown, ...ReadonlyArray<unknown>]> = RequiredKeysOfHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for RequiredKeysOf.
|
||||
*/
|
||||
type RequiredKeysOfHelper<Ts extends readonly [unknown, ...ReadonlyArray<unknown>], Acc> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Record<PropertyKey, unknown> ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? RequiredKeysOfHelper<Rest, Acc | RequiredKeys<Head>> : Acc | RequiredKeys<Head> : never : Acc;
|
||||
/**
|
||||
* Get the optional keys of the type.
|
||||
*/
|
||||
type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>;
|
||||
/**
|
||||
* Get all the optional keys on the types in the tuple.
|
||||
*/
|
||||
type OptionalKeysOf<Ts extends readonly [unknown, ...ReadonlyArray<unknown>]> = OptionalKeysOfHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for OptionalKeysOf.
|
||||
*/
|
||||
type OptionalKeysOfHelper<Ts extends readonly [unknown, ...ReadonlyArray<unknown>], Acc> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Record<PropertyKey, unknown> ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? OptionalKeysOfHelper<Rest, Acc | OptionalKeys<Head>> : Acc | OptionalKeys<Head> : never : Acc;
|
||||
/**
|
||||
* Filter out nevers from a tuple.
|
||||
*/
|
||||
type FilterOutNever<T extends ReadonlyArray<unknown>> = FilterOutNeverHelper<T, []>;
|
||||
/**
|
||||
* Tail-recursive helper type for FilterOutNever.
|
||||
*/
|
||||
type FilterOutNeverHelper<T extends ReadonlyArray<unknown>, Acc extends ReadonlyArray<unknown>> = T extends readonly [] ? Acc : T extends readonly [infer Head, ...infer Rest] ? IsNever<Head> extends true ? FilterOutNeverHelper<Rest, Acc> : FilterOutNeverHelper<Rest, [...Acc, Head]> : T;
|
||||
/**
|
||||
* Is the type a tuple?
|
||||
*/
|
||||
type IsTuple<T extends ReadonlyArray<unknown>> = T extends readonly [] ? true : T extends readonly [unknown, ...ReadonlyArray<unknown>] ? true : false;
|
||||
|
||||
/**
|
||||
* Mapping of merge function URIs to the merge function type.
|
||||
*/
|
||||
interface DeepMergeMergeFunctionURItoKind<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, in out M> {
|
||||
readonly DeepMergeLeafURI: DeepMergeLeaf<Ts>;
|
||||
readonly DeepMergeRecordsDefaultURI: DeepMergeRecordsDefaultHKT<Ts, MF, M>;
|
||||
readonly DeepMergeArraysDefaultURI: DeepMergeArraysDefaultHKT<Ts, MF, M>;
|
||||
readonly DeepMergeSetsDefaultURI: DeepMergeSetsDefaultHKT<Ts>;
|
||||
readonly DeepMergeMapsDefaultURI: DeepMergeMapsDefaultHKT<Ts>;
|
||||
}
|
||||
/**
|
||||
* Get the type of the given merge function via its URI.
|
||||
*/
|
||||
type DeepMergeMergeFunctionKind<URI extends DeepMergeMergeFunctionURIs, Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionURItoKind<Ts, MF, M>[URI];
|
||||
/**
|
||||
* A union of all valid merge function URIs.
|
||||
*/
|
||||
type DeepMergeMergeFunctionURIs = keyof DeepMergeMergeFunctionURItoKind<ReadonlyArray<unknown>, DeepMergeMergeFunctionsURIs, unknown>;
|
||||
/**
|
||||
* The merge functions to use when deep merging.
|
||||
*/
|
||||
type DeepMergeMergeFunctionsURIs = Readonly<{
|
||||
/**
|
||||
* The merge function to merge records with.
|
||||
*/
|
||||
DeepMergeRecordsURI: DeepMergeMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge arrays with.
|
||||
*/
|
||||
DeepMergeArraysURI: DeepMergeMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge sets with.
|
||||
*/
|
||||
DeepMergeSetsURI: DeepMergeMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge maps with.
|
||||
*/
|
||||
DeepMergeMapsURI: DeepMergeMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge other things with.
|
||||
*/
|
||||
DeepMergeOthersURI: DeepMergeMergeFunctionURIs;
|
||||
}>;
|
||||
/**
|
||||
* Deep merge types.
|
||||
*/
|
||||
type DeepMergeHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = IsTuple<Ts> extends true ? Ts extends readonly [] ? undefined : Ts extends readonly [infer T1] ? T1 : EveryIsArray<Ts> extends true ? DeepMergeArraysHKT<Ts, MF, M> : EveryIsMap<Ts> extends true ? DeepMergeMapsHKT<Ts, MF, M> : EveryIsSet<Ts> extends true ? DeepMergeSetsHKT<Ts, MF, M> : EveryIsRecord<Ts> extends true ? DeepMergeRecordsHKT<Ts, MF, M> : DeepMergeOthersHKT<Ts, MF, M> : unknown;
|
||||
/**
|
||||
* Deep merge records.
|
||||
*/
|
||||
type DeepMergeRecordsHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionKind<MF["DeepMergeRecordsURI"], Ts, MF, M>;
|
||||
/**
|
||||
* Deep merge arrays.
|
||||
*/
|
||||
type DeepMergeArraysHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionKind<MF["DeepMergeArraysURI"], Ts, MF, M>;
|
||||
/**
|
||||
* Deep merge sets.
|
||||
*/
|
||||
type DeepMergeSetsHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionKind<MF["DeepMergeSetsURI"], Ts, MF, M>;
|
||||
/**
|
||||
* Deep merge maps.
|
||||
*/
|
||||
type DeepMergeMapsHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionKind<MF["DeepMergeMapsURI"], Ts, MF, M>;
|
||||
/**
|
||||
* Deep merge other things.
|
||||
*/
|
||||
type DeepMergeOthersHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionKind<MF["DeepMergeOthersURI"], Ts, MF, M>;
|
||||
/**
|
||||
* The merge function that returns a leaf.
|
||||
*/
|
||||
type DeepMergeLeafURI = "DeepMergeLeafURI";
|
||||
/**
|
||||
* Get the leaf type from many types that can't be merged.
|
||||
*
|
||||
* @deprecated Use `DeepMergeLeaf` instead.
|
||||
*/
|
||||
type DeepMergeLeafHKT<Ts extends ReadonlyArray<unknown>> = DeepMergeLeaf<Ts>;
|
||||
/**
|
||||
* Get the leaf type from many types that can't be merged.
|
||||
*/
|
||||
type DeepMergeLeaf<Ts extends ReadonlyArray<unknown>> = Ts extends readonly [] ? never : Ts extends readonly [infer T] ? T : Ts extends readonly [...infer Rest, infer Tail] ? IsNever<Tail> extends true ? Rest extends ReadonlyArray<unknown> ? DeepMergeLeaf<Rest> : never : Tail : never;
|
||||
/**
|
||||
* The meta data deepmerge is able to provide.
|
||||
*/
|
||||
type DeepMergeBuiltInMetaData = Readonly<{
|
||||
key: PropertyKey;
|
||||
parents: ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* The default merge function to merge records with.
|
||||
*/
|
||||
type DeepMergeRecordsDefaultURI = "DeepMergeRecordsDefaultURI";
|
||||
/**
|
||||
* The default merge function to merge arrays with.
|
||||
*/
|
||||
type DeepMergeArraysDefaultURI = "DeepMergeArraysDefaultURI";
|
||||
/**
|
||||
* The default merge function to merge sets with.
|
||||
*/
|
||||
type DeepMergeSetsDefaultURI = "DeepMergeSetsDefaultURI";
|
||||
/**
|
||||
* The default merge function to merge maps with.
|
||||
*/
|
||||
type DeepMergeMapsDefaultURI = "DeepMergeMapsDefaultURI";
|
||||
/**
|
||||
* The default merge functions to use when deep merging.
|
||||
*/
|
||||
type DeepMergeMergeFunctionsDefaultURIs = Readonly<{
|
||||
DeepMergeRecordsURI: DeepMergeRecordsDefaultURI;
|
||||
DeepMergeArraysURI: DeepMergeArraysDefaultURI;
|
||||
DeepMergeSetsURI: DeepMergeSetsDefaultURI;
|
||||
DeepMergeMapsURI: DeepMergeMapsDefaultURI;
|
||||
DeepMergeOthersURI: DeepMergeLeafURI;
|
||||
}>;
|
||||
/**
|
||||
* A union of all the props that should not be included in type information for
|
||||
* merged records.
|
||||
*/
|
||||
type BlacklistedRecordProps = "__proto__";
|
||||
/**
|
||||
* Deep merge records.
|
||||
*/
|
||||
type DeepMergeRecordsDefaultHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = Ts extends Readonly<readonly [unknown, ...Readonly<ReadonlyArray<unknown>>]> ? FlatternAlias<Omit<DeepMergeRecordsDefaultHKTInternalProps<Ts, MF, M>, BlacklistedRecordProps>> : {};
|
||||
/**
|
||||
* Deep merge record props.
|
||||
*/
|
||||
type DeepMergeRecordsDefaultHKTInternalProps<Ts extends readonly [unknown, ...ReadonlyArray<unknown>], MF extends DeepMergeMergeFunctionsURIs, M> = {
|
||||
[K in OptionalKeysOf<Ts>]?: DeepMergeHKT<DeepMergeRecordsDefaultHKTInternalPropValue<Ts, K, M>, MF, M>;
|
||||
} & {
|
||||
[K in RequiredKeysOf<Ts>]: DeepMergeHKT<DeepMergeRecordsDefaultHKTInternalPropValue<Ts, K, M>, MF, M>;
|
||||
};
|
||||
/**
|
||||
* Get the value of the property.
|
||||
*/
|
||||
type DeepMergeRecordsDefaultHKTInternalPropValue<Ts extends readonly [unknown, ...ReadonlyArray<unknown>], K extends PropertyKey, M> = FilterOutNever<DeepMergeRecordsDefaultHKTInternalPropValueHelper<Ts, K, M, readonly []>>;
|
||||
/**
|
||||
* Tail-recursive helper type for DeepMergeRecordsDefaultHKTInternalPropValue.
|
||||
*/
|
||||
type DeepMergeRecordsDefaultHKTInternalPropValueHelper<Ts extends readonly [unknown, ...ReadonlyArray<unknown>], K extends PropertyKey, M, Acc extends ReadonlyArray<unknown>> = Ts extends readonly [
|
||||
infer Head extends Readonly<Record<PropertyKey, unknown>>,
|
||||
...infer Rest
|
||||
] ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? DeepMergeRecordsDefaultHKTInternalPropValueHelper<Rest, K, M, [
|
||||
...Acc,
|
||||
ValueOfKey<Head, K>
|
||||
]> : [...Acc, ValueOfKey<Head, K>] : never;
|
||||
/**
|
||||
* Deep merge 2 arrays.
|
||||
*/
|
||||
type DeepMergeArraysDefaultHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeArraysDefaultHKTHelper<Ts, MF, M, []>;
|
||||
/**
|
||||
* Tail-recursive helper type for DeepMergeArraysDefaultHKT.
|
||||
*/
|
||||
type DeepMergeArraysDefaultHKTHelper<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M, Acc extends ReadonlyArray<unknown>> = Ts extends readonly [
|
||||
infer Head extends ReadonlyArray<unknown>,
|
||||
...infer Rest
|
||||
] ? Rest extends readonly [
|
||||
ReadonlyArray<unknown>,
|
||||
...ReadonlyArray<ReadonlyArray<unknown>>
|
||||
] ? DeepMergeArraysDefaultHKTHelper<Rest, MF, M, [...Acc, ...Head]> : [...Acc, ...Head] : never;
|
||||
/**
|
||||
* Deep merge 2 sets.
|
||||
*/
|
||||
type DeepMergeSetsDefaultHKT<Ts extends ReadonlyArray<unknown>> = Set<UnionSetValues<Ts>>;
|
||||
/**
|
||||
* Deep merge 2 maps.
|
||||
*/
|
||||
type DeepMergeMapsDefaultHKT<Ts extends ReadonlyArray<unknown>> = Map<UnionMapKeys<Ts>, UnionMapValues<Ts>>;
|
||||
/**
|
||||
* Get the merge functions with defaults apply from the given subset.
|
||||
*/
|
||||
type GetDeepMergeMergeFunctionsURIs<PMF extends Partial<DeepMergeMergeFunctionsURIs>> = Readonly<{
|
||||
DeepMergeRecordsURI: PMF["DeepMergeRecordsURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeRecordsURI"] : DeepMergeRecordsDefaultURI;
|
||||
DeepMergeArraysURI: PMF["DeepMergeArraysURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeArraysURI"] : DeepMergeArraysDefaultURI;
|
||||
DeepMergeSetsURI: PMF["DeepMergeSetsURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeSetsURI"] : DeepMergeSetsDefaultURI;
|
||||
DeepMergeMapsURI: PMF["DeepMergeMapsURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeMapsURI"] : DeepMergeMapsDefaultURI;
|
||||
DeepMergeOthersURI: PMF["DeepMergeOthersURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeOthersURI"] : DeepMergeLeafURI;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* The default merge functions.
|
||||
*/
|
||||
type MergeFunctions$1 = {
|
||||
mergeRecords: typeof mergeRecords$1;
|
||||
mergeArrays: typeof mergeArrays$1;
|
||||
mergeSets: typeof mergeSets$1;
|
||||
mergeMaps: typeof mergeMaps$1;
|
||||
mergeOthers: typeof mergeOthers$1;
|
||||
};
|
||||
/**
|
||||
* The default strategy to merge records into a target record.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this record
|
||||
* @param values - The records (including the target's value if there is one).
|
||||
*/
|
||||
declare function mergeRecords$1<Ts extends ReadonlyArray<Record<PropertyKey, unknown>>, U extends DeepMergeMergeIntoFunctionUtils<M, MM>, M, MM extends DeepMergeBuiltInMetaData>(m_target: Reference<Record<PropertyKey, unknown>>, values: Ts, utils: U, meta: M | undefined): void;
|
||||
/**
|
||||
* The default strategy to merge arrays into a target array.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this array
|
||||
* @param values - The arrays (including the target's value if there is one).
|
||||
*/
|
||||
declare function mergeArrays$1<Ts extends ReadonlyArray<ReadonlyArray<unknown>>>(m_target: Reference<unknown[]>, values: Ts): void;
|
||||
/**
|
||||
* The default strategy to merge sets into a target set.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this set
|
||||
* @param values - The sets (including the target's value if there is one).
|
||||
*/
|
||||
declare function mergeSets$1<Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>>(m_target: Reference<Set<unknown>>, values: Ts): void;
|
||||
/**
|
||||
* The default strategy to merge maps into a target map.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this map
|
||||
* @param values - The maps (including the target's value if there is one).
|
||||
*/
|
||||
declare function mergeMaps$1<Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>>(m_target: Reference<Map<unknown, unknown>>, values: Ts): void;
|
||||
/**
|
||||
* Set the target to the last value.
|
||||
*/
|
||||
declare function mergeOthers$1<Ts extends ReadonlyArray<unknown>>(m_target: Reference<unknown>, values: Ts): void;
|
||||
|
||||
/**
|
||||
* The default merge functions.
|
||||
*/
|
||||
type MergeFunctions = {
|
||||
mergeRecords: typeof mergeRecords;
|
||||
mergeArrays: typeof mergeArrays;
|
||||
mergeSets: typeof mergeSets;
|
||||
mergeMaps: typeof mergeMaps;
|
||||
mergeOthers: typeof mergeOthers;
|
||||
};
|
||||
/**
|
||||
* The default strategy to merge records.
|
||||
*
|
||||
* @param values - The records.
|
||||
*/
|
||||
declare function mergeRecords<Ts extends ReadonlyArray<Record<PropertyKey, unknown>>, U extends DeepMergeMergeFunctionUtils<M, MM>, MF extends DeepMergeMergeFunctionsURIs, M, MM extends DeepMergeBuiltInMetaData>(values: Ts, utils: U, meta: M | undefined): DeepMergeRecordsDefaultHKT<Ts, MF, M>;
|
||||
/**
|
||||
* The default strategy to merge arrays.
|
||||
*
|
||||
* @param values - The arrays.
|
||||
*/
|
||||
declare function mergeArrays<Ts extends ReadonlyArray<ReadonlyArray<unknown>>, MF extends DeepMergeMergeFunctionsURIs, M>(values: Ts): DeepMergeArraysDefaultHKT<Ts, MF, M>;
|
||||
/**
|
||||
* The default strategy to merge sets.
|
||||
*
|
||||
* @param values - The sets.
|
||||
*/
|
||||
declare function mergeSets<Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>>(values: Ts): DeepMergeSetsDefaultHKT<Ts>;
|
||||
/**
|
||||
* The default strategy to merge maps.
|
||||
*
|
||||
* @param values - The maps.
|
||||
*/
|
||||
declare function mergeMaps<Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>>(values: Ts): DeepMergeMapsDefaultHKT<Ts>;
|
||||
/**
|
||||
* Get the last value in the given array.
|
||||
*/
|
||||
declare function mergeOthers<Ts extends ReadonlyArray<unknown>>(values: Ts): unknown;
|
||||
|
||||
/**
|
||||
* The options the user can pass to customize deepmerge.
|
||||
*/
|
||||
type DeepMergeOptions<in out M, MM extends Readonly<Record<PropertyKey, unknown>> = DeepMergeBuiltInMetaData> = Partial<DeepMergeOptionsFull<M, MM & DeepMergeBuiltInMetaData>>;
|
||||
/**
|
||||
* The options the user can pass to customize deepmergeInto.
|
||||
*/
|
||||
type DeepMergeIntoOptions<in out M, MM extends Readonly<Record<PropertyKey, unknown>> = DeepMergeBuiltInMetaData> = Partial<DeepMergeIntoOptionsFull<M, MM & DeepMergeBuiltInMetaData>>;
|
||||
type MetaDataUpdater<in out M, MM extends DeepMergeBuiltInMetaData> = (previousMeta: M | undefined, metaMeta: Readonly<Partial<MM>>) => M;
|
||||
/**
|
||||
* All the options the user can pass to customize deepmerge.
|
||||
*/
|
||||
type DeepMergeOptionsFull<in out M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: DeepMergeMergeFunctions<M, MM>["mergeRecords"] | false;
|
||||
mergeArrays: DeepMergeMergeFunctions<M, MM>["mergeArrays"] | false;
|
||||
mergeMaps: DeepMergeMergeFunctions<M, MM>["mergeMaps"] | false;
|
||||
mergeSets: DeepMergeMergeFunctions<M, MM>["mergeSets"] | false;
|
||||
mergeOthers: DeepMergeMergeFunctions<M, MM>["mergeOthers"];
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
enableImplicitDefaultMerging: boolean;
|
||||
}>;
|
||||
/**
|
||||
* All the options the user can pass to customize deepmergeInto.
|
||||
*/
|
||||
type DeepMergeIntoOptionsFull<in out M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: DeepMergeMergeIntoFunctions<M, MM>["mergeRecords"] | false;
|
||||
mergeArrays: DeepMergeMergeIntoFunctions<M, MM>["mergeArrays"] | false;
|
||||
mergeMaps: DeepMergeMergeIntoFunctions<M, MM>["mergeMaps"] | false;
|
||||
mergeSets: DeepMergeMergeIntoFunctions<M, MM>["mergeSets"] | false;
|
||||
mergeOthers: DeepMergeMergeIntoFunctions<M, MM>["mergeOthers"];
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
}>;
|
||||
/**
|
||||
* An object that has a reference to a value.
|
||||
*/
|
||||
type Reference<T> = {
|
||||
value: T;
|
||||
};
|
||||
/**
|
||||
* All the merge functions that deepmerge uses.
|
||||
*/
|
||||
type DeepMergeMergeFunctions<in M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: <Ts extends ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>, U extends DeepMergeMergeFunctionUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeArrays: <Ts extends ReadonlyArray<ReadonlyArray<unknown>>, U extends DeepMergeMergeFunctionUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeMaps: <Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>, U extends DeepMergeMergeFunctionUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeSets: <Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>, U extends DeepMergeMergeFunctionUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeOthers: <Ts extends ReadonlyArray<unknown>, U extends DeepMergeMergeFunctionUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
}>;
|
||||
type DeepMergeMergeIntoFunctionsReturnType = void | symbol;
|
||||
/**
|
||||
* All the merge functions that deepmerge uses.
|
||||
*/
|
||||
type DeepMergeMergeIntoFunctions<in M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: <Ts extends ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>, U extends DeepMergeMergeIntoFunctionUtils<M, MM>>(m_target: Reference<Record<PropertyKey, unknown>>, values: Ts, utils: U, meta: M | undefined) => DeepMergeMergeIntoFunctionsReturnType;
|
||||
mergeArrays: <Ts extends ReadonlyArray<ReadonlyArray<unknown>>, U extends DeepMergeMergeIntoFunctionUtils<M, MM>>(m_target: Reference<unknown[]>, values: Ts, utils: U, meta: M | undefined) => DeepMergeMergeIntoFunctionsReturnType;
|
||||
mergeMaps: <Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>, U extends DeepMergeMergeIntoFunctionUtils<M, MM>>(m_target: Reference<Map<unknown, unknown>>, values: Ts, utils: U, meta: M | undefined) => DeepMergeMergeIntoFunctionsReturnType;
|
||||
mergeSets: <Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>, U extends DeepMergeMergeIntoFunctionUtils<M, MM>>(m_target: Reference<Set<unknown>>, values: Ts, utils: U, meta: M | undefined) => DeepMergeMergeIntoFunctionsReturnType;
|
||||
mergeOthers: <Ts extends ReadonlyArray<unknown>, U extends DeepMergeMergeIntoFunctionUtils<M, MM>>(m_target: Reference<unknown>, values: Ts, utils: U, meta: M | undefined) => DeepMergeMergeIntoFunctionsReturnType;
|
||||
}>;
|
||||
/**
|
||||
* The utils provided to the merge functions.
|
||||
*/
|
||||
type DeepMergeMergeFunctionUtils<in out M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeFunctions: DeepMergeMergeFunctions<M, MM>;
|
||||
defaultMergeFunctions: MergeFunctions;
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
deepmerge: <Ts extends ReadonlyArray<unknown>>(...values: Ts) => unknown;
|
||||
useImplicitDefaultMerging: boolean;
|
||||
actions: Readonly<{
|
||||
defaultMerge: symbol;
|
||||
skip: symbol;
|
||||
}>;
|
||||
}>;
|
||||
/**
|
||||
* The utils provided to the merge functions.
|
||||
*/
|
||||
type DeepMergeMergeIntoFunctionUtils<in out M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeFunctions: DeepMergeMergeIntoFunctions<M, MM>;
|
||||
defaultMergeFunctions: MergeFunctions$1;
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
deepmergeInto: <Target extends object, Ts extends ReadonlyArray<unknown>>(target: Target, ...values: Ts) => void;
|
||||
actions: Readonly<{
|
||||
defaultMerge: symbol;
|
||||
}>;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Deeply merge objects.
|
||||
*
|
||||
* @param objects - The objects to merge.
|
||||
*/
|
||||
declare function deepmerge<Ts extends Readonly<ReadonlyArray<unknown>>>(...objects: readonly [...Ts]): DeepMergeHKT<Ts, DeepMergeMergeFunctionsDefaultURIs, DeepMergeBuiltInMetaData>;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
*/
|
||||
declare function deepmergeCustom<PMF extends Partial<DeepMergeMergeFunctionsURIs>>(options: DeepMergeOptions<DeepMergeBuiltInMetaData, DeepMergeBuiltInMetaData>): <Ts extends ReadonlyArray<unknown>>(...objects: Ts) => DeepMergeHKT<Ts, GetDeepMergeMergeFunctionsURIs<PMF>, DeepMergeBuiltInMetaData>;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options and meta data.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
* @param rootMetaData - The meta data passed to the root items' being merged.
|
||||
*/
|
||||
declare function deepmergeCustom<PMF extends Partial<DeepMergeMergeFunctionsURIs>, MetaData, MetaMetaData extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(options: DeepMergeOptions<MetaData, MetaMetaData>, rootMetaData?: MetaData): <Ts extends ReadonlyArray<unknown>>(...objects: Ts) => DeepMergeHKT<Ts, GetDeepMergeMergeFunctionsURIs<PMF>, MetaData>;
|
||||
|
||||
/**
|
||||
* Deeply merge objects into a target.
|
||||
*
|
||||
* @param target - This object will be mutated with the merge result.
|
||||
* @param objects - The objects to merge into the target.
|
||||
*/
|
||||
declare function deepmergeInto<T extends object>(target: T, ...objects: ReadonlyArray<T>): void;
|
||||
/**
|
||||
* Deeply merge objects into a target.
|
||||
*
|
||||
* @param target - This object will be mutated with the merge result.
|
||||
* @param objects - The objects to merge into the target.
|
||||
*/
|
||||
declare function deepmergeInto<Target extends object, Ts extends ReadonlyArray<unknown>>(target: Target, ...objects: Ts): asserts target is FlatternAlias<Target & DeepMergeHKT<[
|
||||
Target,
|
||||
...Ts
|
||||
], DeepMergeMergeFunctionsDefaultURIs, DeepMergeBuiltInMetaData>>;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
*/
|
||||
declare function deepmergeIntoCustom(options: DeepMergeIntoOptions<DeepMergeBuiltInMetaData, DeepMergeBuiltInMetaData>): <Target extends object, Ts extends ReadonlyArray<unknown>>(target: Target, ...objects: Ts) => void;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options and meta data.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
* @param rootMetaData - The meta data passed to the root items' being merged.
|
||||
*/
|
||||
declare function deepmergeIntoCustom<MetaData, MetaMetaData extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(options: DeepMergeIntoOptions<MetaData, MetaMetaData>, rootMetaData?: MetaData): <Target extends object, Ts extends ReadonlyArray<unknown>>(target: Target, ...objects: Ts) => void;
|
||||
|
||||
export { DeepMergeArraysDefaultHKT, DeepMergeBuiltInMetaData, DeepMergeHKT, DeepMergeIntoOptions, DeepMergeLeaf, DeepMergeLeafHKT, DeepMergeLeafURI, DeepMergeMapsDefaultHKT, DeepMergeMergeFunctionURItoKind, DeepMergeMergeFunctionUtils, DeepMergeMergeFunctionsDefaultURIs, MergeFunctions as DeepMergeMergeFunctionsDefaults, DeepMergeMergeFunctionsURIs, DeepMergeMergeIntoFunctionUtils, MergeFunctions$1 as DeepMergeMergeIntoFunctionsDefaults, DeepMergeOptions, DeepMergeRecordsDefaultHKT, DeepMergeSetsDefaultHKT, Reference as DeepMergeValueReference, deepmerge, deepmergeCustom, deepmergeInto, deepmergeIntoCustom };
|
||||
531
node_modules/deepmerge-ts/dist/node/types/current/index.d.mts
generated
vendored
Normal file
531
node_modules/deepmerge-ts/dist/node/types/current/index.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,531 @@
|
|||
/**
|
||||
* Flatten a complex type such as a union or intersection of objects into a
|
||||
* single object.
|
||||
*/
|
||||
type FlatternAlias<T> = Is<T, unknown> extends true ? T : {
|
||||
[P in keyof T]: T[P];
|
||||
} & {};
|
||||
/**
|
||||
* Get the value of the given key in the given object.
|
||||
*/
|
||||
type ValueOfKey<T extends Record<PropertyKey, unknown>, K extends PropertyKey> = K extends keyof T ? T[K] : never;
|
||||
/**
|
||||
* Safely test whether or not the first given types extends the second.
|
||||
*
|
||||
* Needed in particular for testing if a type is "never".
|
||||
*/
|
||||
type Is<T1, T2> = [T1] extends [T2] ? true : false;
|
||||
/**
|
||||
* Safely test whether or not the given type is "never".
|
||||
*/
|
||||
type IsNever<T> = Is<T, never>;
|
||||
/**
|
||||
* Returns whether or not the given type a record.
|
||||
*/
|
||||
type IsRecord<T> = And<Not<IsNever<T>>, T extends Readonly<Record<PropertyKey, unknown>> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are records.
|
||||
*/
|
||||
type EveryIsRecord<Ts extends ReadonlyArray<unknown>> = Ts extends readonly [infer Head, ...infer Rest] ? IsRecord<Head> extends true ? Rest extends ReadonlyArray<unknown> ? EveryIsRecord<Rest> : true : false : true;
|
||||
/**
|
||||
* Returns whether or not the given type is an array.
|
||||
*/
|
||||
type IsArray<T> = And<Not<IsNever<T>>, T extends ReadonlyArray<unknown> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are arrays.
|
||||
*/
|
||||
type EveryIsArray<Ts extends ReadonlyArray<unknown>> = Ts extends readonly [infer T1] ? IsArray<T1> : Ts extends readonly [infer Head, ...infer Rest] ? IsArray<Head> extends true ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? EveryIsArray<Rest> : false : false : false;
|
||||
/**
|
||||
* Returns whether or not the given type is an set.
|
||||
*
|
||||
* Note: This may also return true for Maps.
|
||||
*/
|
||||
type IsSet<T> = And<Not<IsNever<T>>, T extends Readonly<ReadonlySet<unknown>> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are sets.
|
||||
*
|
||||
* Note: This may also return true if all are maps.
|
||||
*/
|
||||
type EveryIsSet<Ts extends ReadonlyArray<unknown>> = Ts extends Readonly<readonly [infer T1]> ? IsSet<T1> : Ts extends readonly [infer Head, ...infer Rest] ? IsSet<Head> extends true ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? EveryIsSet<Rest> : false : false : false;
|
||||
/**
|
||||
* Returns whether or not the given type is an map.
|
||||
*/
|
||||
type IsMap<T> = And<Not<IsNever<T>>, T extends Readonly<ReadonlyMap<unknown, unknown>> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are maps.
|
||||
*/
|
||||
type EveryIsMap<Ts extends ReadonlyArray<unknown>> = Ts extends Readonly<readonly [infer T1]> ? IsMap<T1> : Ts extends readonly [infer Head, ...infer Rest] ? IsMap<Head> extends true ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? EveryIsMap<Rest> : false : false : false;
|
||||
/**
|
||||
* And operator for types.
|
||||
*/
|
||||
type And<T1 extends boolean, T2 extends boolean> = T1 extends false ? false : T2;
|
||||
/**
|
||||
* Not operator for types.
|
||||
*/
|
||||
type Not<T extends boolean> = T extends true ? false : true;
|
||||
/**
|
||||
* Union of the sets' values' types
|
||||
*/
|
||||
type UnionSetValues<Ts extends ReadonlyArray<unknown>> = UnionSetValuesHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for UnionSetValues.
|
||||
*/
|
||||
type UnionSetValuesHelper<Ts extends ReadonlyArray<unknown>, Acc> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Readonly<ReadonlySet<infer V1>> ? Rest extends ReadonlyArray<unknown> ? UnionSetValuesHelper<Rest, Acc | V1> : Acc | V1 : never : Acc;
|
||||
/**
|
||||
* Union of the maps' values' types
|
||||
*/
|
||||
type UnionMapKeys<Ts extends ReadonlyArray<unknown>> = UnionMapKeysHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for UnionMapKeys.
|
||||
*/
|
||||
type UnionMapKeysHelper<Ts extends ReadonlyArray<unknown>, Acc> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Readonly<ReadonlyMap<infer K1, unknown>> ? Rest extends readonly [] ? Acc | K1 : UnionMapKeysHelper<Rest, Acc | K1> : never : Acc;
|
||||
/**
|
||||
* Union of the maps' keys' types
|
||||
*/
|
||||
type UnionMapValues<Ts extends ReadonlyArray<unknown>> = UnionMapValuesHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for UnionMapValues.
|
||||
*/
|
||||
type UnionMapValuesHelper<Ts extends ReadonlyArray<unknown>, Acc> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Readonly<ReadonlyMap<unknown, infer V1>> ? Rest extends readonly [] ? Acc | V1 : UnionMapValuesHelper<Rest, Acc | V1> : never : Acc;
|
||||
/**
|
||||
* Get the keys of the type what match a certain criteria.
|
||||
*/
|
||||
type KeysOfType<T, U> = {
|
||||
[K in keyof T]: T[K] extends U ? K : never;
|
||||
}[keyof T];
|
||||
/**
|
||||
* Get the required keys of the type.
|
||||
*/
|
||||
type RequiredKeys<T> = Exclude<KeysOfType<T, Exclude<T[keyof T], undefined>>, undefined>;
|
||||
/**
|
||||
* Get all the required keys on the types in the tuple.
|
||||
*/
|
||||
type RequiredKeysOf<Ts extends readonly [unknown, ...ReadonlyArray<unknown>]> = RequiredKeysOfHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for RequiredKeysOf.
|
||||
*/
|
||||
type RequiredKeysOfHelper<Ts extends readonly [unknown, ...ReadonlyArray<unknown>], Acc> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Record<PropertyKey, unknown> ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? RequiredKeysOfHelper<Rest, Acc | RequiredKeys<Head>> : Acc | RequiredKeys<Head> : never : Acc;
|
||||
/**
|
||||
* Get the optional keys of the type.
|
||||
*/
|
||||
type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>;
|
||||
/**
|
||||
* Get all the optional keys on the types in the tuple.
|
||||
*/
|
||||
type OptionalKeysOf<Ts extends readonly [unknown, ...ReadonlyArray<unknown>]> = OptionalKeysOfHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for OptionalKeysOf.
|
||||
*/
|
||||
type OptionalKeysOfHelper<Ts extends readonly [unknown, ...ReadonlyArray<unknown>], Acc> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Record<PropertyKey, unknown> ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? OptionalKeysOfHelper<Rest, Acc | OptionalKeys<Head>> : Acc | OptionalKeys<Head> : never : Acc;
|
||||
/**
|
||||
* Filter out nevers from a tuple.
|
||||
*/
|
||||
type FilterOutNever<T extends ReadonlyArray<unknown>> = FilterOutNeverHelper<T, []>;
|
||||
/**
|
||||
* Tail-recursive helper type for FilterOutNever.
|
||||
*/
|
||||
type FilterOutNeverHelper<T extends ReadonlyArray<unknown>, Acc extends ReadonlyArray<unknown>> = T extends readonly [] ? Acc : T extends readonly [infer Head, ...infer Rest] ? IsNever<Head> extends true ? FilterOutNeverHelper<Rest, Acc> : FilterOutNeverHelper<Rest, [...Acc, Head]> : T;
|
||||
/**
|
||||
* Is the type a tuple?
|
||||
*/
|
||||
type IsTuple<T extends ReadonlyArray<unknown>> = T extends readonly [] ? true : T extends readonly [unknown, ...ReadonlyArray<unknown>] ? true : false;
|
||||
|
||||
/**
|
||||
* Mapping of merge function URIs to the merge function type.
|
||||
*/
|
||||
interface DeepMergeMergeFunctionURItoKind<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, in out M> {
|
||||
readonly DeepMergeLeafURI: DeepMergeLeaf<Ts>;
|
||||
readonly DeepMergeRecordsDefaultURI: DeepMergeRecordsDefaultHKT<Ts, MF, M>;
|
||||
readonly DeepMergeArraysDefaultURI: DeepMergeArraysDefaultHKT<Ts, MF, M>;
|
||||
readonly DeepMergeSetsDefaultURI: DeepMergeSetsDefaultHKT<Ts>;
|
||||
readonly DeepMergeMapsDefaultURI: DeepMergeMapsDefaultHKT<Ts>;
|
||||
}
|
||||
/**
|
||||
* Get the type of the given merge function via its URI.
|
||||
*/
|
||||
type DeepMergeMergeFunctionKind<URI extends DeepMergeMergeFunctionURIs, Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionURItoKind<Ts, MF, M>[URI];
|
||||
/**
|
||||
* A union of all valid merge function URIs.
|
||||
*/
|
||||
type DeepMergeMergeFunctionURIs = keyof DeepMergeMergeFunctionURItoKind<ReadonlyArray<unknown>, DeepMergeMergeFunctionsURIs, unknown>;
|
||||
/**
|
||||
* The merge functions to use when deep merging.
|
||||
*/
|
||||
type DeepMergeMergeFunctionsURIs = Readonly<{
|
||||
/**
|
||||
* The merge function to merge records with.
|
||||
*/
|
||||
DeepMergeRecordsURI: DeepMergeMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge arrays with.
|
||||
*/
|
||||
DeepMergeArraysURI: DeepMergeMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge sets with.
|
||||
*/
|
||||
DeepMergeSetsURI: DeepMergeMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge maps with.
|
||||
*/
|
||||
DeepMergeMapsURI: DeepMergeMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge other things with.
|
||||
*/
|
||||
DeepMergeOthersURI: DeepMergeMergeFunctionURIs;
|
||||
}>;
|
||||
/**
|
||||
* Deep merge types.
|
||||
*/
|
||||
type DeepMergeHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = IsTuple<Ts> extends true ? Ts extends readonly [] ? undefined : Ts extends readonly [infer T1] ? T1 : EveryIsArray<Ts> extends true ? DeepMergeArraysHKT<Ts, MF, M> : EveryIsMap<Ts> extends true ? DeepMergeMapsHKT<Ts, MF, M> : EveryIsSet<Ts> extends true ? DeepMergeSetsHKT<Ts, MF, M> : EveryIsRecord<Ts> extends true ? DeepMergeRecordsHKT<Ts, MF, M> : DeepMergeOthersHKT<Ts, MF, M> : unknown;
|
||||
/**
|
||||
* Deep merge records.
|
||||
*/
|
||||
type DeepMergeRecordsHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionKind<MF["DeepMergeRecordsURI"], Ts, MF, M>;
|
||||
/**
|
||||
* Deep merge arrays.
|
||||
*/
|
||||
type DeepMergeArraysHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionKind<MF["DeepMergeArraysURI"], Ts, MF, M>;
|
||||
/**
|
||||
* Deep merge sets.
|
||||
*/
|
||||
type DeepMergeSetsHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionKind<MF["DeepMergeSetsURI"], Ts, MF, M>;
|
||||
/**
|
||||
* Deep merge maps.
|
||||
*/
|
||||
type DeepMergeMapsHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionKind<MF["DeepMergeMapsURI"], Ts, MF, M>;
|
||||
/**
|
||||
* Deep merge other things.
|
||||
*/
|
||||
type DeepMergeOthersHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionKind<MF["DeepMergeOthersURI"], Ts, MF, M>;
|
||||
/**
|
||||
* The merge function that returns a leaf.
|
||||
*/
|
||||
type DeepMergeLeafURI = "DeepMergeLeafURI";
|
||||
/**
|
||||
* Get the leaf type from many types that can't be merged.
|
||||
*
|
||||
* @deprecated Use `DeepMergeLeaf` instead.
|
||||
*/
|
||||
type DeepMergeLeafHKT<Ts extends ReadonlyArray<unknown>> = DeepMergeLeaf<Ts>;
|
||||
/**
|
||||
* Get the leaf type from many types that can't be merged.
|
||||
*/
|
||||
type DeepMergeLeaf<Ts extends ReadonlyArray<unknown>> = Ts extends readonly [] ? never : Ts extends readonly [infer T] ? T : Ts extends readonly [...infer Rest, infer Tail] ? IsNever<Tail> extends true ? Rest extends ReadonlyArray<unknown> ? DeepMergeLeaf<Rest> : never : Tail : never;
|
||||
/**
|
||||
* The meta data deepmerge is able to provide.
|
||||
*/
|
||||
type DeepMergeBuiltInMetaData = Readonly<{
|
||||
key: PropertyKey;
|
||||
parents: ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* The default merge function to merge records with.
|
||||
*/
|
||||
type DeepMergeRecordsDefaultURI = "DeepMergeRecordsDefaultURI";
|
||||
/**
|
||||
* The default merge function to merge arrays with.
|
||||
*/
|
||||
type DeepMergeArraysDefaultURI = "DeepMergeArraysDefaultURI";
|
||||
/**
|
||||
* The default merge function to merge sets with.
|
||||
*/
|
||||
type DeepMergeSetsDefaultURI = "DeepMergeSetsDefaultURI";
|
||||
/**
|
||||
* The default merge function to merge maps with.
|
||||
*/
|
||||
type DeepMergeMapsDefaultURI = "DeepMergeMapsDefaultURI";
|
||||
/**
|
||||
* The default merge functions to use when deep merging.
|
||||
*/
|
||||
type DeepMergeMergeFunctionsDefaultURIs = Readonly<{
|
||||
DeepMergeRecordsURI: DeepMergeRecordsDefaultURI;
|
||||
DeepMergeArraysURI: DeepMergeArraysDefaultURI;
|
||||
DeepMergeSetsURI: DeepMergeSetsDefaultURI;
|
||||
DeepMergeMapsURI: DeepMergeMapsDefaultURI;
|
||||
DeepMergeOthersURI: DeepMergeLeafURI;
|
||||
}>;
|
||||
/**
|
||||
* A union of all the props that should not be included in type information for
|
||||
* merged records.
|
||||
*/
|
||||
type BlacklistedRecordProps = "__proto__";
|
||||
/**
|
||||
* Deep merge records.
|
||||
*/
|
||||
type DeepMergeRecordsDefaultHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = Ts extends Readonly<readonly [unknown, ...Readonly<ReadonlyArray<unknown>>]> ? FlatternAlias<Omit<DeepMergeRecordsDefaultHKTInternalProps<Ts, MF, M>, BlacklistedRecordProps>> : {};
|
||||
/**
|
||||
* Deep merge record props.
|
||||
*/
|
||||
type DeepMergeRecordsDefaultHKTInternalProps<Ts extends readonly [unknown, ...ReadonlyArray<unknown>], MF extends DeepMergeMergeFunctionsURIs, M> = {
|
||||
[K in OptionalKeysOf<Ts>]?: DeepMergeHKT<DeepMergeRecordsDefaultHKTInternalPropValue<Ts, K, M>, MF, M>;
|
||||
} & {
|
||||
[K in RequiredKeysOf<Ts>]: DeepMergeHKT<DeepMergeRecordsDefaultHKTInternalPropValue<Ts, K, M>, MF, M>;
|
||||
};
|
||||
/**
|
||||
* Get the value of the property.
|
||||
*/
|
||||
type DeepMergeRecordsDefaultHKTInternalPropValue<Ts extends readonly [unknown, ...ReadonlyArray<unknown>], K extends PropertyKey, M> = FilterOutNever<DeepMergeRecordsDefaultHKTInternalPropValueHelper<Ts, K, M, readonly []>>;
|
||||
/**
|
||||
* Tail-recursive helper type for DeepMergeRecordsDefaultHKTInternalPropValue.
|
||||
*/
|
||||
type DeepMergeRecordsDefaultHKTInternalPropValueHelper<Ts extends readonly [unknown, ...ReadonlyArray<unknown>], K extends PropertyKey, M, Acc extends ReadonlyArray<unknown>> = Ts extends readonly [
|
||||
infer Head extends Readonly<Record<PropertyKey, unknown>>,
|
||||
...infer Rest
|
||||
] ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? DeepMergeRecordsDefaultHKTInternalPropValueHelper<Rest, K, M, [
|
||||
...Acc,
|
||||
ValueOfKey<Head, K>
|
||||
]> : [...Acc, ValueOfKey<Head, K>] : never;
|
||||
/**
|
||||
* Deep merge 2 arrays.
|
||||
*/
|
||||
type DeepMergeArraysDefaultHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeArraysDefaultHKTHelper<Ts, MF, M, []>;
|
||||
/**
|
||||
* Tail-recursive helper type for DeepMergeArraysDefaultHKT.
|
||||
*/
|
||||
type DeepMergeArraysDefaultHKTHelper<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M, Acc extends ReadonlyArray<unknown>> = Ts extends readonly [
|
||||
infer Head extends ReadonlyArray<unknown>,
|
||||
...infer Rest
|
||||
] ? Rest extends readonly [
|
||||
ReadonlyArray<unknown>,
|
||||
...ReadonlyArray<ReadonlyArray<unknown>>
|
||||
] ? DeepMergeArraysDefaultHKTHelper<Rest, MF, M, [...Acc, ...Head]> : [...Acc, ...Head] : never;
|
||||
/**
|
||||
* Deep merge 2 sets.
|
||||
*/
|
||||
type DeepMergeSetsDefaultHKT<Ts extends ReadonlyArray<unknown>> = Set<UnionSetValues<Ts>>;
|
||||
/**
|
||||
* Deep merge 2 maps.
|
||||
*/
|
||||
type DeepMergeMapsDefaultHKT<Ts extends ReadonlyArray<unknown>> = Map<UnionMapKeys<Ts>, UnionMapValues<Ts>>;
|
||||
/**
|
||||
* Get the merge functions with defaults apply from the given subset.
|
||||
*/
|
||||
type GetDeepMergeMergeFunctionsURIs<PMF extends Partial<DeepMergeMergeFunctionsURIs>> = Readonly<{
|
||||
DeepMergeRecordsURI: PMF["DeepMergeRecordsURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeRecordsURI"] : DeepMergeRecordsDefaultURI;
|
||||
DeepMergeArraysURI: PMF["DeepMergeArraysURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeArraysURI"] : DeepMergeArraysDefaultURI;
|
||||
DeepMergeSetsURI: PMF["DeepMergeSetsURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeSetsURI"] : DeepMergeSetsDefaultURI;
|
||||
DeepMergeMapsURI: PMF["DeepMergeMapsURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeMapsURI"] : DeepMergeMapsDefaultURI;
|
||||
DeepMergeOthersURI: PMF["DeepMergeOthersURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeOthersURI"] : DeepMergeLeafURI;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* The default merge functions.
|
||||
*/
|
||||
type MergeFunctions$1 = {
|
||||
mergeRecords: typeof mergeRecords$1;
|
||||
mergeArrays: typeof mergeArrays$1;
|
||||
mergeSets: typeof mergeSets$1;
|
||||
mergeMaps: typeof mergeMaps$1;
|
||||
mergeOthers: typeof mergeOthers$1;
|
||||
};
|
||||
/**
|
||||
* The default strategy to merge records into a target record.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this record
|
||||
* @param values - The records (including the target's value if there is one).
|
||||
*/
|
||||
declare function mergeRecords$1<Ts extends ReadonlyArray<Record<PropertyKey, unknown>>, U extends DeepMergeMergeIntoFunctionUtils<M, MM>, M, MM extends DeepMergeBuiltInMetaData>(m_target: Reference<Record<PropertyKey, unknown>>, values: Ts, utils: U, meta: M | undefined): void;
|
||||
/**
|
||||
* The default strategy to merge arrays into a target array.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this array
|
||||
* @param values - The arrays (including the target's value if there is one).
|
||||
*/
|
||||
declare function mergeArrays$1<Ts extends ReadonlyArray<ReadonlyArray<unknown>>>(m_target: Reference<unknown[]>, values: Ts): void;
|
||||
/**
|
||||
* The default strategy to merge sets into a target set.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this set
|
||||
* @param values - The sets (including the target's value if there is one).
|
||||
*/
|
||||
declare function mergeSets$1<Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>>(m_target: Reference<Set<unknown>>, values: Ts): void;
|
||||
/**
|
||||
* The default strategy to merge maps into a target map.
|
||||
*
|
||||
* @param m_target - The result will be mutated into this map
|
||||
* @param values - The maps (including the target's value if there is one).
|
||||
*/
|
||||
declare function mergeMaps$1<Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>>(m_target: Reference<Map<unknown, unknown>>, values: Ts): void;
|
||||
/**
|
||||
* Set the target to the last value.
|
||||
*/
|
||||
declare function mergeOthers$1<Ts extends ReadonlyArray<unknown>>(m_target: Reference<unknown>, values: Ts): void;
|
||||
|
||||
/**
|
||||
* The default merge functions.
|
||||
*/
|
||||
type MergeFunctions = {
|
||||
mergeRecords: typeof mergeRecords;
|
||||
mergeArrays: typeof mergeArrays;
|
||||
mergeSets: typeof mergeSets;
|
||||
mergeMaps: typeof mergeMaps;
|
||||
mergeOthers: typeof mergeOthers;
|
||||
};
|
||||
/**
|
||||
* The default strategy to merge records.
|
||||
*
|
||||
* @param values - The records.
|
||||
*/
|
||||
declare function mergeRecords<Ts extends ReadonlyArray<Record<PropertyKey, unknown>>, U extends DeepMergeMergeFunctionUtils<M, MM>, MF extends DeepMergeMergeFunctionsURIs, M, MM extends DeepMergeBuiltInMetaData>(values: Ts, utils: U, meta: M | undefined): DeepMergeRecordsDefaultHKT<Ts, MF, M>;
|
||||
/**
|
||||
* The default strategy to merge arrays.
|
||||
*
|
||||
* @param values - The arrays.
|
||||
*/
|
||||
declare function mergeArrays<Ts extends ReadonlyArray<ReadonlyArray<unknown>>, MF extends DeepMergeMergeFunctionsURIs, M>(values: Ts): DeepMergeArraysDefaultHKT<Ts, MF, M>;
|
||||
/**
|
||||
* The default strategy to merge sets.
|
||||
*
|
||||
* @param values - The sets.
|
||||
*/
|
||||
declare function mergeSets<Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>>(values: Ts): DeepMergeSetsDefaultHKT<Ts>;
|
||||
/**
|
||||
* The default strategy to merge maps.
|
||||
*
|
||||
* @param values - The maps.
|
||||
*/
|
||||
declare function mergeMaps<Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>>(values: Ts): DeepMergeMapsDefaultHKT<Ts>;
|
||||
/**
|
||||
* Get the last value in the given array.
|
||||
*/
|
||||
declare function mergeOthers<Ts extends ReadonlyArray<unknown>>(values: Ts): unknown;
|
||||
|
||||
/**
|
||||
* The options the user can pass to customize deepmerge.
|
||||
*/
|
||||
type DeepMergeOptions<in out M, MM extends Readonly<Record<PropertyKey, unknown>> = DeepMergeBuiltInMetaData> = Partial<DeepMergeOptionsFull<M, MM & DeepMergeBuiltInMetaData>>;
|
||||
/**
|
||||
* The options the user can pass to customize deepmergeInto.
|
||||
*/
|
||||
type DeepMergeIntoOptions<in out M, MM extends Readonly<Record<PropertyKey, unknown>> = DeepMergeBuiltInMetaData> = Partial<DeepMergeIntoOptionsFull<M, MM & DeepMergeBuiltInMetaData>>;
|
||||
type MetaDataUpdater<in out M, MM extends DeepMergeBuiltInMetaData> = (previousMeta: M | undefined, metaMeta: Readonly<Partial<MM>>) => M;
|
||||
/**
|
||||
* All the options the user can pass to customize deepmerge.
|
||||
*/
|
||||
type DeepMergeOptionsFull<in out M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: DeepMergeMergeFunctions<M, MM>["mergeRecords"] | false;
|
||||
mergeArrays: DeepMergeMergeFunctions<M, MM>["mergeArrays"] | false;
|
||||
mergeMaps: DeepMergeMergeFunctions<M, MM>["mergeMaps"] | false;
|
||||
mergeSets: DeepMergeMergeFunctions<M, MM>["mergeSets"] | false;
|
||||
mergeOthers: DeepMergeMergeFunctions<M, MM>["mergeOthers"];
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
enableImplicitDefaultMerging: boolean;
|
||||
}>;
|
||||
/**
|
||||
* All the options the user can pass to customize deepmergeInto.
|
||||
*/
|
||||
type DeepMergeIntoOptionsFull<in out M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: DeepMergeMergeIntoFunctions<M, MM>["mergeRecords"] | false;
|
||||
mergeArrays: DeepMergeMergeIntoFunctions<M, MM>["mergeArrays"] | false;
|
||||
mergeMaps: DeepMergeMergeIntoFunctions<M, MM>["mergeMaps"] | false;
|
||||
mergeSets: DeepMergeMergeIntoFunctions<M, MM>["mergeSets"] | false;
|
||||
mergeOthers: DeepMergeMergeIntoFunctions<M, MM>["mergeOthers"];
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
}>;
|
||||
/**
|
||||
* An object that has a reference to a value.
|
||||
*/
|
||||
type Reference<T> = {
|
||||
value: T;
|
||||
};
|
||||
/**
|
||||
* All the merge functions that deepmerge uses.
|
||||
*/
|
||||
type DeepMergeMergeFunctions<in M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: <Ts extends ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>, U extends DeepMergeMergeFunctionUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeArrays: <Ts extends ReadonlyArray<ReadonlyArray<unknown>>, U extends DeepMergeMergeFunctionUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeMaps: <Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>, U extends DeepMergeMergeFunctionUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeSets: <Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>, U extends DeepMergeMergeFunctionUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeOthers: <Ts extends ReadonlyArray<unknown>, U extends DeepMergeMergeFunctionUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
}>;
|
||||
type DeepMergeMergeIntoFunctionsReturnType = void | symbol;
|
||||
/**
|
||||
* All the merge functions that deepmerge uses.
|
||||
*/
|
||||
type DeepMergeMergeIntoFunctions<in M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: <Ts extends ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>, U extends DeepMergeMergeIntoFunctionUtils<M, MM>>(m_target: Reference<Record<PropertyKey, unknown>>, values: Ts, utils: U, meta: M | undefined) => DeepMergeMergeIntoFunctionsReturnType;
|
||||
mergeArrays: <Ts extends ReadonlyArray<ReadonlyArray<unknown>>, U extends DeepMergeMergeIntoFunctionUtils<M, MM>>(m_target: Reference<unknown[]>, values: Ts, utils: U, meta: M | undefined) => DeepMergeMergeIntoFunctionsReturnType;
|
||||
mergeMaps: <Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>, U extends DeepMergeMergeIntoFunctionUtils<M, MM>>(m_target: Reference<Map<unknown, unknown>>, values: Ts, utils: U, meta: M | undefined) => DeepMergeMergeIntoFunctionsReturnType;
|
||||
mergeSets: <Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>, U extends DeepMergeMergeIntoFunctionUtils<M, MM>>(m_target: Reference<Set<unknown>>, values: Ts, utils: U, meta: M | undefined) => DeepMergeMergeIntoFunctionsReturnType;
|
||||
mergeOthers: <Ts extends ReadonlyArray<unknown>, U extends DeepMergeMergeIntoFunctionUtils<M, MM>>(m_target: Reference<unknown>, values: Ts, utils: U, meta: M | undefined) => DeepMergeMergeIntoFunctionsReturnType;
|
||||
}>;
|
||||
/**
|
||||
* The utils provided to the merge functions.
|
||||
*/
|
||||
type DeepMergeMergeFunctionUtils<in out M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeFunctions: DeepMergeMergeFunctions<M, MM>;
|
||||
defaultMergeFunctions: MergeFunctions;
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
deepmerge: <Ts extends ReadonlyArray<unknown>>(...values: Ts) => unknown;
|
||||
useImplicitDefaultMerging: boolean;
|
||||
actions: Readonly<{
|
||||
defaultMerge: symbol;
|
||||
skip: symbol;
|
||||
}>;
|
||||
}>;
|
||||
/**
|
||||
* The utils provided to the merge functions.
|
||||
*/
|
||||
type DeepMergeMergeIntoFunctionUtils<in out M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeFunctions: DeepMergeMergeIntoFunctions<M, MM>;
|
||||
defaultMergeFunctions: MergeFunctions$1;
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
deepmergeInto: <Target extends object, Ts extends ReadonlyArray<unknown>>(target: Target, ...values: Ts) => void;
|
||||
actions: Readonly<{
|
||||
defaultMerge: symbol;
|
||||
}>;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Deeply merge objects.
|
||||
*
|
||||
* @param objects - The objects to merge.
|
||||
*/
|
||||
declare function deepmerge<Ts extends Readonly<ReadonlyArray<unknown>>>(...objects: readonly [...Ts]): DeepMergeHKT<Ts, DeepMergeMergeFunctionsDefaultURIs, DeepMergeBuiltInMetaData>;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
*/
|
||||
declare function deepmergeCustom<PMF extends Partial<DeepMergeMergeFunctionsURIs>>(options: DeepMergeOptions<DeepMergeBuiltInMetaData, DeepMergeBuiltInMetaData>): <Ts extends ReadonlyArray<unknown>>(...objects: Ts) => DeepMergeHKT<Ts, GetDeepMergeMergeFunctionsURIs<PMF>, DeepMergeBuiltInMetaData>;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options and meta data.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
* @param rootMetaData - The meta data passed to the root items' being merged.
|
||||
*/
|
||||
declare function deepmergeCustom<PMF extends Partial<DeepMergeMergeFunctionsURIs>, MetaData, MetaMetaData extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(options: DeepMergeOptions<MetaData, MetaMetaData>, rootMetaData?: MetaData): <Ts extends ReadonlyArray<unknown>>(...objects: Ts) => DeepMergeHKT<Ts, GetDeepMergeMergeFunctionsURIs<PMF>, MetaData>;
|
||||
|
||||
/**
|
||||
* Deeply merge objects into a target.
|
||||
*
|
||||
* @param target - This object will be mutated with the merge result.
|
||||
* @param objects - The objects to merge into the target.
|
||||
*/
|
||||
declare function deepmergeInto<T extends object>(target: T, ...objects: ReadonlyArray<T>): void;
|
||||
/**
|
||||
* Deeply merge objects into a target.
|
||||
*
|
||||
* @param target - This object will be mutated with the merge result.
|
||||
* @param objects - The objects to merge into the target.
|
||||
*/
|
||||
declare function deepmergeInto<Target extends object, Ts extends ReadonlyArray<unknown>>(target: Target, ...objects: Ts): asserts target is FlatternAlias<Target & DeepMergeHKT<[
|
||||
Target,
|
||||
...Ts
|
||||
], DeepMergeMergeFunctionsDefaultURIs, DeepMergeBuiltInMetaData>>;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
*/
|
||||
declare function deepmergeIntoCustom(options: DeepMergeIntoOptions<DeepMergeBuiltInMetaData, DeepMergeBuiltInMetaData>): <Target extends object, Ts extends ReadonlyArray<unknown>>(target: Target, ...objects: Ts) => void;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options and meta data.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
* @param rootMetaData - The meta data passed to the root items' being merged.
|
||||
*/
|
||||
declare function deepmergeIntoCustom<MetaData, MetaMetaData extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(options: DeepMergeIntoOptions<MetaData, MetaMetaData>, rootMetaData?: MetaData): <Target extends object, Ts extends ReadonlyArray<unknown>>(target: Target, ...objects: Ts) => void;
|
||||
|
||||
export { DeepMergeArraysDefaultHKT, DeepMergeBuiltInMetaData, DeepMergeHKT, DeepMergeIntoOptions, DeepMergeLeaf, DeepMergeLeafHKT, DeepMergeLeafURI, DeepMergeMapsDefaultHKT, DeepMergeMergeFunctionURItoKind, DeepMergeMergeFunctionUtils, DeepMergeMergeFunctionsDefaultURIs, MergeFunctions as DeepMergeMergeFunctionsDefaults, DeepMergeMergeFunctionsURIs, DeepMergeMergeIntoFunctionUtils, MergeFunctions$1 as DeepMergeMergeIntoFunctionsDefaults, DeepMergeOptions, DeepMergeRecordsDefaultHKT, DeepMergeSetsDefaultHKT, Reference as DeepMergeValueReference, deepmerge, deepmergeCustom, deepmergeInto, deepmergeIntoCustom };
|
||||
80
node_modules/deepmerge-ts/dist/node/types/legacy/v4_0.d.ts
generated
vendored
Normal file
80
node_modules/deepmerge-ts/dist/node/types/legacy/v4_0.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* These types are a more simplified version of this library's types
|
||||
* designed to work with versions of TypeScript < 4.1
|
||||
*/
|
||||
|
||||
declare type MetaDataUpdater = (previousMeta: any, metaMeta: any) => any;
|
||||
|
||||
/**
|
||||
* All the options the user can pass to customize deepmerge.
|
||||
*/
|
||||
declare type DeepMergeOptionsFull = Readonly<{
|
||||
mergeRecords: DeepMergeMergeFunctions["mergeRecords"] | false;
|
||||
mergeArrays: DeepMergeMergeFunctions["mergeArrays"] | false;
|
||||
mergeMaps: DeepMergeMergeFunctions["mergeMaps"] | false;
|
||||
mergeSets: DeepMergeMergeFunctions["mergeSets"] | false;
|
||||
mergeOthers: DeepMergeMergeFunctions["mergeOthers"];
|
||||
metaDataUpdater: MetaDataUpdater;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* All the merge functions that deepmerge uses.
|
||||
*/
|
||||
declare type DeepMergeMergeFunctions = Readonly<{
|
||||
mergeRecords: <Ts extends ReadonlyArray<Readonly<Record<keyof any, any>>>, U extends DeepMergeMergeFunctionUtils>(records: Ts, utils: U, meta: any) => any;
|
||||
mergeArrays: <Ts extends ReadonlyArray<ReadonlyArray<any>>, U extends DeepMergeMergeFunctionUtils>(records: Ts, utils: U, meta: any) => any;
|
||||
mergeMaps: <Ts extends ReadonlyArray<Readonly<ReadonlyMap<any, any>>>, U extends DeepMergeMergeFunctionUtils>(records: Ts, utils: U, meta: any) => any;
|
||||
mergeSets: <Ts extends ReadonlyArray<Readonly<ReadonlySet<any>>>, U extends DeepMergeMergeFunctionUtils>(records: Ts, utils: U, meta: any) => any;
|
||||
mergeOthers: <Ts extends ReadonlyArray<any>, U extends DeepMergeMergeFunctionUtils>(records: Ts, utils: U, meta: any) => any;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* The utils provided to the merge functions.
|
||||
*/
|
||||
declare type DeepMergeMergeFunctionUtils = Readonly<{
|
||||
mergeFunctions: DeepMergeMergeFunctions;
|
||||
defaultMergeFunctions: DeepMergeMergeFunctionsDefaults;
|
||||
metaDataUpdater: MetaDataUpdater;
|
||||
deepmerge: <Ts extends ReadonlyArray<any>>(...values: Ts) => any;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* The default merge functions.
|
||||
*/
|
||||
declare type DeepMergeMergeFunctionsDefaults = Readonly<{
|
||||
mergeMaps: (values: Record<keyof any, any>[]) => any;
|
||||
mergeSets: (values: any[][]) => any;
|
||||
mergeArrays: (values: Set<any>[]) => any;
|
||||
mergeRecords: (values: Map<any, any>[], utils: DeepMergeMergeFunctionUtils, meta: any) => any;
|
||||
mergeOthers: (values: any[]) => any;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Deeply merge objects.
|
||||
*
|
||||
* @param objects - The objects to merge.
|
||||
*/
|
||||
declare function deepmerge(): undefined;
|
||||
declare function deepmerge<T0>(arg0: T0): T0;
|
||||
declare function deepmerge<T0, T1>(arg0: T0, arg1: T1): T0 & T1;
|
||||
declare function deepmerge<T0, T1, T2>(arg0: T0, arg1: T1, arg2: T2): T0 & T1 & T2;
|
||||
declare function deepmerge<T0, T1, T2, T3>(arg0: T0, arg1: T1, arg2: T2, arg3: T3): T0 & T1 & T2 & T3;
|
||||
declare function deepmerge<T0, T1, T2, T3, T4>(arg0: T0, arg1: T1, arg2: T2, arg3: T3, arg4: T4): T0 & T1 & T2 & T3 & T4;
|
||||
declare function deepmerge<T0, T1, T2, T3, T4, T5>(arg0: T0, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5): T0 & T1 & T2 & T3 & T4 & T5;
|
||||
declare function deepmerge<T0, T1, T2, T3, T4, T5, T6>(arg0: T0, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6): T0 & T1 & T2 & T3 & T4 & T5 & T6;
|
||||
declare function deepmerge<T0, T1, T2, T3, T4, T5, T6, T7>(arg0: T0, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7): T0 & T1 & T2 & T3 & T4 & T5 & T6 & T7;
|
||||
declare function deepmerge<T0, T1, T2, T3, T4, T5, T6, T7, T8>(arg0: T0, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8): T0 & T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8;
|
||||
declare function deepmerge<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(arg0: T0, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8, arg9: T9): T0 & T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9;
|
||||
declare function deepmerge(...args: any[]): any;
|
||||
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options and meta data.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
* @param rootMetaData - The meta data passed to the root items' being merged.
|
||||
*/
|
||||
declare function deepmergeCustom(options: Partial<DeepMergeOptionsFull>, rootMetaData?: any): (...objects: any[]) => any;
|
||||
|
||||
export { deepmerge, deepmergeCustom };
|
||||
407
node_modules/deepmerge-ts/dist/node/types/legacy/v4_6.d.ts
generated
vendored
Normal file
407
node_modules/deepmerge-ts/dist/node/types/legacy/v4_6.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,407 @@
|
|||
/**
|
||||
* Flatten a complex type such as a union or intersection of objects into a
|
||||
* single object.
|
||||
*/
|
||||
declare type FlatternAlias<T> = {
|
||||
[P in keyof T]: T[P];
|
||||
} & {};
|
||||
/**
|
||||
* Get the value of the given key in the given object.
|
||||
*/
|
||||
declare type ValueOfKey<T extends Record<PropertyKey, unknown>, K extends PropertyKey> = K extends keyof T ? T[K] : never;
|
||||
/**
|
||||
* Safely test whether or not the first given types extends the second.
|
||||
*
|
||||
* Needed in particular for testing if a type is "never".
|
||||
*/
|
||||
declare type Is<T1, T2> = [T1] extends [T2] ? true : false;
|
||||
/**
|
||||
* Safely test whether or not the given type is "never".
|
||||
*/
|
||||
declare type IsNever<T> = Is<T, never>;
|
||||
/**
|
||||
* Returns whether or not the given type a record.
|
||||
*/
|
||||
declare type IsRecord<T> = And<Not<IsNever<T>>, T extends Readonly<Record<PropertyKey, unknown>> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are records.
|
||||
*/
|
||||
declare type EveryIsRecord<Ts extends ReadonlyArray<unknown>> = Ts extends readonly [infer Head, ...infer Rest] ? IsRecord<Head> extends true ? Rest extends ReadonlyArray<unknown> ? EveryIsRecord<Rest> : true : false : true;
|
||||
/**
|
||||
* Returns whether or not the given type is an array.
|
||||
*/
|
||||
declare type IsArray<T> = And<Not<IsNever<T>>, T extends ReadonlyArray<unknown> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are arrays.
|
||||
*/
|
||||
declare type EveryIsArray<Ts extends ReadonlyArray<unknown>> = Ts extends readonly [infer T1] ? IsArray<T1> : Ts extends readonly [infer Head, ...infer Rest] ? IsArray<Head> extends true ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? EveryIsArray<Rest> : false : false : false;
|
||||
/**
|
||||
* Returns whether or not the given type is an set.
|
||||
*
|
||||
* Note: This may also return true for Maps.
|
||||
*/
|
||||
declare type IsSet<T> = And<Not<IsNever<T>>, T extends Readonly<ReadonlySet<unknown>> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are sets.
|
||||
*
|
||||
* Note: This may also return true if all are maps.
|
||||
*/
|
||||
declare type EveryIsSet<Ts extends ReadonlyArray<unknown>> = Ts extends Readonly<readonly [infer T1]> ? IsSet<T1> : Ts extends readonly [infer Head, ...infer Rest] ? IsSet<Head> extends true ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? EveryIsSet<Rest> : false : false : false;
|
||||
/**
|
||||
* Returns whether or not the given type is an map.
|
||||
*/
|
||||
declare type IsMap<T> = And<Not<IsNever<T>>, T extends Readonly<ReadonlyMap<unknown, unknown>> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are maps.
|
||||
*/
|
||||
declare type EveryIsMap<Ts extends ReadonlyArray<unknown>> = Ts extends Readonly<readonly [infer T1]> ? IsMap<T1> : Ts extends readonly [infer Head, ...infer Rest] ? IsMap<Head> extends true ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? EveryIsMap<Rest> : false : false : false;
|
||||
/**
|
||||
* And operator for types.
|
||||
*/
|
||||
declare type And<T1 extends boolean, T2 extends boolean> = T1 extends false ? false : T2;
|
||||
/**
|
||||
* Not operator for types.
|
||||
*/
|
||||
declare type Not<T extends boolean> = T extends true ? false : true;
|
||||
/**
|
||||
* Union of the sets' values' types
|
||||
*/
|
||||
declare type UnionSetValues<Ts extends ReadonlyArray<unknown>> = UnionSetValuesHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for UnionSetValues.
|
||||
*/
|
||||
declare type UnionSetValuesHelper<Ts extends ReadonlyArray<unknown>, Acc> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Readonly<ReadonlySet<infer V1>> ? Rest extends ReadonlyArray<unknown> ? UnionSetValuesHelper<Rest, Acc | V1> : Acc | V1 : never : Acc;
|
||||
/**
|
||||
* Union of the maps' values' types
|
||||
*/
|
||||
declare type UnionMapKeys<Ts extends ReadonlyArray<unknown>> = UnionMapKeysHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for UnionMapKeys.
|
||||
*/
|
||||
declare type UnionMapKeysHelper<Ts extends ReadonlyArray<unknown>, Acc> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Readonly<ReadonlyMap<infer K1, unknown>> ? Rest extends readonly [] ? Acc | K1 : UnionMapKeysHelper<Rest, Acc | K1> : never : Acc;
|
||||
/**
|
||||
* Union of the maps' keys' types
|
||||
*/
|
||||
declare type UnionMapValues<Ts extends ReadonlyArray<unknown>> = UnionMapValuesHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for UnionMapValues.
|
||||
*/
|
||||
declare type UnionMapValuesHelper<Ts extends ReadonlyArray<unknown>, Acc> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Readonly<ReadonlyMap<unknown, infer V1>> ? Rest extends readonly [] ? Acc | V1 : UnionMapValuesHelper<Rest, Acc | V1> : never : Acc;
|
||||
/**
|
||||
* Get the keys of the type what match a certain criteria.
|
||||
*/
|
||||
declare type KeysOfType<T, U> = {
|
||||
[K in keyof T]: T[K] extends U ? K : never;
|
||||
}[keyof T];
|
||||
/**
|
||||
* Get the required keys of the type.
|
||||
*/
|
||||
declare type RequiredKeys<T> = Exclude<KeysOfType<T, Exclude<T[keyof T], undefined>>, undefined>;
|
||||
/**
|
||||
* Get all the required keys on the types in the tuple.
|
||||
*/
|
||||
declare type RequiredKeysOf<Ts extends readonly [unknown, ...ReadonlyArray<unknown>]> = RequiredKeysOfHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for RequiredKeysOf.
|
||||
*/
|
||||
declare type RequiredKeysOfHelper<Ts extends readonly [unknown, ...ReadonlyArray<unknown>], Acc> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Record<PropertyKey, unknown> ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? RequiredKeysOfHelper<Rest, Acc | RequiredKeys<Head>> : Acc | RequiredKeys<Head> : never : Acc;
|
||||
/**
|
||||
* Get the optional keys of the type.
|
||||
*/
|
||||
declare type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>;
|
||||
/**
|
||||
* Get all the optional keys on the types in the tuple.
|
||||
*/
|
||||
declare type OptionalKeysOf<Ts extends readonly [unknown, ...ReadonlyArray<unknown>]> = OptionalKeysOfHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for OptionalKeysOf.
|
||||
*/
|
||||
declare type OptionalKeysOfHelper<Ts extends readonly [unknown, ...ReadonlyArray<unknown>], Acc> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Record<PropertyKey, unknown> ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? OptionalKeysOfHelper<Rest, Acc | OptionalKeys<Head>> : Acc | OptionalKeys<Head> : never : Acc;
|
||||
/**
|
||||
* Filter out nevers from a tuple.
|
||||
*/
|
||||
declare type FilterOutNever<T extends ReadonlyArray<unknown>> = FilterOutNeverHelper<T, []>;
|
||||
/**
|
||||
* Tail-recursive helper type for FilterOutNever.
|
||||
*/
|
||||
declare type FilterOutNeverHelper<T extends ReadonlyArray<unknown>, Acc extends ReadonlyArray<unknown>> = T extends readonly [] ? Acc : T extends readonly [infer Head, ...infer Rest] ? IsNever<Head> extends true ? FilterOutNeverHelper<Rest, Acc> : FilterOutNeverHelper<Rest, [...Acc, Head]> : T;
|
||||
/**
|
||||
* Is the type a tuple?
|
||||
*/
|
||||
declare type IsTuple<T extends ReadonlyArray<unknown>> = T extends readonly [] ? true : T extends readonly [unknown, ...ReadonlyArray<unknown>] ? true : false;
|
||||
|
||||
/**
|
||||
* Mapping of merge function URIs to the merge function type.
|
||||
*/
|
||||
interface DeepMergeMergeFunctionURItoKind<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> {
|
||||
readonly DeepMergeLeafURI: DeepMergeLeaf<Ts>;
|
||||
readonly DeepMergeRecordsDefaultURI: DeepMergeRecordsDefaultHKT<Ts, MF, M>;
|
||||
readonly DeepMergeArraysDefaultURI: DeepMergeArraysDefaultHKT<Ts, MF, M>;
|
||||
readonly DeepMergeSetsDefaultURI: DeepMergeSetsDefaultHKT<Ts>;
|
||||
readonly DeepMergeMapsDefaultURI: DeepMergeMapsDefaultHKT<Ts>;
|
||||
}
|
||||
/**
|
||||
* Get the type of the given merge function via its URI.
|
||||
*/
|
||||
declare type DeepMergeMergeFunctionKind<URI extends DeepMergeMergeFunctionURIs, Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionURItoKind<Ts, MF, M>[URI];
|
||||
/**
|
||||
* A union of all valid merge function URIs.
|
||||
*/
|
||||
declare type DeepMergeMergeFunctionURIs = keyof DeepMergeMergeFunctionURItoKind<ReadonlyArray<unknown>, DeepMergeMergeFunctionsURIs, unknown>;
|
||||
/**
|
||||
* The merge functions to use when deep merging.
|
||||
*/
|
||||
declare type DeepMergeMergeFunctionsURIs = Readonly<{
|
||||
/**
|
||||
* The merge function to merge records with.
|
||||
*/
|
||||
DeepMergeRecordsURI: DeepMergeMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge arrays with.
|
||||
*/
|
||||
DeepMergeArraysURI: DeepMergeMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge sets with.
|
||||
*/
|
||||
DeepMergeSetsURI: DeepMergeMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge maps with.
|
||||
*/
|
||||
DeepMergeMapsURI: DeepMergeMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge other things with.
|
||||
*/
|
||||
DeepMergeOthersURI: DeepMergeMergeFunctionURIs;
|
||||
}>;
|
||||
/**
|
||||
* Deep merge types.
|
||||
*/
|
||||
declare type DeepMergeHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = IsTuple<Ts> extends true ? Ts extends readonly [] ? undefined : Ts extends readonly [infer T1] ? T1 : EveryIsArray<Ts> extends true ? DeepMergeArraysHKT<Ts, MF, M> : EveryIsMap<Ts> extends true ? DeepMergeMapsHKT<Ts, MF, M> : EveryIsSet<Ts> extends true ? DeepMergeSetsHKT<Ts, MF, M> : EveryIsRecord<Ts> extends true ? DeepMergeRecordsHKT<Ts, MF, M> : DeepMergeOthersHKT<Ts, MF, M> : unknown;
|
||||
/**
|
||||
* Deep merge records.
|
||||
*/
|
||||
declare type DeepMergeRecordsHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionKind<MF["DeepMergeRecordsURI"], Ts, MF, M>;
|
||||
/**
|
||||
* Deep merge arrays.
|
||||
*/
|
||||
declare type DeepMergeArraysHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionKind<MF["DeepMergeArraysURI"], Ts, MF, M>;
|
||||
/**
|
||||
* Deep merge sets.
|
||||
*/
|
||||
declare type DeepMergeSetsHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionKind<MF["DeepMergeSetsURI"], Ts, MF, M>;
|
||||
/**
|
||||
* Deep merge maps.
|
||||
*/
|
||||
declare type DeepMergeMapsHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionKind<MF["DeepMergeMapsURI"], Ts, MF, M>;
|
||||
/**
|
||||
* Deep merge other things.
|
||||
*/
|
||||
declare type DeepMergeOthersHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeMergeFunctionKind<MF["DeepMergeOthersURI"], Ts, MF, M>;
|
||||
/**
|
||||
* The merge function that returns a leaf.
|
||||
*/
|
||||
declare type DeepMergeLeafURI = "DeepMergeLeafURI";
|
||||
/**
|
||||
* Get the leaf type from many types that can't be merged.
|
||||
*
|
||||
* @deprecated Use `DeepMergeLeaf` instead.
|
||||
*/
|
||||
declare type DeepMergeLeafHKT<Ts extends ReadonlyArray<unknown>> = DeepMergeLeaf<Ts>;
|
||||
/**
|
||||
* Get the leaf type from many types that can't be merged.
|
||||
*/
|
||||
declare type DeepMergeLeaf<Ts extends ReadonlyArray<unknown>> = Ts extends readonly [] ? never : Ts extends readonly [infer T] ? T : Ts extends readonly [...infer Rest, infer Tail] ? IsNever<Tail> extends true ? Rest extends ReadonlyArray<unknown> ? DeepMergeLeaf<Rest> : never : Tail : never;
|
||||
/**
|
||||
* The meta data deepmerge is able to provide.
|
||||
*/
|
||||
declare type DeepMergeBuiltInMetaData = Readonly<{
|
||||
key: PropertyKey;
|
||||
parents: ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* The default merge function to merge records with.
|
||||
*/
|
||||
declare type DeepMergeRecordsDefaultURI = "DeepMergeRecordsDefaultURI";
|
||||
/**
|
||||
* The default merge function to merge arrays with.
|
||||
*/
|
||||
declare type DeepMergeArraysDefaultURI = "DeepMergeArraysDefaultURI";
|
||||
/**
|
||||
* The default merge function to merge sets with.
|
||||
*/
|
||||
declare type DeepMergeSetsDefaultURI = "DeepMergeSetsDefaultURI";
|
||||
/**
|
||||
* The default merge function to merge maps with.
|
||||
*/
|
||||
declare type DeepMergeMapsDefaultURI = "DeepMergeMapsDefaultURI";
|
||||
/**
|
||||
* The default merge functions to use when deep merging.
|
||||
*/
|
||||
declare type DeepMergeMergeFunctionsDefaultURIs = Readonly<{
|
||||
DeepMergeRecordsURI: DeepMergeRecordsDefaultURI;
|
||||
DeepMergeArraysURI: DeepMergeArraysDefaultURI;
|
||||
DeepMergeSetsURI: DeepMergeSetsDefaultURI;
|
||||
DeepMergeMapsURI: DeepMergeMapsDefaultURI;
|
||||
DeepMergeOthersURI: DeepMergeLeafURI;
|
||||
}>;
|
||||
/**
|
||||
* A union of all the props that should not be included in type information for
|
||||
* merged records.
|
||||
*/
|
||||
declare type BlacklistedRecordProps = "__proto__";
|
||||
/**
|
||||
* Deep merge records.
|
||||
*/
|
||||
declare type DeepMergeRecordsDefaultHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = Ts extends Readonly<readonly [unknown, ...Readonly<ReadonlyArray<unknown>>]> ? FlatternAlias<Omit<DeepMergeRecordsDefaultHKTInternalProps<Ts, MF, M>, BlacklistedRecordProps>> : {};
|
||||
/**
|
||||
* Deep merge record props.
|
||||
*/
|
||||
declare type DeepMergeRecordsDefaultHKTInternalProps<Ts extends readonly [unknown, ...ReadonlyArray<unknown>], MF extends DeepMergeMergeFunctionsURIs, M> = {
|
||||
[K in OptionalKeysOf<Ts>]?: DeepMergeHKT<DeepMergeRecordsDefaultHKTInternalPropValue<Ts, K, M>, MF, M>;
|
||||
} & {
|
||||
[K in RequiredKeysOf<Ts>]: DeepMergeHKT<DeepMergeRecordsDefaultHKTInternalPropValue<Ts, K, M>, MF, M>;
|
||||
};
|
||||
/**
|
||||
* Get the value of the property.
|
||||
*/
|
||||
declare type DeepMergeRecordsDefaultHKTInternalPropValue<Ts extends readonly [unknown, ...ReadonlyArray<unknown>], K extends PropertyKey, M> = FilterOutNever<DeepMergeRecordsDefaultHKTInternalPropValueHelper<Ts, K, M, readonly []>>;
|
||||
/**
|
||||
* Tail-recursive helper type for DeepMergeRecordsDefaultHKTInternalPropValue.
|
||||
*/
|
||||
declare type DeepMergeRecordsDefaultHKTInternalPropValueHelper<Ts extends readonly [unknown, ...ReadonlyArray<unknown>], K extends PropertyKey, M, Acc extends ReadonlyArray<unknown>> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends Readonly<Record<PropertyKey, unknown>> ? Rest extends readonly [unknown, ...ReadonlyArray<unknown>] ? DeepMergeRecordsDefaultHKTInternalPropValueHelper<Rest, K, M, [
|
||||
...Acc,
|
||||
ValueOfKey<Head, K>
|
||||
]> : [...Acc, ValueOfKey<Head, K>] : never : never;
|
||||
/**
|
||||
* Deep merge 2 arrays.
|
||||
*/
|
||||
declare type DeepMergeArraysDefaultHKT<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M> = DeepMergeArraysDefaultHKTHelper<Ts, MF, M, []>;
|
||||
/**
|
||||
* Tail-recursive helper type for DeepMergeArraysDefaultHKT.
|
||||
*/
|
||||
declare type DeepMergeArraysDefaultHKTHelper<Ts extends ReadonlyArray<unknown>, MF extends DeepMergeMergeFunctionsURIs, M, Acc extends ReadonlyArray<unknown>> = Ts extends readonly [infer Head, ...infer Rest] ? Head extends ReadonlyArray<unknown> ? Rest extends readonly [
|
||||
ReadonlyArray<unknown>,
|
||||
...ReadonlyArray<ReadonlyArray<unknown>>
|
||||
] ? DeepMergeArraysDefaultHKTHelper<Rest, MF, M, [...Acc, ...Head]> : [...Acc, ...Head] : never : never;
|
||||
/**
|
||||
* Deep merge 2 sets.
|
||||
*/
|
||||
declare type DeepMergeSetsDefaultHKT<Ts extends ReadonlyArray<unknown>> = Set<UnionSetValues<Ts>>;
|
||||
/**
|
||||
* Deep merge 2 maps.
|
||||
*/
|
||||
declare type DeepMergeMapsDefaultHKT<Ts extends ReadonlyArray<unknown>> = Map<UnionMapKeys<Ts>, UnionMapValues<Ts>>;
|
||||
/**
|
||||
* Get the merge functions with defaults apply from the given subset.
|
||||
*/
|
||||
declare type GetDeepMergeMergeFunctionsURIs<PMF extends Partial<DeepMergeMergeFunctionsURIs>> = Readonly<{
|
||||
DeepMergeRecordsURI: PMF["DeepMergeRecordsURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeRecordsURI"] : DeepMergeRecordsDefaultURI;
|
||||
DeepMergeArraysURI: PMF["DeepMergeArraysURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeArraysURI"] : DeepMergeArraysDefaultURI;
|
||||
DeepMergeSetsURI: PMF["DeepMergeSetsURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeSetsURI"] : DeepMergeSetsDefaultURI;
|
||||
DeepMergeMapsURI: PMF["DeepMergeMapsURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeMapsURI"] : DeepMergeMapsDefaultURI;
|
||||
DeepMergeOthersURI: PMF["DeepMergeOthersURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeOthersURI"] : DeepMergeLeafURI;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* The options the user can pass to customize deepmerge.
|
||||
*/
|
||||
declare type DeepMergeOptions<M, MM extends Readonly<Record<PropertyKey, unknown>> = DeepMergeBuiltInMetaData> = Partial<DeepMergeOptionsFull<M, MM & DeepMergeBuiltInMetaData>>;
|
||||
declare type MetaDataUpdater<M, MM extends DeepMergeBuiltInMetaData> = (previousMeta: M | undefined, metaMeta: Readonly<Partial<MM>>) => M;
|
||||
/**
|
||||
* All the options the user can pass to customize deepmerge.
|
||||
*/
|
||||
declare type DeepMergeOptionsFull<M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: DeepMergeMergeFunctions<M, MM>["mergeRecords"] | false;
|
||||
mergeArrays: DeepMergeMergeFunctions<M, MM>["mergeArrays"] | false;
|
||||
mergeMaps: DeepMergeMergeFunctions<M, MM>["mergeMaps"] | false;
|
||||
mergeSets: DeepMergeMergeFunctions<M, MM>["mergeSets"] | false;
|
||||
mergeOthers: DeepMergeMergeFunctions<M, MM>["mergeOthers"];
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
enableImplicitDefaultMerging: boolean;
|
||||
}>;
|
||||
/**
|
||||
* All the merge functions that deepmerge uses.
|
||||
*/
|
||||
declare type DeepMergeMergeFunctions<M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: <Ts extends ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>, U extends DeepMergeMergeFunctionUtils<M, MM>>(records: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeArrays: <Ts extends ReadonlyArray<ReadonlyArray<unknown>>, U extends DeepMergeMergeFunctionUtils<M, MM>>(records: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeMaps: <Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>, U extends DeepMergeMergeFunctionUtils<M, MM>>(records: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeSets: <Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>, U extends DeepMergeMergeFunctionUtils<M, MM>>(records: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeOthers: <Ts extends ReadonlyArray<unknown>, U extends DeepMergeMergeFunctionUtils<M, MM>>(records: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
}>;
|
||||
/**
|
||||
* The utils provided to the merge functions.
|
||||
*/
|
||||
declare type DeepMergeMergeFunctionUtils<M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeFunctions: DeepMergeMergeFunctions<M, MM>;
|
||||
defaultMergeFunctions: DeepMergeMergeFunctionsDefaults;
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
deepmerge: <Ts extends ReadonlyArray<unknown>>(...values: Ts) => unknown;
|
||||
useImplicitDefaultMerging: boolean;
|
||||
actions: Readonly<{
|
||||
defaultMerge: symbol;
|
||||
skip: symbol;
|
||||
}>;
|
||||
}>;
|
||||
|
||||
declare const defaultMergeFunctions: {
|
||||
readonly mergeMaps: typeof defaultMergeMaps;
|
||||
readonly mergeSets: typeof defaultMergeSets;
|
||||
readonly mergeArrays: typeof defaultMergeArrays;
|
||||
readonly mergeRecords: typeof defaultMergeRecords;
|
||||
readonly mergeOthers: typeof leaf;
|
||||
};
|
||||
/**
|
||||
* The default merge functions.
|
||||
*/
|
||||
declare type DeepMergeMergeFunctionsDefaults = typeof defaultMergeFunctions;
|
||||
/**
|
||||
* Deeply merge objects.
|
||||
*
|
||||
* @param objects - The objects to merge.
|
||||
*/
|
||||
declare function deepmerge<Ts extends Readonly<ReadonlyArray<unknown>>>(...objects: readonly [...Ts]): DeepMergeHKT<Ts, DeepMergeMergeFunctionsDefaultURIs, DeepMergeBuiltInMetaData>;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
*/
|
||||
declare function deepmergeCustom<PMF extends Partial<DeepMergeMergeFunctionsURIs>>(options: DeepMergeOptions<DeepMergeBuiltInMetaData, DeepMergeBuiltInMetaData>): <Ts extends ReadonlyArray<unknown>>(...objects: Ts) => DeepMergeHKT<Ts, GetDeepMergeMergeFunctionsURIs<PMF>, DeepMergeBuiltInMetaData>;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options and meta data.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
* @param rootMetaData - The meta data passed to the root items' being merged.
|
||||
*/
|
||||
declare function deepmergeCustom<PMF extends Partial<DeepMergeMergeFunctionsURIs>, MetaData, MetaMetaData extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(options: DeepMergeOptions<MetaData, MetaMetaData>, rootMetaData?: MetaData): <Ts extends ReadonlyArray<unknown>>(...objects: Ts) => DeepMergeHKT<Ts, GetDeepMergeMergeFunctionsURIs<PMF>, MetaData>;
|
||||
/**
|
||||
* The default strategy to merge records.
|
||||
*
|
||||
* @param values - The records.
|
||||
*/
|
||||
declare function defaultMergeRecords<Ts extends ReadonlyArray<Record<PropertyKey, unknown>>, U extends DeepMergeMergeFunctionUtils<M, MM>, MF extends DeepMergeMergeFunctionsURIs, M, MM extends DeepMergeBuiltInMetaData>(values: Ts, utils: U, meta: M | undefined): DeepMergeRecordsDefaultHKT<Ts, MF, M>;
|
||||
/**
|
||||
* The default strategy to merge arrays.
|
||||
*
|
||||
* @param values - The arrays.
|
||||
*/
|
||||
declare function defaultMergeArrays<Ts extends ReadonlyArray<ReadonlyArray<unknown>>, MF extends DeepMergeMergeFunctionsURIs, M>(values: Ts): DeepMergeArraysDefaultHKT<Ts, MF, M>;
|
||||
/**
|
||||
* The default strategy to merge sets.
|
||||
*
|
||||
* @param values - The sets.
|
||||
*/
|
||||
declare function defaultMergeSets<Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>>(values: Ts): DeepMergeSetsDefaultHKT<Ts>;
|
||||
/**
|
||||
* The default strategy to merge maps.
|
||||
*
|
||||
* @param values - The maps.
|
||||
*/
|
||||
declare function defaultMergeMaps<Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>>(values: Ts): DeepMergeMapsDefaultHKT<Ts>;
|
||||
/**
|
||||
* Get the last value in the given array.
|
||||
*/
|
||||
declare function leaf<Ts extends ReadonlyArray<unknown>>(values: Ts): unknown;
|
||||
|
||||
export { DeepMergeArraysDefaultHKT, DeepMergeBuiltInMetaData, DeepMergeHKT, DeepMergeLeaf, DeepMergeLeafHKT, DeepMergeLeafURI, DeepMergeMapsDefaultHKT, DeepMergeMergeFunctionURItoKind, DeepMergeMergeFunctionUtils, DeepMergeMergeFunctionsDefaultURIs, DeepMergeMergeFunctionsDefaults, DeepMergeMergeFunctionsURIs, DeepMergeOptions, DeepMergeRecordsDefaultHKT, DeepMergeSetsDefaultHKT, deepmerge, deepmergeCustom };
|
||||
Loading…
Add table
Add a link
Reference in a new issue