Add settings page for managing forecasting API key and URL via UI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-20 14:37:36 +00:00
parent cae411eae7
commit 1c411e402e
19809 changed files with 1962608 additions and 97 deletions

View file

@ -0,0 +1,25 @@
import { ConformsPredicateObject } from "../_internal/ConformsPredicateObject.mjs";
//#region src/compat/predicate/conforms.d.ts
/**
* Creates a function that invokes the predicate properties of `source` with the corresponding property values of a given object, returning `true` if all predicates return truthy, else `false`.
*
* Note: The created function is equivalent to `conformsTo` with source partially applied.
*
* @param source The object of property predicates to conform to.
* @returns Returns the new spec function.
*
* @example
* const isPositive = (n) => n > 0;
* const isEven = (n) => n % 2 === 0;
* const predicates = { a: isPositive, b: isEven };
* const conform = conforms(predicates);
*
* console.log(conform({ a: 2, b: 4 })); // true
* console.log(conform({ a: -1, b: 4 })); // false
* console.log(conform({ a: 2, b: 3 })); // false
* console.log(conform({ a: 0, b: 2 })); // false
*/
declare function conforms<T>(source: ConformsPredicateObject<T>): (value: T) => boolean;
//#endregion
export { conforms };

View file

@ -0,0 +1,25 @@
import { ConformsPredicateObject } from "../_internal/ConformsPredicateObject.js";
//#region src/compat/predicate/conforms.d.ts
/**
* Creates a function that invokes the predicate properties of `source` with the corresponding property values of a given object, returning `true` if all predicates return truthy, else `false`.
*
* Note: The created function is equivalent to `conformsTo` with source partially applied.
*
* @param source The object of property predicates to conform to.
* @returns Returns the new spec function.
*
* @example
* const isPositive = (n) => n > 0;
* const isEven = (n) => n % 2 === 0;
* const predicates = { a: isPositive, b: isEven };
* const conform = conforms(predicates);
*
* console.log(conform({ a: 2, b: 4 })); // true
* console.log(conform({ a: -1, b: 4 })); // false
* console.log(conform({ a: 2, b: 3 })); // false
* console.log(conform({ a: 0, b: 2 })); // false
*/
declare function conforms<T>(source: ConformsPredicateObject<T>): (value: T) => boolean;
//#endregion
export { conforms };

View file

@ -0,0 +1,30 @@
const require_cloneDeep = require("../../object/cloneDeep.js");
const require_conformsTo = require("./conformsTo.js");
//#region src/compat/predicate/conforms.ts
/**
* Creates a function that invokes the predicate properties of `source` with the corresponding property values of a given object, returning `true` if all predicates return truthy, else `false`.
*
* Note: The created function is equivalent to `conformsTo` with source partially applied.
*
* @param source The object of property predicates to conform to.
* @returns Returns the new spec function.
*
* @example
* const isPositive = (n) => n > 0;
* const isEven = (n) => n % 2 === 0;
* const predicates = { a: isPositive, b: isEven };
* const conform = conforms(predicates);
*
* console.log(conform({ a: 2, b: 4 })); // true
* console.log(conform({ a: -1, b: 4 })); // false
* console.log(conform({ a: 2, b: 3 })); // false
* console.log(conform({ a: 0, b: 2 })); // false
*/
function conforms(source) {
source = require_cloneDeep.cloneDeep(source);
return function(object) {
return require_conformsTo.conformsTo(object, source);
};
}
//#endregion
exports.conforms = conforms;

View file

@ -0,0 +1,30 @@
import { cloneDeep } from "../../object/cloneDeep.mjs";
import { conformsTo } from "./conformsTo.mjs";
//#region src/compat/predicate/conforms.ts
/**
* Creates a function that invokes the predicate properties of `source` with the corresponding property values of a given object, returning `true` if all predicates return truthy, else `false`.
*
* Note: The created function is equivalent to `conformsTo` with source partially applied.
*
* @param source The object of property predicates to conform to.
* @returns Returns the new spec function.
*
* @example
* const isPositive = (n) => n > 0;
* const isEven = (n) => n % 2 === 0;
* const predicates = { a: isPositive, b: isEven };
* const conform = conforms(predicates);
*
* console.log(conform({ a: 2, b: 4 })); // true
* console.log(conform({ a: -1, b: 4 })); // false
* console.log(conform({ a: 2, b: 3 })); // false
* console.log(conform({ a: 0, b: 2 })); // false
*/
function conforms(source) {
source = cloneDeep(source);
return function(object) {
return conformsTo(object, source);
};
}
//#endregion
export { conforms };

View file

@ -0,0 +1,33 @@
import { ConformsPredicateObject } from "../_internal/ConformsPredicateObject.mjs";
//#region src/compat/predicate/conformsTo.d.ts
/**
* Checks if `object` conforms to `source` by invoking the predicate properties of `source` with the corresponding property values of `object`.
*
* Note: This method is equivalent to `conforms` when source is partially applied.
*
* @template T - The type of the target object.
* @param target The object to inspect.
* @param source The object of property predicates to conform to.
* @returns Returns `true` if `object` conforms, else `false`.
*
* @example
*
* const object = { 'a': 1, 'b': 2 };
* const source = {
* 'a': (n) => n > 0,
* 'b': (n) => n > 1
* };
*
* console.log(conformsTo(object, source)); // => true
*
* const source2 = {
* 'a': (n) => n > 1,
* 'b': (n) => n > 1
* };
*
* console.log(conformsTo(object, source2)); // => false
*/
declare function conformsTo<T>(target: T, source: ConformsPredicateObject<T>): boolean;
//#endregion
export { conformsTo };

View file

@ -0,0 +1,33 @@
import { ConformsPredicateObject } from "../_internal/ConformsPredicateObject.js";
//#region src/compat/predicate/conformsTo.d.ts
/**
* Checks if `object` conforms to `source` by invoking the predicate properties of `source` with the corresponding property values of `object`.
*
* Note: This method is equivalent to `conforms` when source is partially applied.
*
* @template T - The type of the target object.
* @param target The object to inspect.
* @param source The object of property predicates to conform to.
* @returns Returns `true` if `object` conforms, else `false`.
*
* @example
*
* const object = { 'a': 1, 'b': 2 };
* const source = {
* 'a': (n) => n > 0,
* 'b': (n) => n > 1
* };
*
* console.log(conformsTo(object, source)); // => true
*
* const source2 = {
* 'a': (n) => n > 1,
* 'b': (n) => n > 1
* };
*
* console.log(conformsTo(object, source2)); // => false
*/
declare function conformsTo<T>(target: T, source: ConformsPredicateObject<T>): boolean;
//#endregion
export { conformsTo };

View file

@ -0,0 +1,43 @@
//#region src/compat/predicate/conformsTo.ts
/**
* Checks if `object` conforms to `source` by invoking the predicate properties of `source` with the corresponding property values of `object`.
*
* Note: This method is equivalent to `conforms` when source is partially applied.
*
* @template T - The type of the target object.
* @param target The object to inspect.
* @param source The object of property predicates to conform to.
* @returns Returns `true` if `object` conforms, else `false`.
*
* @example
*
* const object = { 'a': 1, 'b': 2 };
* const source = {
* 'a': (n) => n > 0,
* 'b': (n) => n > 1
* };
*
* console.log(conformsTo(object, source)); // => true
*
* const source2 = {
* 'a': (n) => n > 1,
* 'b': (n) => n > 1
* };
*
* console.log(conformsTo(object, source2)); // => false
*/
function conformsTo(target, source) {
if (source == null) return true;
if (target == null) return Object.keys(source).length === 0;
const keys = Object.keys(source);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const predicate = source[key];
const value = target[key];
if (value === void 0 && !(key in target)) return false;
if (typeof predicate === "function" && !predicate(value)) return false;
}
return true;
}
//#endregion
exports.conformsTo = conformsTo;

View file

@ -0,0 +1,43 @@
//#region src/compat/predicate/conformsTo.ts
/**
* Checks if `object` conforms to `source` by invoking the predicate properties of `source` with the corresponding property values of `object`.
*
* Note: This method is equivalent to `conforms` when source is partially applied.
*
* @template T - The type of the target object.
* @param target The object to inspect.
* @param source The object of property predicates to conform to.
* @returns Returns `true` if `object` conforms, else `false`.
*
* @example
*
* const object = { 'a': 1, 'b': 2 };
* const source = {
* 'a': (n) => n > 0,
* 'b': (n) => n > 1
* };
*
* console.log(conformsTo(object, source)); // => true
*
* const source2 = {
* 'a': (n) => n > 1,
* 'b': (n) => n > 1
* };
*
* console.log(conformsTo(object, source2)); // => false
*/
function conformsTo(target, source) {
if (source == null) return true;
if (target == null) return Object.keys(source).length === 0;
const keys = Object.keys(source);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const predicate = source[key];
const value = target[key];
if (value === void 0 && !(key in target)) return false;
if (typeof predicate === "function" && !predicate(value)) return false;
}
return true;
}
//#endregion
export { conformsTo };

View file

@ -0,0 +1,24 @@
//#region src/compat/predicate/isArguments.d.ts
/**
* Checks if the given value is an arguments object.
*
* This function tests whether the provided value is an arguments object or not.
* It returns `true` if the value is an arguments object, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an arguments object.
*
* @param value - The value to test if it is an arguments object.
* @returns `true` if the value is an arguments, `false` otherwise.
*
* @example
* const args = (function() { return arguments; })();
* const strictArgs = (function() { 'use strict'; return arguments; })();
* const value = [1, 2, 3];
*
* console.log(isArguments(args)); // true
* console.log(isArguments(strictArgs)); // true
* console.log(isArguments(value)); // false
*/
declare function isArguments(value?: any): value is IArguments;
//#endregion
export { isArguments };

View file

@ -0,0 +1,24 @@
//#region src/compat/predicate/isArguments.d.ts
/**
* Checks if the given value is an arguments object.
*
* This function tests whether the provided value is an arguments object or not.
* It returns `true` if the value is an arguments object, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an arguments object.
*
* @param value - The value to test if it is an arguments object.
* @returns `true` if the value is an arguments, `false` otherwise.
*
* @example
* const args = (function() { return arguments; })();
* const strictArgs = (function() { 'use strict'; return arguments; })();
* const value = [1, 2, 3];
*
* console.log(isArguments(args)); // true
* console.log(isArguments(strictArgs)); // true
* console.log(isArguments(value)); // false
*/
declare function isArguments(value?: any): value is IArguments;
//#endregion
export { isArguments };

View file

@ -0,0 +1,27 @@
const require_getTag = require("../_internal/getTag.js");
//#region src/compat/predicate/isArguments.ts
/**
* Checks if the given value is an arguments object.
*
* This function tests whether the provided value is an arguments object or not.
* It returns `true` if the value is an arguments object, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an arguments object.
*
* @param value - The value to test if it is an arguments object.
* @returns `true` if the value is an arguments, `false` otherwise.
*
* @example
* const args = (function() { return arguments; })();
* const strictArgs = (function() { 'use strict'; return arguments; })();
* const value = [1, 2, 3];
*
* console.log(isArguments(args)); // true
* console.log(isArguments(strictArgs)); // true
* console.log(isArguments(value)); // false
*/
function isArguments(value) {
return value !== null && typeof value === "object" && require_getTag.getTag(value) === "[object Arguments]";
}
//#endregion
exports.isArguments = isArguments;

View file

@ -0,0 +1,27 @@
import { getTag } from "../_internal/getTag.mjs";
//#region src/compat/predicate/isArguments.ts
/**
* Checks if the given value is an arguments object.
*
* This function tests whether the provided value is an arguments object or not.
* It returns `true` if the value is an arguments object, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an arguments object.
*
* @param value - The value to test if it is an arguments object.
* @returns `true` if the value is an arguments, `false` otherwise.
*
* @example
* const args = (function() { return arguments; })();
* const strictArgs = (function() { 'use strict'; return arguments; })();
* const value = [1, 2, 3];
*
* console.log(isArguments(args)); // true
* console.log(isArguments(strictArgs)); // true
* console.log(isArguments(value)); // false
*/
function isArguments(value) {
return value !== null && typeof value === "object" && getTag(value) === "[object Arguments]";
}
//#endregion
export { isArguments };

View file

@ -0,0 +1,46 @@
//#region src/compat/predicate/isArray.d.ts
/**
* Checks if the given value is an array.
*
* This function tests whether the provided value is an array or not.
* It returns `true` if the value is an array, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an array.
*
* @param value - The value to test if it is an array.
* @returns `true` if the value is an array, `false` otherwise.
*
* @example
* const value1 = [1, 2, 3];
* const value2 = 'abc';
* const value3 = () => {};
*
* console.log(isArray(value1)); // true
* console.log(isArray(value2)); // false
* console.log(isArray(value3)); // false
*/
declare function isArray(value?: any): value is any[];
/**
* Checks if the given value is an array with generic type support.
*
* This function tests whether the provided value is an array or not.
* It returns `true` if the value is an array, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an array.
*
* @template T - The type of elements in the array.
* @param value - The value to test if it is an array.
* @returns `true` if the value is an array, `false` otherwise.
*
* @example
* const value1 = [1, 2, 3];
* const value2 = 'abc';
* const value3 = () => {};
*
* console.log(isArray<number>(value1)); // true
* console.log(isArray<string>(value2)); // false
* console.log(isArray<Function>(value3)); // false
*/
declare function isArray<T>(value?: any): value is any[];
//#endregion
export { isArray };

View file

@ -0,0 +1,46 @@
//#region src/compat/predicate/isArray.d.ts
/**
* Checks if the given value is an array.
*
* This function tests whether the provided value is an array or not.
* It returns `true` if the value is an array, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an array.
*
* @param value - The value to test if it is an array.
* @returns `true` if the value is an array, `false` otherwise.
*
* @example
* const value1 = [1, 2, 3];
* const value2 = 'abc';
* const value3 = () => {};
*
* console.log(isArray(value1)); // true
* console.log(isArray(value2)); // false
* console.log(isArray(value3)); // false
*/
declare function isArray(value?: any): value is any[];
/**
* Checks if the given value is an array with generic type support.
*
* This function tests whether the provided value is an array or not.
* It returns `true` if the value is an array, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an array.
*
* @template T - The type of elements in the array.
* @param value - The value to test if it is an array.
* @returns `true` if the value is an array, `false` otherwise.
*
* @example
* const value1 = [1, 2, 3];
* const value2 = 'abc';
* const value3 = () => {};
*
* console.log(isArray<number>(value1)); // true
* console.log(isArray<string>(value2)); // false
* console.log(isArray<Function>(value3)); // false
*/
declare function isArray<T>(value?: any): value is any[];
//#endregion
export { isArray };

View file

@ -0,0 +1,26 @@
//#region src/compat/predicate/isArray.ts
/**
* Checks if the given value is an array.
*
* This function tests whether the provided value is an array or not.
* It returns `true` if the value is an array, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an array.
*
* @param value - The value to test if it is an array.
* @returns `true` if the value is an array, `false` otherwise.
*
* @example
* const value1 = [1, 2, 3];
* const value2 = 'abc';
* const value3 = () => {};
*
* console.log(isArray(value1)); // true
* console.log(isArray(value2)); // false
* console.log(isArray(value3)); // false
*/
function isArray(value) {
return Array.isArray(value);
}
//#endregion
exports.isArray = isArray;

View file

@ -0,0 +1,26 @@
//#region src/compat/predicate/isArray.ts
/**
* Checks if the given value is an array.
*
* This function tests whether the provided value is an array or not.
* It returns `true` if the value is an array, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an array.
*
* @param value - The value to test if it is an array.
* @returns `true` if the value is an array, `false` otherwise.
*
* @example
* const value1 = [1, 2, 3];
* const value2 = 'abc';
* const value3 = () => {};
*
* console.log(isArray(value1)); // true
* console.log(isArray(value2)); // false
* console.log(isArray(value3)); // false
*/
function isArray(value) {
return Array.isArray(value);
}
//#endregion
export { isArray };

View file

@ -0,0 +1,21 @@
//#region src/compat/predicate/isArrayBuffer.d.ts
/**
* Checks if a given value is `ArrayBuffer`.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `ArrayBuffer`.
*
* @param value The value to check if it is a `ArrayBuffer`.
* @returns Returns `true` if `value` is a `ArrayBuffer`, else `false`.
*
* @example
* const value1 = new ArrayBuffer();
* const value2 = new Array();
* const value3 = new Map();
*
* console.log(isArrayBuffer(value1)); // true
* console.log(isArrayBuffer(value2)); // false
* console.log(isArrayBuffer(value3)); // false
*/
declare function isArrayBuffer(value?: any): value is ArrayBuffer;
//#endregion
export { isArrayBuffer };

View file

@ -0,0 +1,21 @@
//#region src/compat/predicate/isArrayBuffer.d.ts
/**
* Checks if a given value is `ArrayBuffer`.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `ArrayBuffer`.
*
* @param value The value to check if it is a `ArrayBuffer`.
* @returns Returns `true` if `value` is a `ArrayBuffer`, else `false`.
*
* @example
* const value1 = new ArrayBuffer();
* const value2 = new Array();
* const value3 = new Map();
*
* console.log(isArrayBuffer(value1)); // true
* console.log(isArrayBuffer(value2)); // false
* console.log(isArrayBuffer(value3)); // false
*/
declare function isArrayBuffer(value?: any): value is ArrayBuffer;
//#endregion
export { isArrayBuffer };

View file

@ -0,0 +1,24 @@
const require_isArrayBuffer = require("../../predicate/isArrayBuffer.js");
//#region src/compat/predicate/isArrayBuffer.ts
/**
* Checks if a given value is `ArrayBuffer`.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `ArrayBuffer`.
*
* @param value The value to check if it is a `ArrayBuffer`.
* @returns Returns `true` if `value` is a `ArrayBuffer`, else `false`.
*
* @example
* const value1 = new ArrayBuffer();
* const value2 = new Array();
* const value3 = new Map();
*
* console.log(isArrayBuffer(value1)); // true
* console.log(isArrayBuffer(value2)); // false
* console.log(isArrayBuffer(value3)); // false
*/
function isArrayBuffer(value) {
return require_isArrayBuffer.isArrayBuffer(value);
}
//#endregion
exports.isArrayBuffer = isArrayBuffer;

View file

@ -0,0 +1,24 @@
import { isArrayBuffer as isArrayBuffer$1 } from "../../predicate/isArrayBuffer.mjs";
//#region src/compat/predicate/isArrayBuffer.ts
/**
* Checks if a given value is `ArrayBuffer`.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `ArrayBuffer`.
*
* @param value The value to check if it is a `ArrayBuffer`.
* @returns Returns `true` if `value` is a `ArrayBuffer`, else `false`.
*
* @example
* const value1 = new ArrayBuffer();
* const value2 = new Array();
* const value3 = new Map();
*
* console.log(isArrayBuffer(value1)); // true
* console.log(isArrayBuffer(value2)); // false
* console.log(isArrayBuffer(value3)); // false
*/
function isArrayBuffer(value) {
return isArrayBuffer$1(value);
}
//#endregion
export { isArrayBuffer };

View file

@ -0,0 +1,28 @@
//#region src/compat/predicate/isArrayLike.d.ts
/**
* Checks if `value` is array-like. This overload is for compatibility with lodash type checking.
*
* @param t The value to check.
* @returns Returns `true` if `value` is array-like, else `false`.
*/
declare function isArrayLike<T extends {
__lodashAnyHack: any;
}>(t: T): boolean;
/**
* Checks if `value` is array-like. Functions, null, and undefined are never array-like.
*
* @param value The value to check.
* @returns Returns `false` for functions, null, and undefined.
*/
declare function isArrayLike(value: ((...args: any[]) => any) | null | undefined): value is never;
/**
* Checks if `value` is array-like.
*
* @param value The value to check.
* @returns} Returns `true` if `value` is array-like, else `false`.
*/
declare function isArrayLike(value: any): value is {
length: number;
};
//#endregion
export { isArrayLike };

View file

@ -0,0 +1,28 @@
//#region src/compat/predicate/isArrayLike.d.ts
/**
* Checks if `value` is array-like. This overload is for compatibility with lodash type checking.
*
* @param t The value to check.
* @returns Returns `true` if `value` is array-like, else `false`.
*/
declare function isArrayLike<T extends {
__lodashAnyHack: any;
}>(t: T): boolean;
/**
* Checks if `value` is array-like. Functions, null, and undefined are never array-like.
*
* @param value The value to check.
* @returns Returns `false` for functions, null, and undefined.
*/
declare function isArrayLike(value: ((...args: any[]) => any) | null | undefined): value is never;
/**
* Checks if `value` is array-like.
*
* @param value The value to check.
* @returns} Returns `true` if `value` is array-like, else `false`.
*/
declare function isArrayLike(value: any): value is {
length: number;
};
//#endregion
export { isArrayLike };

View file

@ -0,0 +1,21 @@
const require_isLength = require("../../predicate/isLength.js");
//#region src/compat/predicate/isArrayLike.ts
/**
* Checks if `value` is array-like.
*
* @param value The value to check.
* @returns Returns `true` if `value` is array-like, else `false`.
*
* @example
* isArrayLike([1, 2, 3]); // true
* isArrayLike('abc'); // true
* isArrayLike({ 0: 'a', length: 1 }); // true
* isArrayLike({}); // false
* isArrayLike(null); // false
* isArrayLike(undefined); // false
*/
function isArrayLike(value) {
return value != null && typeof value !== "function" && require_isLength.isLength(value.length);
}
//#endregion
exports.isArrayLike = isArrayLike;

View file

@ -0,0 +1,21 @@
import { isLength } from "../../predicate/isLength.mjs";
//#region src/compat/predicate/isArrayLike.ts
/**
* Checks if `value` is array-like.
*
* @param value The value to check.
* @returns Returns `true` if `value` is array-like, else `false`.
*
* @example
* isArrayLike([1, 2, 3]); // true
* isArrayLike('abc'); // true
* isArrayLike({ 0: 'a', length: 1 }); // true
* isArrayLike({}); // false
* isArrayLike(null); // false
* isArrayLike(undefined); // false
*/
function isArrayLike(value) {
return value != null && typeof value !== "function" && isLength(value.length);
}
//#endregion
export { isArrayLike };

View file

@ -0,0 +1,10 @@
//#region src/compat/predicate/isArrayLikeObject.d.ts
declare function isArrayLikeObject<T extends {
__lodashAnyHack: any;
}>(value: T): boolean;
declare function isArrayLikeObject(value: ((...args: any[]) => any) | Function | string | boolean | number | null | undefined): value is never;
declare function isArrayLikeObject(value: any): value is object & {
length: number;
};
//#endregion
export { isArrayLikeObject };

View file

@ -0,0 +1,10 @@
//#region src/compat/predicate/isArrayLikeObject.d.ts
declare function isArrayLikeObject<T extends {
__lodashAnyHack: any;
}>(value: T): boolean;
declare function isArrayLikeObject(value: ((...args: any[]) => any) | Function | string | boolean | number | null | undefined): value is never;
declare function isArrayLikeObject(value: any): value is object & {
length: number;
};
//#endregion
export { isArrayLikeObject };

View file

@ -0,0 +1,20 @@
const require_isArrayLike = require("./isArrayLike.js");
const require_isObjectLike = require("./isObjectLike.js");
//#region src/compat/predicate/isArrayLikeObject.ts
/**
* Checks if the given value is a non-primitive, array-like object.
*
* @param value The value to check.
* @returns `true` if the value is a non-primitive, array-like object, `false` otherwise.
*
* @example
* isArrayLikeObject([1, 2, 3]); // true
* isArrayLikeObject({ 0: 'a', length: 1 }); // true
* isArrayLikeObject('abc'); // false
* isArrayLikeObject(()=>{}); // false
*/
function isArrayLikeObject(value) {
return require_isObjectLike.isObjectLike(value) && require_isArrayLike.isArrayLike(value);
}
//#endregion
exports.isArrayLikeObject = isArrayLikeObject;

View file

@ -0,0 +1,20 @@
import { isArrayLike } from "./isArrayLike.mjs";
import { isObjectLike } from "./isObjectLike.mjs";
//#region src/compat/predicate/isArrayLikeObject.ts
/**
* Checks if the given value is a non-primitive, array-like object.
*
* @param value The value to check.
* @returns `true` if the value is a non-primitive, array-like object, `false` otherwise.
*
* @example
* isArrayLikeObject([1, 2, 3]); // true
* isArrayLikeObject({ 0: 'a', length: 1 }); // true
* isArrayLikeObject('abc'); // false
* isArrayLikeObject(()=>{}); // false
*/
function isArrayLikeObject(value) {
return isObjectLike(value) && isArrayLike(value);
}
//#endregion
export { isArrayLikeObject };

View file

@ -0,0 +1,26 @@
//#region src/compat/predicate/isBoolean.d.ts
/**
* Checks if the given value is boolean.
*
* This function tests whether the provided value is strictly `boolean`.
* It returns `true` if the value is `boolean`, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.
*
* @param value - The Value to test if it is boolean.
* @returns True if the value is boolean, false otherwise.
*
* @example
*
* const value1 = true;
* const value2 = 0;
* const value3 = 'abc';
*
* console.log(isBoolean(value1)); // true
* console.log(isBoolean(value2)); // false
* console.log(isBoolean(value3)); // false
*
*/
declare function isBoolean(value?: any): value is boolean;
//#endregion
export { isBoolean };

View file

@ -0,0 +1,26 @@
//#region src/compat/predicate/isBoolean.d.ts
/**
* Checks if the given value is boolean.
*
* This function tests whether the provided value is strictly `boolean`.
* It returns `true` if the value is `boolean`, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.
*
* @param value - The Value to test if it is boolean.
* @returns True if the value is boolean, false otherwise.
*
* @example
*
* const value1 = true;
* const value2 = 0;
* const value3 = 'abc';
*
* console.log(isBoolean(value1)); // true
* console.log(isBoolean(value2)); // false
* console.log(isBoolean(value3)); // false
*
*/
declare function isBoolean(value?: any): value is boolean;
//#endregion
export { isBoolean };

View file

@ -0,0 +1,28 @@
//#region src/compat/predicate/isBoolean.ts
/**
* Checks if the given value is boolean.
*
* This function tests whether the provided value is strictly `boolean`.
* It returns `true` if the value is `boolean`, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.
*
* @param value - The Value to test if it is boolean.
* @returns True if the value is boolean, false otherwise.
*
* @example
*
* const value1 = true;
* const value2 = 0;
* const value3 = 'abc';
*
* console.log(isBoolean(value1)); // true
* console.log(isBoolean(value2)); // false
* console.log(isBoolean(value3)); // false
*
*/
function isBoolean(value) {
return typeof value === "boolean" || value instanceof Boolean;
}
//#endregion
exports.isBoolean = isBoolean;

View file

@ -0,0 +1,28 @@
//#region src/compat/predicate/isBoolean.ts
/**
* Checks if the given value is boolean.
*
* This function tests whether the provided value is strictly `boolean`.
* It returns `true` if the value is `boolean`, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.
*
* @param value - The Value to test if it is boolean.
* @returns True if the value is boolean, false otherwise.
*
* @example
*
* const value1 = true;
* const value2 = 0;
* const value3 = 'abc';
*
* console.log(isBoolean(value1)); // true
* console.log(isBoolean(value2)); // false
* console.log(isBoolean(value3)); // false
*
*/
function isBoolean(value) {
return typeof value === "boolean" || value instanceof Boolean;
}
//#endregion
export { isBoolean };

View file

@ -0,0 +1,22 @@
//#region src/compat/predicate/isBuffer.d.ts
/**
* Checks if the given value is a Buffer instance.
*
* This function tests whether the provided value is an instance of Buffer.
* It returns `true` if the value is a Buffer, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Buffer`.
*
* @param x - The value to check if it is a Buffer.
* @returns Returns `true` if `x` is a Buffer, else `false`.
*
* @example
* const buffer = Buffer.from("test");
* console.log(isBuffer(buffer)); // true
*
* const notBuffer = "not a buffer";
* console.log(isBuffer(notBuffer)); // false
*/
declare function isBuffer(x?: any): boolean;
//#endregion
export { isBuffer };

View file

@ -0,0 +1,22 @@
//#region src/compat/predicate/isBuffer.d.ts
/**
* Checks if the given value is a Buffer instance.
*
* This function tests whether the provided value is an instance of Buffer.
* It returns `true` if the value is a Buffer, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Buffer`.
*
* @param x - The value to check if it is a Buffer.
* @returns Returns `true` if `x` is a Buffer, else `false`.
*
* @example
* const buffer = Buffer.from("test");
* console.log(isBuffer(buffer)); // true
*
* const notBuffer = "not a buffer";
* console.log(isBuffer(notBuffer)); // false
*/
declare function isBuffer(x?: any): boolean;
//#endregion
export { isBuffer };

View file

@ -0,0 +1,25 @@
const require_isBuffer = require("../../predicate/isBuffer.js");
//#region src/compat/predicate/isBuffer.ts
/**
* Checks if the given value is a Buffer instance.
*
* This function tests whether the provided value is an instance of Buffer.
* It returns `true` if the value is a Buffer, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Buffer`.
*
* @param x - The value to check if it is a Buffer.
* @returns Returns `true` if `x` is a Buffer, else `false`.
*
* @example
* const buffer = Buffer.from("test");
* console.log(isBuffer(buffer)); // true
*
* const notBuffer = "not a buffer";
* console.log(isBuffer(notBuffer)); // false
*/
function isBuffer(x) {
return require_isBuffer.isBuffer(x);
}
//#endregion
exports.isBuffer = isBuffer;

View file

@ -0,0 +1,25 @@
import { isBuffer as isBuffer$1 } from "../../predicate/isBuffer.mjs";
//#region src/compat/predicate/isBuffer.ts
/**
* Checks if the given value is a Buffer instance.
*
* This function tests whether the provided value is an instance of Buffer.
* It returns `true` if the value is a Buffer, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Buffer`.
*
* @param x - The value to check if it is a Buffer.
* @returns Returns `true` if `x` is a Buffer, else `false`.
*
* @example
* const buffer = Buffer.from("test");
* console.log(isBuffer(buffer)); // true
*
* const notBuffer = "not a buffer";
* console.log(isBuffer(notBuffer)); // false
*/
function isBuffer(x) {
return isBuffer$1(x);
}
//#endregion
export { isBuffer };

View file

@ -0,0 +1,17 @@
//#region src/compat/predicate/isDate.d.ts
/**
* Checks if `value` is a Date object.
*
* @param value The value to check.
* @returns Returns `true` if `value` is a Date object, `false` otherwise.
*
* @example
* const value1 = new Date();
* const value2 = '2024-01-01';
*
* console.log(isDate(value1)); // true
* console.log(isDate(value2)); // false
*/
declare function isDate(value?: any): value is Date;
//#endregion
export { isDate };

View file

@ -0,0 +1,17 @@
//#region src/compat/predicate/isDate.d.ts
/**
* Checks if `value` is a Date object.
*
* @param value The value to check.
* @returns Returns `true` if `value` is a Date object, `false` otherwise.
*
* @example
* const value1 = new Date();
* const value2 = '2024-01-01';
*
* console.log(isDate(value1)); // true
* console.log(isDate(value2)); // false
*/
declare function isDate(value?: any): value is Date;
//#endregion
export { isDate };

View file

@ -0,0 +1,20 @@
const require_isDate = require("../../predicate/isDate.js");
//#region src/compat/predicate/isDate.ts
/**
* Checks if `value` is a Date object.
*
* @param value The value to check.
* @returns Returns `true` if `value` is a Date object, `false` otherwise.
*
* @example
* const value1 = new Date();
* const value2 = '2024-01-01';
*
* console.log(isDate(value1)); // true
* console.log(isDate(value2)); // false
*/
function isDate(value) {
return require_isDate.isDate(value);
}
//#endregion
exports.isDate = isDate;

View file

@ -0,0 +1,20 @@
import { isDate as isDate$1 } from "../../predicate/isDate.mjs";
//#region src/compat/predicate/isDate.ts
/**
* Checks if `value` is a Date object.
*
* @param value The value to check.
* @returns Returns `true` if `value` is a Date object, `false` otherwise.
*
* @example
* const value1 = new Date();
* const value2 = '2024-01-01';
*
* console.log(isDate(value1)); // true
* console.log(isDate(value2)); // false
*/
function isDate(value) {
return isDate$1(value);
}
//#endregion
export { isDate };

View file

@ -0,0 +1,14 @@
//#region src/compat/predicate/isElement.d.ts
/**
* Checks if `value` is likely a DOM element.
*
* @param value The value to check.
* @returns Returns `true` if `value` is a DOM element, else `false`.
*
* @example
* console.log(isElement(document.body)); // true
* console.log(isElement('<body>')); // false
*/
declare function isElement(value?: any): boolean;
//#endregion
export { isElement };

View file

@ -0,0 +1,14 @@
//#region src/compat/predicate/isElement.d.ts
/**
* Checks if `value` is likely a DOM element.
*
* @param value The value to check.
* @returns Returns `true` if `value` is a DOM element, else `false`.
*
* @example
* console.log(isElement(document.body)); // true
* console.log(isElement('<body>')); // false
*/
declare function isElement(value?: any): boolean;
//#endregion
export { isElement };

View file

@ -0,0 +1,18 @@
const require_isPlainObject = require("./isPlainObject.js");
const require_isObjectLike = require("./isObjectLike.js");
//#region src/compat/predicate/isElement.ts
/**
* Checks if `value` is likely a DOM element.
*
* @param value The value to check.
* @returns Returns `true` if `value` is a DOM element, else `false`.
*
* @example
* console.log(isElement(document.body)); // true
* console.log(isElement('<body>')); // false
*/
function isElement(value) {
return require_isObjectLike.isObjectLike(value) && value.nodeType === 1 && !require_isPlainObject.isPlainObject(value);
}
//#endregion
exports.isElement = isElement;

View file

@ -0,0 +1,18 @@
import { isPlainObject } from "./isPlainObject.mjs";
import { isObjectLike } from "./isObjectLike.mjs";
//#region src/compat/predicate/isElement.ts
/**
* Checks if `value` is likely a DOM element.
*
* @param value The value to check.
* @returns Returns `true` if `value` is a DOM element, else `false`.
*
* @example
* console.log(isElement(document.body)); // true
* console.log(isElement('<body>')); // false
*/
function isElement(value) {
return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
}
//#endregion
export { isElement };

View file

@ -0,0 +1,13 @@
import { EmptyObjectOf } from "../_internal/EmptyObjectOf.mjs";
//#region src/compat/predicate/isEmpty.d.ts
declare function isEmpty<T extends {
__trapAny: any;
}>(value?: T): boolean;
declare function isEmpty(value: string): value is '';
declare function isEmpty(value: Map<any, any> | Set<any> | ArrayLike<any> | null | undefined): boolean;
declare function isEmpty(value: object): boolean;
declare function isEmpty<T extends object>(value: T | null | undefined): value is EmptyObjectOf<T> | null | undefined;
declare function isEmpty(value?: any): boolean;
//#endregion
export { isEmpty };

View file

@ -0,0 +1,13 @@
import { EmptyObjectOf } from "../_internal/EmptyObjectOf.js";
//#region src/compat/predicate/isEmpty.d.ts
declare function isEmpty<T extends {
__trapAny: any;
}>(value?: T): boolean;
declare function isEmpty(value: string): value is '';
declare function isEmpty(value: Map<any, any> | Set<any> | ArrayLike<any> | null | undefined): boolean;
declare function isEmpty(value: object): boolean;
declare function isEmpty<T extends object>(value: T | null | undefined): value is EmptyObjectOf<T> | null | undefined;
declare function isEmpty(value?: any): boolean;
//#endregion
export { isEmpty };

View file

@ -0,0 +1,48 @@
const require_isBuffer = require("../../predicate/isBuffer.js");
const require_isArrayLike = require("./isArrayLike.js");
const require_isArguments = require("./isArguments.js");
const require_isPrototype = require("../_internal/isPrototype.js");
const require_isTypedArray = require("./isTypedArray.js");
//#region src/compat/predicate/isEmpty.ts
/**
* Checks if a given value is empty.
*
* - If the given value is a string, checks if it is an empty string.
* - If the given value is an array, `Map`, or `Set`, checks if its size is 0.
* - If the given value is an [array-like object](../predicate/isArrayLike.md), checks if its length is 0.
* - If the given value is an object, checks if it is an empty object with no properties.
* - Primitive values (booleans, numbers, or bigints) are considered empty.
*
* @param [value] - The value to check.
* @returns `true` if the value is empty, `false` otherwise.
*
* @example
* isEmpty(); // true
* isEmpty(null); // true
* isEmpty(""); // true
* isEmpty([]); // true
* isEmpty({}); // true
* isEmpty(new Map()); // true
* isEmpty(new Set()); // true
* isEmpty("hello"); // false
* isEmpty([1, 2, 3]); // false
* isEmpty({ a: 1 }); // false
* isEmpty(new Map([["key", "value"]])); // false
* isEmpty(new Set([1, 2, 3])); // false
*/
function isEmpty(value) {
if (value == null) return true;
if (require_isArrayLike.isArrayLike(value)) {
if (typeof value.splice !== "function" && typeof value !== "string" && !require_isBuffer.isBuffer(value) && !require_isTypedArray.isTypedArray(value) && !require_isArguments.isArguments(value)) return false;
return value.length === 0;
}
if (typeof value === "object" || typeof value === "function") {
if (value instanceof Map || value instanceof Set) return value.size === 0;
const keys = Object.keys(value);
if (require_isPrototype.isPrototype(value)) return keys.filter((x) => x !== "constructor").length === 0;
return keys.length === 0;
}
return true;
}
//#endregion
exports.isEmpty = isEmpty;

View file

@ -0,0 +1,48 @@
import { isBuffer } from "../../predicate/isBuffer.mjs";
import { isArrayLike } from "./isArrayLike.mjs";
import { isArguments } from "./isArguments.mjs";
import { isPrototype } from "../_internal/isPrototype.mjs";
import { isTypedArray } from "./isTypedArray.mjs";
//#region src/compat/predicate/isEmpty.ts
/**
* Checks if a given value is empty.
*
* - If the given value is a string, checks if it is an empty string.
* - If the given value is an array, `Map`, or `Set`, checks if its size is 0.
* - If the given value is an [array-like object](../predicate/isArrayLike.md), checks if its length is 0.
* - If the given value is an object, checks if it is an empty object with no properties.
* - Primitive values (booleans, numbers, or bigints) are considered empty.
*
* @param [value] - The value to check.
* @returns `true` if the value is empty, `false` otherwise.
*
* @example
* isEmpty(); // true
* isEmpty(null); // true
* isEmpty(""); // true
* isEmpty([]); // true
* isEmpty({}); // true
* isEmpty(new Map()); // true
* isEmpty(new Set()); // true
* isEmpty("hello"); // false
* isEmpty([1, 2, 3]); // false
* isEmpty({ a: 1 }); // false
* isEmpty(new Map([["key", "value"]])); // false
* isEmpty(new Set([1, 2, 3])); // false
*/
function isEmpty(value) {
if (value == null) return true;
if (isArrayLike(value)) {
if (typeof value.splice !== "function" && typeof value !== "string" && !isBuffer(value) && !isTypedArray(value) && !isArguments(value)) return false;
return value.length === 0;
}
if (typeof value === "object" || typeof value === "function") {
if (value instanceof Map || value instanceof Set) return value.size === 0;
const keys = Object.keys(value);
if (isPrototype(value)) return keys.filter((x) => x !== "constructor").length === 0;
return keys.length === 0;
}
return true;
}
//#endregion
export { isEmpty };

View file

@ -0,0 +1,41 @@
import { IsEqualCustomizer } from "../_internal/IsEqualCustomizer.mjs";
//#region src/compat/predicate/isEqualWith.d.ts
/**
* Compares two values for equality using a custom comparison function.
*
* The custom function allows for fine-tuned control over the comparison process. If it returns a boolean, that result determines the equality. If it returns undefined, the function falls back to the default equality comparison.
*
* This function also uses the custom equality function to compare values inside objects,
* arrays, maps, sets, and other complex structures, ensuring a deep comparison.
*
* This approach provides flexibility in handling complex comparisons while maintaining efficient default behavior for simpler cases.
*
* The custom comparison function can take up to six parameters:
* - `x`: The value from the first object `a`.
* - `y`: The value from the second object `b`.
* - `property`: The property key used to get `x` and `y`.
* - `xParent`: The parent of the first value `x`.
* - `yParent`: The parent of the second value `y`.
* - `stack`: An internal stack (Map) to handle circular references.
*
* @param a - The first value to compare.
* @param b - The second value to compare.
* @param [areValuesEqual=noop] - A function to customize the comparison.
* If it returns a boolean, that result will be used. If it returns undefined,
* the default equality comparison will be used.
* @returns `true` if the values are equal according to the customizer, otherwise `false`.
*
* @example
* const customizer = (a, b) => {
* if (typeof a === 'string' && typeof b === 'string') {
* return a.toLowerCase() === b.toLowerCase();
* }
* };
* isEqualWith('Hello', 'hello', customizer); // true
* isEqualWith({ a: 'Hello' }, { a: 'hello' }, customizer); // true
* isEqualWith([1, 2, 3], [1, 2, 3], customizer); // true
*/
declare function isEqualWith(a: any, b: any, areValuesEqual?: IsEqualCustomizer): boolean;
//#endregion
export { isEqualWith };

View file

@ -0,0 +1,41 @@
import { IsEqualCustomizer } from "../_internal/IsEqualCustomizer.js";
//#region src/compat/predicate/isEqualWith.d.ts
/**
* Compares two values for equality using a custom comparison function.
*
* The custom function allows for fine-tuned control over the comparison process. If it returns a boolean, that result determines the equality. If it returns undefined, the function falls back to the default equality comparison.
*
* This function also uses the custom equality function to compare values inside objects,
* arrays, maps, sets, and other complex structures, ensuring a deep comparison.
*
* This approach provides flexibility in handling complex comparisons while maintaining efficient default behavior for simpler cases.
*
* The custom comparison function can take up to six parameters:
* - `x`: The value from the first object `a`.
* - `y`: The value from the second object `b`.
* - `property`: The property key used to get `x` and `y`.
* - `xParent`: The parent of the first value `x`.
* - `yParent`: The parent of the second value `y`.
* - `stack`: An internal stack (Map) to handle circular references.
*
* @param a - The first value to compare.
* @param b - The second value to compare.
* @param [areValuesEqual=noop] - A function to customize the comparison.
* If it returns a boolean, that result will be used. If it returns undefined,
* the default equality comparison will be used.
* @returns `true` if the values are equal according to the customizer, otherwise `false`.
*
* @example
* const customizer = (a, b) => {
* if (typeof a === 'string' && typeof b === 'string') {
* return a.toLowerCase() === b.toLowerCase();
* }
* };
* isEqualWith('Hello', 'hello', customizer); // true
* isEqualWith({ a: 'Hello' }, { a: 'hello' }, customizer); // true
* isEqualWith([1, 2, 3], [1, 2, 3], customizer); // true
*/
declare function isEqualWith(a: any, b: any, areValuesEqual?: IsEqualCustomizer): boolean;
//#endregion
export { isEqualWith };

View file

@ -0,0 +1,49 @@
const require_after = require("../../function/after.js");
const require_isEqualWith = require("../../predicate/isEqualWith.js");
//#region src/compat/predicate/isEqualWith.ts
/**
* Compares two values for equality using a custom comparison function.
*
* The custom function allows for fine-tuned control over the comparison process. If it returns a boolean, that result determines the equality. If it returns undefined, the function falls back to the default equality comparison.
*
* This function also uses the custom equality function to compare values inside objects,
* arrays, maps, sets, and other complex structures, ensuring a deep comparison.
*
* This approach provides flexibility in handling complex comparisons while maintaining efficient default behavior for simpler cases.
*
* The custom comparison function can take up to six parameters:
* - `x`: The value from the first object `a`.
* - `y`: The value from the second object `b`.
* - `property`: The property key used to get `x` and `y`.
* - `xParent`: The parent of the first value `x`.
* - `yParent`: The parent of the second value `y`.
* - `stack`: An internal stack (Map) to handle circular references.
*
* @param a - The first value to compare.
* @param b - The second value to compare.
* @param [areValuesEqual=noop] - A function to customize the comparison.
* If it returns a boolean, that result will be used. If it returns undefined,
* the default equality comparison will be used.
* @returns `true` if the values are equal according to the customizer, otherwise `false`.
*
* @example
* const customizer = (a, b) => {
* if (typeof a === 'string' && typeof b === 'string') {
* return a.toLowerCase() === b.toLowerCase();
* }
* };
* isEqualWith('Hello', 'hello', customizer); // true
* isEqualWith({ a: 'Hello' }, { a: 'hello' }, customizer); // true
* isEqualWith([1, 2, 3], [1, 2, 3], customizer); // true
*/
function isEqualWith(a, b, areValuesEqual) {
if (typeof areValuesEqual !== "function") areValuesEqual = () => void 0;
return require_isEqualWith.isEqualWith(a, b, (...args) => {
const result = areValuesEqual(...args);
if (result !== void 0) return Boolean(result);
if (a instanceof Map && b instanceof Map) return isEqualWith(Array.from(a), Array.from(b), require_after.after(2, areValuesEqual));
if (a instanceof Set && b instanceof Set) return isEqualWith(Array.from(a), Array.from(b), require_after.after(2, areValuesEqual));
});
}
//#endregion
exports.isEqualWith = isEqualWith;

View file

@ -0,0 +1,49 @@
import { after } from "../../function/after.mjs";
import { isEqualWith as isEqualWith$1 } from "../../predicate/isEqualWith.mjs";
//#region src/compat/predicate/isEqualWith.ts
/**
* Compares two values for equality using a custom comparison function.
*
* The custom function allows for fine-tuned control over the comparison process. If it returns a boolean, that result determines the equality. If it returns undefined, the function falls back to the default equality comparison.
*
* This function also uses the custom equality function to compare values inside objects,
* arrays, maps, sets, and other complex structures, ensuring a deep comparison.
*
* This approach provides flexibility in handling complex comparisons while maintaining efficient default behavior for simpler cases.
*
* The custom comparison function can take up to six parameters:
* - `x`: The value from the first object `a`.
* - `y`: The value from the second object `b`.
* - `property`: The property key used to get `x` and `y`.
* - `xParent`: The parent of the first value `x`.
* - `yParent`: The parent of the second value `y`.
* - `stack`: An internal stack (Map) to handle circular references.
*
* @param a - The first value to compare.
* @param b - The second value to compare.
* @param [areValuesEqual=noop] - A function to customize the comparison.
* If it returns a boolean, that result will be used. If it returns undefined,
* the default equality comparison will be used.
* @returns `true` if the values are equal according to the customizer, otherwise `false`.
*
* @example
* const customizer = (a, b) => {
* if (typeof a === 'string' && typeof b === 'string') {
* return a.toLowerCase() === b.toLowerCase();
* }
* };
* isEqualWith('Hello', 'hello', customizer); // true
* isEqualWith({ a: 'Hello' }, { a: 'hello' }, customizer); // true
* isEqualWith([1, 2, 3], [1, 2, 3], customizer); // true
*/
function isEqualWith(a, b, areValuesEqual) {
if (typeof areValuesEqual !== "function") areValuesEqual = () => void 0;
return isEqualWith$1(a, b, (...args) => {
const result = areValuesEqual(...args);
if (result !== void 0) return Boolean(result);
if (a instanceof Map && b instanceof Map) return isEqualWith(Array.from(a), Array.from(b), after(2, areValuesEqual));
if (a instanceof Set && b instanceof Set) return isEqualWith(Array.from(a), Array.from(b), after(2, areValuesEqual));
});
}
//#endregion
export { isEqualWith };

View file

@ -0,0 +1,17 @@
//#region src/compat/predicate/isError.d.ts
/**
* Checks if `value` is an Error object.
*
* @param value The value to check.
* @returns Returns `true` if `value` is an Error object, `false` otherwise.
*
* @example
* ```typescript
* console.log(isError(new Error())); // true
* console.log(isError('Error')); // false
* console.log(isError({ name: 'Error', message: '' })); // false
* ```
*/
declare function isError(value: any): value is Error;
//#endregion
export { isError };

View file

@ -0,0 +1,17 @@
//#region src/compat/predicate/isError.d.ts
/**
* Checks if `value` is an Error object.
*
* @param value The value to check.
* @returns Returns `true` if `value` is an Error object, `false` otherwise.
*
* @example
* ```typescript
* console.log(isError(new Error())); // true
* console.log(isError('Error')); // false
* console.log(isError({ name: 'Error', message: '' })); // false
* ```
*/
declare function isError(value: any): value is Error;
//#endregion
export { isError };

View file

@ -0,0 +1,20 @@
const require_getTag = require("../_internal/getTag.js");
//#region src/compat/predicate/isError.ts
/**
* Checks if `value` is an Error object.
*
* @param value The value to check.
* @returns Returns `true` if `value` is an Error object, `false` otherwise.
*
* @example
* ```typescript
* console.log(isError(new Error())); // true
* console.log(isError('Error')); // false
* console.log(isError({ name: 'Error', message: '' })); // false
* ```
*/
function isError(value) {
return require_getTag.getTag(value) === "[object Error]";
}
//#endregion
exports.isError = isError;

View file

@ -0,0 +1,20 @@
import { getTag } from "../_internal/getTag.mjs";
//#region src/compat/predicate/isError.ts
/**
* Checks if `value` is an Error object.
*
* @param value The value to check.
* @returns Returns `true` if `value` is an Error object, `false` otherwise.
*
* @example
* ```typescript
* console.log(isError(new Error())); // true
* console.log(isError('Error')); // false
* console.log(isError({ name: 'Error', message: '' })); // false
* ```
*/
function isError(value) {
return getTag(value) === "[object Error]";
}
//#endregion
export { isError };

View file

@ -0,0 +1,28 @@
//#region src/compat/predicate/isFinite.d.ts
/**
* Checks if `value` is a finite number.
*
* Acts as a type guard for `number` values returning `true` only when `value`
* is of type `number` and finite (not `Infinity`, `-Infinity`, or `NaN`).
*
* @param value The value to check.
* @returns Returns `true` if `value` is a finite number, `false` otherwise.
*
* @example
* ```typescript
* const value1 = 100;
* const value2 = Infinity;
* const value3 = '100';
*
* console.log(isFinite(value1)); // true
* console.log(isFinite(value2)); // false
* console.log(isFinite(value3)); // false
*
* if (isFinite(value1)) {
* console.log(value1.toFixed(2));
* }
* ```
*/
declare function isFinite(value: unknown): value is number;
//#endregion
export { isFinite };

View file

@ -0,0 +1,28 @@
//#region src/compat/predicate/isFinite.d.ts
/**
* Checks if `value` is a finite number.
*
* Acts as a type guard for `number` values returning `true` only when `value`
* is of type `number` and finite (not `Infinity`, `-Infinity`, or `NaN`).
*
* @param value The value to check.
* @returns Returns `true` if `value` is a finite number, `false` otherwise.
*
* @example
* ```typescript
* const value1 = 100;
* const value2 = Infinity;
* const value3 = '100';
*
* console.log(isFinite(value1)); // true
* console.log(isFinite(value2)); // false
* console.log(isFinite(value3)); // false
*
* if (isFinite(value1)) {
* console.log(value1.toFixed(2));
* }
* ```
*/
declare function isFinite(value: unknown): value is number;
//#endregion
export { isFinite };

View file

@ -0,0 +1,30 @@
//#region src/compat/predicate/isFinite.ts
/**
* Checks if `value` is a finite number.
*
* Acts as a type guard for `number` values returning `true` only when `value`
* is of type `number` and finite (not `Infinity`, `-Infinity`, or `NaN`).
*
* @param value The value to check.
* @returns Returns `true` if `value` is a finite number, `false` otherwise.
*
* @example
* ```typescript
* const value1 = 100;
* const value2 = Infinity;
* const value3 = '100';
*
* console.log(isFinite(value1)); // true
* console.log(isFinite(value2)); // false
* console.log(isFinite(value3)); // false
*
* if (isFinite(value1)) {
* console.log(value1.toFixed(2));
* }
* ```
*/
function isFinite(value) {
return Number.isFinite(value);
}
//#endregion
exports.isFinite = isFinite;

View file

@ -0,0 +1,30 @@
//#region src/compat/predicate/isFinite.ts
/**
* Checks if `value` is a finite number.
*
* Acts as a type guard for `number` values returning `true` only when `value`
* is of type `number` and finite (not `Infinity`, `-Infinity`, or `NaN`).
*
* @param value The value to check.
* @returns Returns `true` if `value` is a finite number, `false` otherwise.
*
* @example
* ```typescript
* const value1 = 100;
* const value2 = Infinity;
* const value3 = '100';
*
* console.log(isFinite(value1)); // true
* console.log(isFinite(value2)); // false
* console.log(isFinite(value3)); // false
*
* if (isFinite(value1)) {
* console.log(value1.toFixed(2));
* }
* ```
*/
function isFinite(value) {
return Number.isFinite(value);
}
//#endregion
export { isFinite };

View file

@ -0,0 +1,17 @@
//#region src/compat/predicate/isFunction.d.ts
/**
* Checks if `value` is a function.
*
* @param value The value to check.
* @returns Returns `true` if `value` is a function, else `false`.
*
* @example
* isFunction(Array.prototype.slice); // true
* isFunction(async function () {}); // true
* isFunction(function* () {}); // true
* isFunction(Proxy); // true
* isFunction(Int8Array); // true
*/
declare function isFunction(value: any): value is (...args: any[]) => any;
//#endregion
export { isFunction };

View file

@ -0,0 +1,17 @@
//#region src/compat/predicate/isFunction.d.ts
/**
* Checks if `value` is a function.
*
* @param value The value to check.
* @returns Returns `true` if `value` is a function, else `false`.
*
* @example
* isFunction(Array.prototype.slice); // true
* isFunction(async function () {}); // true
* isFunction(function* () {}); // true
* isFunction(Proxy); // true
* isFunction(Int8Array); // true
*/
declare function isFunction(value: any): value is (...args: any[]) => any;
//#endregion
export { isFunction };

View file

@ -0,0 +1,19 @@
//#region src/compat/predicate/isFunction.ts
/**
* Checks if `value` is a function.
*
* @param value The value to check.
* @returns Returns `true` if `value` is a function, else `false`.
*
* @example
* isFunction(Array.prototype.slice); // true
* isFunction(async function () {}); // true
* isFunction(function* () {}); // true
* isFunction(Proxy); // true
* isFunction(Int8Array); // true
*/
function isFunction(value) {
return typeof value === "function";
}
//#endregion
exports.isFunction = isFunction;

View file

@ -0,0 +1,19 @@
//#region src/compat/predicate/isFunction.ts
/**
* Checks if `value` is a function.
*
* @param value The value to check.
* @returns Returns `true` if `value` is a function, else `false`.
*
* @example
* isFunction(Array.prototype.slice); // true
* isFunction(async function () {}); // true
* isFunction(function* () {}); // true
* isFunction(Proxy); // true
* isFunction(Int8Array); // true
*/
function isFunction(value) {
return typeof value === "function";
}
//#endregion
export { isFunction };

View file

@ -0,0 +1,18 @@
//#region src/compat/predicate/isInteger.d.ts
/**
* Checks if `value` is an integer.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`.
*
* @param value - The value to check
* @returns `true` if `value` is integer, otherwise `false`.
*
* @example
* isInteger(3); // Returns: true
* isInteger(Infinity); // Returns: false
* isInteger('3'); // Returns: false
* isInteger([]); // Returns: false
*/
declare function isInteger(value?: any): boolean;
//#endregion
export { isInteger };

View file

@ -0,0 +1,18 @@
//#region src/compat/predicate/isInteger.d.ts
/**
* Checks if `value` is an integer.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`.
*
* @param value - The value to check
* @returns `true` if `value` is integer, otherwise `false`.
*
* @example
* isInteger(3); // Returns: true
* isInteger(Infinity); // Returns: false
* isInteger('3'); // Returns: false
* isInteger([]); // Returns: false
*/
declare function isInteger(value?: any): boolean;
//#endregion
export { isInteger };

View file

@ -0,0 +1,20 @@
//#region src/compat/predicate/isInteger.ts
/**
* Checks if `value` is an integer.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`.
*
* @param value - The value to check
* @returns `true` if `value` is integer, otherwise `false`.
*
* @example
* isInteger(3); // Returns: true
* isInteger(Infinity); // Returns: false
* isInteger('3'); // Returns: false
* isInteger([]); // Returns: false
*/
function isInteger(value) {
return Number.isInteger(value);
}
//#endregion
exports.isInteger = isInteger;

View file

@ -0,0 +1,20 @@
//#region src/compat/predicate/isInteger.ts
/**
* Checks if `value` is an integer.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`.
*
* @param value - The value to check
* @returns `true` if `value` is integer, otherwise `false`.
*
* @example
* isInteger(3); // Returns: true
* isInteger(Infinity); // Returns: false
* isInteger('3'); // Returns: false
* isInteger([]); // Returns: false
*/
function isInteger(value) {
return Number.isInteger(value);
}
//#endregion
export { isInteger };

View file

@ -0,0 +1,25 @@
//#region src/compat/predicate/isLength.d.ts
/**
* Checks if a given value is a valid length.
*
* A valid length is of type `number`, is a non-negative integer, and is less than or equal to
* JavaScript's maximum safe integer (`Number.MAX_SAFE_INTEGER`).
* It returns `true` if the value is a valid length, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the
* argument to a valid length (`number`).
*
* @param value The value to check.
* @returns Returns `true` if `value` is a valid length, else `false`.
*
* @example
* isLength(0); // true
* isLength(42); // true
* isLength(-1); // false
* isLength(1.5); // false
* isLength(Number.MAX_SAFE_INTEGER); // true
* isLength(Number.MAX_SAFE_INTEGER + 1); // false
*/
declare function isLength(value?: any): boolean;
//#endregion
export { isLength };

View file

@ -0,0 +1,25 @@
//#region src/compat/predicate/isLength.d.ts
/**
* Checks if a given value is a valid length.
*
* A valid length is of type `number`, is a non-negative integer, and is less than or equal to
* JavaScript's maximum safe integer (`Number.MAX_SAFE_INTEGER`).
* It returns `true` if the value is a valid length, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the
* argument to a valid length (`number`).
*
* @param value The value to check.
* @returns Returns `true` if `value` is a valid length, else `false`.
*
* @example
* isLength(0); // true
* isLength(42); // true
* isLength(-1); // false
* isLength(1.5); // false
* isLength(Number.MAX_SAFE_INTEGER); // true
* isLength(Number.MAX_SAFE_INTEGER + 1); // false
*/
declare function isLength(value?: any): boolean;
//#endregion
export { isLength };

View file

@ -0,0 +1,27 @@
//#region src/compat/predicate/isLength.ts
/**
* Checks if a given value is a valid length.
*
* A valid length is of type `number`, is a non-negative integer, and is less than or equal to
* JavaScript's maximum safe integer (`Number.MAX_SAFE_INTEGER`).
* It returns `true` if the value is a valid length, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the
* argument to a valid length (`number`).
*
* @param value The value to check.
* @returns Returns `true` if `value` is a valid length, else `false`.
*
* @example
* isLength(0); // true
* isLength(42); // true
* isLength(-1); // false
* isLength(1.5); // false
* isLength(Number.MAX_SAFE_INTEGER); // true
* isLength(Number.MAX_SAFE_INTEGER + 1); // false
*/
function isLength(value) {
return Number.isSafeInteger(value) && value >= 0;
}
//#endregion
exports.isLength = isLength;

View file

@ -0,0 +1,27 @@
//#region src/compat/predicate/isLength.ts
/**
* Checks if a given value is a valid length.
*
* A valid length is of type `number`, is a non-negative integer, and is less than or equal to
* JavaScript's maximum safe integer (`Number.MAX_SAFE_INTEGER`).
* It returns `true` if the value is a valid length, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the
* argument to a valid length (`number`).
*
* @param value The value to check.
* @returns Returns `true` if `value` is a valid length, else `false`.
*
* @example
* isLength(0); // true
* isLength(42); // true
* isLength(-1); // false
* isLength(1.5); // false
* isLength(Number.MAX_SAFE_INTEGER); // true
* isLength(Number.MAX_SAFE_INTEGER + 1); // false
*/
function isLength(value) {
return Number.isSafeInteger(value) && value >= 0;
}
//#endregion
export { isLength };

View file

@ -0,0 +1,21 @@
//#region src/compat/predicate/isMap.d.ts
/**
* Checks if a given value is `Map`.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Map`.
*
* @param value The value to check if it is a `Map`.
* @returns Returns `true` if `value` is a `Map`, else `false`.
*
* @example
* const value1 = new Map();
* const value2 = new Set();
* const value3 = new WeakMap();
*
* console.log(isMap(value1)); // true
* console.log(isMap(value2)); // false
* console.log(isMap(value3)); // false
*/
declare function isMap(value?: any): value is Map<any, any>;
//#endregion
export { isMap };

View file

@ -0,0 +1,21 @@
//#region src/compat/predicate/isMap.d.ts
/**
* Checks if a given value is `Map`.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Map`.
*
* @param value The value to check if it is a `Map`.
* @returns Returns `true` if `value` is a `Map`, else `false`.
*
* @example
* const value1 = new Map();
* const value2 = new Set();
* const value3 = new WeakMap();
*
* console.log(isMap(value1)); // true
* console.log(isMap(value2)); // false
* console.log(isMap(value3)); // false
*/
declare function isMap(value?: any): value is Map<any, any>;
//#endregion
export { isMap };

View file

@ -0,0 +1,24 @@
const require_isMap = require("../../predicate/isMap.js");
//#region src/compat/predicate/isMap.ts
/**
* Checks if a given value is `Map`.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Map`.
*
* @param value The value to check if it is a `Map`.
* @returns Returns `true` if `value` is a `Map`, else `false`.
*
* @example
* const value1 = new Map();
* const value2 = new Set();
* const value3 = new WeakMap();
*
* console.log(isMap(value1)); // true
* console.log(isMap(value2)); // false
* console.log(isMap(value3)); // false
*/
function isMap(value) {
return require_isMap.isMap(value);
}
//#endregion
exports.isMap = isMap;

View file

@ -0,0 +1,24 @@
import { isMap as isMap$1 } from "../../predicate/isMap.mjs";
//#region src/compat/predicate/isMap.ts
/**
* Checks if a given value is `Map`.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Map`.
*
* @param value The value to check if it is a `Map`.
* @returns Returns `true` if `value` is a `Map`, else `false`.
*
* @example
* const value1 = new Map();
* const value2 = new Set();
* const value3 = new WeakMap();
*
* console.log(isMap(value1)); // true
* console.log(isMap(value2)); // false
* console.log(isMap(value3)); // false
*/
function isMap(value) {
return isMap$1(value);
}
//#endregion
export { isMap };

View file

@ -0,0 +1,32 @@
//#region src/compat/predicate/isMatch.d.ts
/**
* Checks if the target matches the source by comparing their structures and values.
* This function supports deep comparison for objects, arrays, maps, and sets.
*
* @param target - The target value to match against.
* @param source - The source value to match with.
* @returns Returns `true` if the target matches the source, otherwise `false`.
*
* @example
* // Basic usage
* isMatch({ a: 1, b: 2 }, { a: 1 }); // true
*
* @example
* // Matching arrays
* isMatch([1, 2, 3], [1, 2, 3]); // true
*
* @example
* // Matching maps
* const targetMap = new Map([['key1', 'value1'], ['key2', 'value2']]);
* const sourceMap = new Map([['key1', 'value1']]);
* isMatch(targetMap, sourceMap); // true
*
* @example
* // Matching sets
* const targetSet = new Set([1, 2, 3]);
* const sourceSet = new Set([1, 2]);
* isMatch(targetSet, sourceSet); // true
*/
declare function isMatch(target: object, source: object): boolean;
//#endregion
export { isMatch };

View file

@ -0,0 +1,32 @@
//#region src/compat/predicate/isMatch.d.ts
/**
* Checks if the target matches the source by comparing their structures and values.
* This function supports deep comparison for objects, arrays, maps, and sets.
*
* @param target - The target value to match against.
* @param source - The source value to match with.
* @returns Returns `true` if the target matches the source, otherwise `false`.
*
* @example
* // Basic usage
* isMatch({ a: 1, b: 2 }, { a: 1 }); // true
*
* @example
* // Matching arrays
* isMatch([1, 2, 3], [1, 2, 3]); // true
*
* @example
* // Matching maps
* const targetMap = new Map([['key1', 'value1'], ['key2', 'value2']]);
* const sourceMap = new Map([['key1', 'value1']]);
* isMatch(targetMap, sourceMap); // true
*
* @example
* // Matching sets
* const targetSet = new Set([1, 2, 3]);
* const sourceSet = new Set([1, 2]);
* isMatch(targetSet, sourceSet); // true
*/
declare function isMatch(target: object, source: object): boolean;
//#endregion
export { isMatch };

View file

@ -0,0 +1,35 @@
const require_isMatchWith = require("./isMatchWith.js");
//#region src/compat/predicate/isMatch.ts
/**
* Checks if the target matches the source by comparing their structures and values.
* This function supports deep comparison for objects, arrays, maps, and sets.
*
* @param target - The target value to match against.
* @param source - The source value to match with.
* @returns Returns `true` if the target matches the source, otherwise `false`.
*
* @example
* // Basic usage
* isMatch({ a: 1, b: 2 }, { a: 1 }); // true
*
* @example
* // Matching arrays
* isMatch([1, 2, 3], [1, 2, 3]); // true
*
* @example
* // Matching maps
* const targetMap = new Map([['key1', 'value1'], ['key2', 'value2']]);
* const sourceMap = new Map([['key1', 'value1']]);
* isMatch(targetMap, sourceMap); // true
*
* @example
* // Matching sets
* const targetSet = new Set([1, 2, 3]);
* const sourceSet = new Set([1, 2]);
* isMatch(targetSet, sourceSet); // true
*/
function isMatch(target, source) {
return require_isMatchWith.isMatchWith(target, source, () => void 0);
}
//#endregion
exports.isMatch = isMatch;

View file

@ -0,0 +1,35 @@
import { isMatchWith } from "./isMatchWith.mjs";
//#region src/compat/predicate/isMatch.ts
/**
* Checks if the target matches the source by comparing their structures and values.
* This function supports deep comparison for objects, arrays, maps, and sets.
*
* @param target - The target value to match against.
* @param source - The source value to match with.
* @returns Returns `true` if the target matches the source, otherwise `false`.
*
* @example
* // Basic usage
* isMatch({ a: 1, b: 2 }, { a: 1 }); // true
*
* @example
* // Matching arrays
* isMatch([1, 2, 3], [1, 2, 3]); // true
*
* @example
* // Matching maps
* const targetMap = new Map([['key1', 'value1'], ['key2', 'value2']]);
* const sourceMap = new Map([['key1', 'value1']]);
* isMatch(targetMap, sourceMap); // true
*
* @example
* // Matching sets
* const targetSet = new Set([1, 2, 3]);
* const sourceSet = new Set([1, 2]);
* isMatch(targetSet, sourceSet); // true
*/
function isMatch(target, source) {
return isMatchWith(target, source, () => void 0);
}
//#endregion
export { isMatch };

View file

@ -0,0 +1,31 @@
import { IsMatchWithCustomizer } from "../_internal/IsMatchWithCustomizer.mjs";
//#region src/compat/predicate/isMatchWith.d.ts
/**
* Performs a deep comparison between a target value and a source pattern to determine if they match,
* using a custom comparison function for fine-grained control over the matching logic.
*
* @param target - The value to be tested for matching
* @param source - The pattern/template to match against
* @param compare - Custom comparison function for fine-grained control
* @returns `true` if the target matches the source pattern, `false` otherwise
*
* @example
* // Basic matching with custom comparator
* const caseInsensitiveCompare = (objVal, srcVal) => {
* if (typeof objVal === 'string' && typeof srcVal === 'string') {
* return objVal.toLowerCase() === srcVal.toLowerCase();
* }
* return undefined;
* };
*
* isMatchWith(
* { name: 'JOHN', age: 30 },
* { name: 'john' },
* caseInsensitiveCompare
* ); // true
*/
declare function isMatchWith(target: object, source: object, compare: IsMatchWithCustomizer): boolean;
declare function isSetMatch(target: unknown, source: Set<any>, compare: (objValue: any, srcValue: any, key: PropertyKey, object: any, source: any, stack?: Map<any, any>) => boolean | undefined, stack?: Map<any, any>): boolean;
//#endregion
export { isMatchWith };

View file

@ -0,0 +1,31 @@
import { IsMatchWithCustomizer } from "../_internal/IsMatchWithCustomizer.js";
//#region src/compat/predicate/isMatchWith.d.ts
/**
* Performs a deep comparison between a target value and a source pattern to determine if they match,
* using a custom comparison function for fine-grained control over the matching logic.
*
* @param target - The value to be tested for matching
* @param source - The pattern/template to match against
* @param compare - Custom comparison function for fine-grained control
* @returns `true` if the target matches the source pattern, `false` otherwise
*
* @example
* // Basic matching with custom comparator
* const caseInsensitiveCompare = (objVal, srcVal) => {
* if (typeof objVal === 'string' && typeof srcVal === 'string') {
* return objVal.toLowerCase() === srcVal.toLowerCase();
* }
* return undefined;
* };
*
* isMatchWith(
* { name: 'JOHN', age: 30 },
* { name: 'john' },
* caseInsensitiveCompare
* ); // true
*/
declare function isMatchWith(target: object, source: object, compare: IsMatchWithCustomizer): boolean;
declare function isSetMatch(target: unknown, source: Set<any>, compare: (objValue: any, srcValue: any, key: PropertyKey, object: any, source: any, stack?: Map<any, any>) => boolean | undefined, stack?: Map<any, any>): boolean;
//#endregion
export { isMatchWith };

View file

@ -0,0 +1,156 @@
const require_isPrimitive = require("../../predicate/isPrimitive.js");
const require_isEqualsSameValueZero = require("../../_internal/isEqualsSameValueZero.js");
require("../util/eq.js");
const require_isObject = require("./isObject.js");
//#region src/compat/predicate/isMatchWith.ts
/**
* Performs a deep comparison between a target value and a source pattern to determine if they match,
* using a custom comparison function for fine-grained control over the matching logic.
*
* This function recursively traverses both values, calling the custom compare function for each
* property/element pair. If the compare function returns a boolean, that result is used directly.
* If it returns undefined, the default matching behavior continues recursively.
*
* The matching behavior varies by data type:
* - **Objects**: Matches if all properties in the source exist in the target and match
* - **Arrays**: Matches if all elements in the source array can be found in the target array (order-independent)
* - **Maps**: Matches if all key-value pairs in the source Map exist and match in the target Map
* - **Sets**: Matches if all elements in the source Set can be found in the target Set
* - **Functions**: Matches using strict equality, or object comparison if the function has properties
* - **Primitives**: Matches using strict equality
*
* Special cases:
* - Empty objects, arrays, Maps, and Sets always match any target
* - `null` and `undefined` source values have specific matching rules
* - Circular references are handled using an internal stack to prevent infinite recursion
*
* @param target - The value to be tested for matching
* @param source - The pattern/template to match against
* @param [compare] - Optional custom comparison function that receives:
* - `objValue` - The value from the target at the current path
* - `srcValue` - The value from the source at the current path
* - `key` - The property key or array index being compared
* - `object` - The parent object/array from the target
* - `source` - The parent object/array from the source
* - `stack` - Internal Map used for circular reference detection
* Should return `true` for a match, `false` for no match, or `undefined` to continue with default behavior
*
* @returns `true` if the target matches the source pattern, `false` otherwise
*
* @example
* // Basic matching without custom comparator
* isMatchWith({ a: 1, b: 2 }, { a: 1 }); // true
* isMatchWith([1, 2, 3], [1, 3]); // true
*
* @example
* // Custom comparison for case-insensitive string matching
* const caseInsensitiveCompare = (objVal, srcVal) => {
* if (typeof objVal === 'string' && typeof srcVal === 'string') {
* return objVal.toLowerCase() === srcVal.toLowerCase();
* }
* return undefined; // Use default behavior for non-strings
* };
*
* isMatchWith(
* { name: 'JOHN', age: 30 },
* { name: 'john' },
* caseInsensitiveCompare
* ); // true
*
* @example
* // Custom comparison for range matching
* const rangeCompare = (objVal, srcVal, key) => {
* if (key === 'age' && typeof srcVal === 'object' && srcVal.min !== undefined) {
* return objVal >= srcVal.min && objVal <= srcVal.max;
* }
* return undefined;
* };
*
* isMatchWith(
* { name: 'John', age: 25 },
* { age: { min: 18, max: 30 } },
* rangeCompare
* ); // true
*/
function isMatchWith(target, source, compare) {
if (typeof compare !== "function") return isMatchWith(target, source, () => void 0);
return isMatchWithInternal(target, source, function doesMatch(objValue, srcValue, key, object, source, stack) {
const isEqual = compare(objValue, srcValue, key, object, source, stack);
if (isEqual !== void 0) return Boolean(isEqual);
return isMatchWithInternal(objValue, srcValue, doesMatch, stack, false);
}, /* @__PURE__ */ new Map(), true);
}
function isMatchWithInternal(target, source, compare, stack, isRoot = false) {
if (source === target) return true;
switch (typeof source) {
case "object": return isObjectMatch(target, source, compare, stack);
case "function":
if (Object.keys(source).length > 0) return isMatchWithInternal(target, { ...source }, compare, stack, isRoot);
return require_isEqualsSameValueZero.isEqualsSameValueZero(target, source);
default:
if (!require_isObject.isObject(target)) return require_isEqualsSameValueZero.isEqualsSameValueZero(target, source);
if (isRoot) {
if (typeof source === "string") return source === "";
return true;
}
return require_isEqualsSameValueZero.isEqualsSameValueZero(target, source);
}
}
function isObjectMatch(target, source, compare, stack) {
if (source == null) return true;
if (Array.isArray(source)) return isArrayMatch(target, source, compare, stack);
if (source instanceof Map) return isMapMatch(target, source, compare, stack);
if (source instanceof Set) return isSetMatch(target, source, compare, stack);
const keys = Object.keys(source);
if (target == null || require_isPrimitive.isPrimitive(target)) return keys.length === 0;
if (keys.length === 0) return true;
if (stack?.has(source)) return stack.get(source) === target;
stack?.set(source, target);
try {
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
if (!require_isPrimitive.isPrimitive(target) && !(key in target)) return false;
if (source[key] === void 0 && target[key] !== void 0) return false;
if (source[key] === null && target[key] !== null) return false;
if (!compare(target[key], source[key], key, target, source, stack)) return false;
}
return true;
} finally {
stack?.delete(source);
}
}
function isMapMatch(target, source, compare, stack) {
if (source.size === 0) return true;
if (!(target instanceof Map)) return false;
for (const [key, sourceValue] of source.entries()) if (compare(target.get(key), sourceValue, key, target, source, stack) === false) return false;
return true;
}
function isArrayMatch(target, source, compare, stack) {
if (source.length === 0) return true;
if (!Array.isArray(target)) return false;
const countedIndex = /* @__PURE__ */ new Set();
for (let i = 0; i < source.length; i++) {
const sourceItem = source[i];
let found = false;
for (let j = 0; j < target.length; j++) {
if (countedIndex.has(j)) continue;
const targetItem = target[j];
let matches = false;
if (compare(targetItem, sourceItem, i, target, source, stack)) matches = true;
if (matches) {
countedIndex.add(j);
found = true;
break;
}
}
if (!found) return false;
}
return true;
}
function isSetMatch(target, source, compare, stack) {
if (source.size === 0) return true;
if (!(target instanceof Set)) return false;
return isArrayMatch([...target], [...source], compare, stack);
}
//#endregion
exports.isMatchWith = isMatchWith;

View file

@ -0,0 +1,156 @@
import { isPrimitive } from "../../predicate/isPrimitive.mjs";
import { isEqualsSameValueZero } from "../../_internal/isEqualsSameValueZero.mjs";
import "../util/eq.mjs";
import { isObject } from "./isObject.mjs";
//#region src/compat/predicate/isMatchWith.ts
/**
* Performs a deep comparison between a target value and a source pattern to determine if they match,
* using a custom comparison function for fine-grained control over the matching logic.
*
* This function recursively traverses both values, calling the custom compare function for each
* property/element pair. If the compare function returns a boolean, that result is used directly.
* If it returns undefined, the default matching behavior continues recursively.
*
* The matching behavior varies by data type:
* - **Objects**: Matches if all properties in the source exist in the target and match
* - **Arrays**: Matches if all elements in the source array can be found in the target array (order-independent)
* - **Maps**: Matches if all key-value pairs in the source Map exist and match in the target Map
* - **Sets**: Matches if all elements in the source Set can be found in the target Set
* - **Functions**: Matches using strict equality, or object comparison if the function has properties
* - **Primitives**: Matches using strict equality
*
* Special cases:
* - Empty objects, arrays, Maps, and Sets always match any target
* - `null` and `undefined` source values have specific matching rules
* - Circular references are handled using an internal stack to prevent infinite recursion
*
* @param target - The value to be tested for matching
* @param source - The pattern/template to match against
* @param [compare] - Optional custom comparison function that receives:
* - `objValue` - The value from the target at the current path
* - `srcValue` - The value from the source at the current path
* - `key` - The property key or array index being compared
* - `object` - The parent object/array from the target
* - `source` - The parent object/array from the source
* - `stack` - Internal Map used for circular reference detection
* Should return `true` for a match, `false` for no match, or `undefined` to continue with default behavior
*
* @returns `true` if the target matches the source pattern, `false` otherwise
*
* @example
* // Basic matching without custom comparator
* isMatchWith({ a: 1, b: 2 }, { a: 1 }); // true
* isMatchWith([1, 2, 3], [1, 3]); // true
*
* @example
* // Custom comparison for case-insensitive string matching
* const caseInsensitiveCompare = (objVal, srcVal) => {
* if (typeof objVal === 'string' && typeof srcVal === 'string') {
* return objVal.toLowerCase() === srcVal.toLowerCase();
* }
* return undefined; // Use default behavior for non-strings
* };
*
* isMatchWith(
* { name: 'JOHN', age: 30 },
* { name: 'john' },
* caseInsensitiveCompare
* ); // true
*
* @example
* // Custom comparison for range matching
* const rangeCompare = (objVal, srcVal, key) => {
* if (key === 'age' && typeof srcVal === 'object' && srcVal.min !== undefined) {
* return objVal >= srcVal.min && objVal <= srcVal.max;
* }
* return undefined;
* };
*
* isMatchWith(
* { name: 'John', age: 25 },
* { age: { min: 18, max: 30 } },
* rangeCompare
* ); // true
*/
function isMatchWith(target, source, compare) {
if (typeof compare !== "function") return isMatchWith(target, source, () => void 0);
return isMatchWithInternal(target, source, function doesMatch(objValue, srcValue, key, object, source, stack) {
const isEqual = compare(objValue, srcValue, key, object, source, stack);
if (isEqual !== void 0) return Boolean(isEqual);
return isMatchWithInternal(objValue, srcValue, doesMatch, stack, false);
}, /* @__PURE__ */ new Map(), true);
}
function isMatchWithInternal(target, source, compare, stack, isRoot = false) {
if (source === target) return true;
switch (typeof source) {
case "object": return isObjectMatch(target, source, compare, stack);
case "function":
if (Object.keys(source).length > 0) return isMatchWithInternal(target, { ...source }, compare, stack, isRoot);
return isEqualsSameValueZero(target, source);
default:
if (!isObject(target)) return isEqualsSameValueZero(target, source);
if (isRoot) {
if (typeof source === "string") return source === "";
return true;
}
return isEqualsSameValueZero(target, source);
}
}
function isObjectMatch(target, source, compare, stack) {
if (source == null) return true;
if (Array.isArray(source)) return isArrayMatch(target, source, compare, stack);
if (source instanceof Map) return isMapMatch(target, source, compare, stack);
if (source instanceof Set) return isSetMatch(target, source, compare, stack);
const keys = Object.keys(source);
if (target == null || isPrimitive(target)) return keys.length === 0;
if (keys.length === 0) return true;
if (stack?.has(source)) return stack.get(source) === target;
stack?.set(source, target);
try {
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
if (!isPrimitive(target) && !(key in target)) return false;
if (source[key] === void 0 && target[key] !== void 0) return false;
if (source[key] === null && target[key] !== null) return false;
if (!compare(target[key], source[key], key, target, source, stack)) return false;
}
return true;
} finally {
stack?.delete(source);
}
}
function isMapMatch(target, source, compare, stack) {
if (source.size === 0) return true;
if (!(target instanceof Map)) return false;
for (const [key, sourceValue] of source.entries()) if (compare(target.get(key), sourceValue, key, target, source, stack) === false) return false;
return true;
}
function isArrayMatch(target, source, compare, stack) {
if (source.length === 0) return true;
if (!Array.isArray(target)) return false;
const countedIndex = /* @__PURE__ */ new Set();
for (let i = 0; i < source.length; i++) {
const sourceItem = source[i];
let found = false;
for (let j = 0; j < target.length; j++) {
if (countedIndex.has(j)) continue;
const targetItem = target[j];
let matches = false;
if (compare(targetItem, sourceItem, i, target, source, stack)) matches = true;
if (matches) {
countedIndex.add(j);
found = true;
break;
}
}
if (!found) return false;
}
return true;
}
function isSetMatch(target, source, compare, stack) {
if (source.size === 0) return true;
if (!(target instanceof Set)) return false;
return isArrayMatch([...target], [...source], compare, stack);
}
//#endregion
export { isMatchWith };

View file

@ -0,0 +1,16 @@
//#region src/compat/predicate/isNaN.d.ts
/**
* Checks if the value is NaN.
*
* @param value - The value to check.
* @returns `true` if the value is NaN, `false` otherwise.
*
* @example
* isNaN(NaN); // true
* isNaN(0); // false
* isNaN('NaN'); // false
* isNaN(undefined); // false
*/
declare function isNaN(value?: any): boolean;
//#endregion
export { isNaN };

View file

@ -0,0 +1,16 @@
//#region src/compat/predicate/isNaN.d.ts
/**
* Checks if the value is NaN.
*
* @param value - The value to check.
* @returns `true` if the value is NaN, `false` otherwise.
*
* @example
* isNaN(NaN); // true
* isNaN(0); // false
* isNaN('NaN'); // false
* isNaN(undefined); // false
*/
declare function isNaN(value?: any): boolean;
//#endregion
export { isNaN };

View file

@ -0,0 +1,19 @@
const require_isNumber = require("./isNumber.js");
//#region src/compat/predicate/isNaN.ts
/**
* Checks if the value is NaN.
*
* @param value - The value to check.
* @returns `true` if the value is NaN, `false` otherwise.
*
* @example
* isNaN(NaN); // true
* isNaN(0); // false
* isNaN('NaN'); // false
* isNaN(undefined); // false
*/
function isNaN(value) {
return require_isNumber.isNumber(value) && Number.isNaN(Number(value));
}
//#endregion
exports.isNaN = isNaN;

View file

@ -0,0 +1,19 @@
import { isNumber } from "./isNumber.mjs";
//#region src/compat/predicate/isNaN.ts
/**
* Checks if the value is NaN.
*
* @param value - The value to check.
* @returns `true` if the value is NaN, `false` otherwise.
*
* @example
* isNaN(NaN); // true
* isNaN(0); // false
* isNaN('NaN'); // false
* isNaN(undefined); // false
*/
function isNaN(value) {
return isNumber(value) && Number.isNaN(Number(value));
}
//#endregion
export { isNaN };

View file

@ -0,0 +1,19 @@
//#region src/compat/predicate/isNative.d.ts
/**
* Checks if a given value is a native function.
*
* This function tests whether the provided value is a native function implemented by the JavaScript engine.
* It returns `true` if the value is a native function, and `false` otherwise.
*
* @param value - The value to test for native function.
* @returns `true` if the value is a native function, `false` otherwise.
*
* @example
* const value1 = Array.prototype.push;
* const value2 = () => {};
* const result1 = isNative(value1); // true
* const result2 = isNative(value2); // false
*/
declare function isNative(value: any): value is (...args: any[]) => any;
//#endregion
export { isNative };

View file

@ -0,0 +1,19 @@
//#region src/compat/predicate/isNative.d.ts
/**
* Checks if a given value is a native function.
*
* This function tests whether the provided value is a native function implemented by the JavaScript engine.
* It returns `true` if the value is a native function, and `false` otherwise.
*
* @param value - The value to test for native function.
* @returns `true` if the value is a native function, `false` otherwise.
*
* @example
* const value1 = Array.prototype.push;
* const value2 = () => {};
* const result1 = isNative(value1); // true
* const result2 = isNative(value2); // false
*/
declare function isNative(value: any): value is (...args: any[]) => any;
//#endregion
export { isNative };

View file

@ -0,0 +1,26 @@
//#region src/compat/predicate/isNative.ts
const functionToString = Function.prototype.toString;
/** Used to detect if a method is native. */
const IS_NATIVE_FUNCTION_REGEXP = RegExp(`^${functionToString.call(Object.prototype.hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?")}$`);
/**
* Checks if a given value is a native function.
*
* This function tests whether the provided value is a native function implemented by the JavaScript engine.
* It returns `true` if the value is a native function, and `false` otherwise.
*
* @param value - The value to test for native function.
* @returns `true` if the value is a native function, `false` otherwise.
*
* @example
* const value1 = Array.prototype.push;
* const value2 = () => {};
* const result1 = isNative(value1); // true
* const result2 = isNative(value2); // false
*/
function isNative(value) {
if (typeof value !== "function") return false;
if (globalThis?.["__core-js_shared__"] != null) throw new Error("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");
return IS_NATIVE_FUNCTION_REGEXP.test(functionToString.call(value));
}
//#endregion
exports.isNative = isNative;

View file

@ -0,0 +1,26 @@
//#region src/compat/predicate/isNative.ts
const functionToString = Function.prototype.toString;
/** Used to detect if a method is native. */
const IS_NATIVE_FUNCTION_REGEXP = RegExp(`^${functionToString.call(Object.prototype.hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?")}$`);
/**
* Checks if a given value is a native function.
*
* This function tests whether the provided value is a native function implemented by the JavaScript engine.
* It returns `true` if the value is a native function, and `false` otherwise.
*
* @param value - The value to test for native function.
* @returns `true` if the value is a native function, `false` otherwise.
*
* @example
* const value1 = Array.prototype.push;
* const value2 = () => {};
* const result1 = isNative(value1); // true
* const result2 = isNative(value2); // false
*/
function isNative(value) {
if (typeof value !== "function") return false;
if (globalThis?.["__core-js_shared__"] != null) throw new Error("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");
return IS_NATIVE_FUNCTION_REGEXP.test(functionToString.call(value));
}
//#endregion
export { isNative };

View file

@ -0,0 +1,23 @@
//#region src/compat/predicate/isNil.d.ts
/**
* Checks if a given value is null or undefined.
*
* This function tests whether the provided value is either `null` or `undefined`.
* It returns `true` if the value is `null` or `undefined`, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.
*
* @param x - The value to test for null or undefined.
* @returns `true` if the value is null or undefined, `false` otherwise.
*
* @example
* const value1 = null;
* const value2 = undefined;
* const value3 = 42;
* const result1 = isNil(value1); // true
* const result2 = isNil(value2); // true
* const result3 = isNil(value3); // false
*/
declare function isNil(x: any): x is null | undefined;
//#endregion
export { isNil };

View file

@ -0,0 +1,23 @@
//#region src/compat/predicate/isNil.d.ts
/**
* Checks if a given value is null or undefined.
*
* This function tests whether the provided value is either `null` or `undefined`.
* It returns `true` if the value is `null` or `undefined`, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.
*
* @param x - The value to test for null or undefined.
* @returns `true` if the value is null or undefined, `false` otherwise.
*
* @example
* const value1 = null;
* const value2 = undefined;
* const value3 = 42;
* const result1 = isNil(value1); // true
* const result2 = isNil(value2); // true
* const result3 = isNil(value3); // false
*/
declare function isNil(x: any): x is null | undefined;
//#endregion
export { isNil };

View file

@ -0,0 +1,25 @@
//#region src/compat/predicate/isNil.ts
/**
* Checks if a given value is null or undefined.
*
* This function tests whether the provided value is either `null` or `undefined`.
* It returns `true` if the value is `null` or `undefined`, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.
*
* @param x - The value to test for null or undefined.
* @returns `true` if the value is null or undefined, `false` otherwise.
*
* @example
* const value1 = null;
* const value2 = undefined;
* const value3 = 42;
* const result1 = isNil(value1); // true
* const result2 = isNil(value2); // true
* const result3 = isNil(value3); // false
*/
function isNil(x) {
return x == null;
}
//#endregion
exports.isNil = isNil;

View file

@ -0,0 +1,25 @@
//#region src/compat/predicate/isNil.ts
/**
* Checks if a given value is null or undefined.
*
* This function tests whether the provided value is either `null` or `undefined`.
* It returns `true` if the value is `null` or `undefined`, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.
*
* @param x - The value to test for null or undefined.
* @returns `true` if the value is null or undefined, `false` otherwise.
*
* @example
* const value1 = null;
* const value2 = undefined;
* const value3 = 42;
* const result1 = isNil(value1); // true
* const result2 = isNil(value2); // true
* const result3 = isNil(value3); // false
*/
function isNil(x) {
return x == null;
}
//#endregion
export { isNil };

View file

@ -0,0 +1,15 @@
//#region src/compat/predicate/isNull.d.ts
/**
* Checks if `value` is `null`.
*
* @param value - The value to check.
* @returns Returns `true` if `value` is `null`, else `false`.
*
* @example
* isNull(null); // true
* isNull(undefined); // false
* isNull(0); // false
*/
declare function isNull(value: any): value is null;
//#endregion
export { isNull };

View file

@ -0,0 +1,15 @@
//#region src/compat/predicate/isNull.d.ts
/**
* Checks if `value` is `null`.
*
* @param value - The value to check.
* @returns Returns `true` if `value` is `null`, else `false`.
*
* @example
* isNull(null); // true
* isNull(undefined); // false
* isNull(0); // false
*/
declare function isNull(value: any): value is null;
//#endregion
export { isNull };

View file

@ -0,0 +1,17 @@
//#region src/compat/predicate/isNull.ts
/**
* Checks if `value` is `null`.
*
* @param value - The value to check.
* @returns Returns `true` if `value` is `null`, else `false`.
*
* @example
* isNull(null); // true
* isNull(undefined); // false
* isNull(0); // false
*/
function isNull(value) {
return value === null;
}
//#endregion
exports.isNull = isNull;

View file

@ -0,0 +1,17 @@
//#region src/compat/predicate/isNull.ts
/**
* Checks if `value` is `null`.
*
* @param value - The value to check.
* @returns Returns `true` if `value` is `null`, else `false`.
*
* @example
* isNull(null); // true
* isNull(undefined); // false
* isNull(0); // false
*/
function isNull(value) {
return value === null;
}
//#endregion
export { isNull };

Some files were not shown because too many files have changed in this diff Show more