CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-lodash-es

Lodash utility library exported as ES6 modules for modern JavaScript applications with tree-shaking support.

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

lang.mddocs/

Type Checking Functions

Comprehensive type checking utilities for validating data types, including primitives, objects, arrays, and special types.

Capabilities

Basic Type Checking

Core functions for checking primitive and common data types.

/**
 * Checks if value is classified as an Array object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is an array, else false
 */
function isArray(value);

/**
 * Checks if value is the Object language type
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is an object, else false
 */
function isObject(value);

/**
 * Checks if value is classified as a String primitive or object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a string, else false
 */
function isString(value);

/**
 * Checks if value is classified as a Number primitive or object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a number, else false
 */
function isNumber(value);

/**
 * Checks if value is classified as a boolean primitive or object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a boolean, else false
 */
function isBoolean(value);

/**
 * Checks if value is classified as a Function object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a function, else false
 */
function isFunction(value);

/**
 * Checks if value is undefined
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is undefined, else false
 */
function isUndefined(value);

/**
 * Checks if value is null
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is null, else false
 */
function isNull(value);

/**
 * Checks if value is null or undefined
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is nullish, else false
 */
function isNil(value);

/**
 * Casts value as an array if it's not one already
 * @param {*} value - The value to inspect
 * @returns {Array} Returns the cast array
 */
function castArray(value);

Number and Comparison Functions

Functions for number validation and value comparison.

/**
 * Checks if value is a finite primitive number
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a finite number, else false
 */
function isFinite(value);

/**
 * Checks if value is an integer
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is an integer, else false
 */
function isInteger(value);

/**
 * Checks if value is a valid array-like length
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a valid length, else false
 */
function isLength(value);

/**
 * Checks if value is NaN
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is NaN, else false
 */
function isNaN(value);

/**
 * Checks if value is a pristine native function
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a native function, else false
 */
function isNative(value);

/**
 * Checks if value is a safe integer
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a safe integer, else false
 */
function isSafeInteger(value);

/**
 * Checks if value is greater than other
 * @param {*} value - The value to compare
 * @param {*} other - The other value to compare
 * @returns {boolean} Returns true if value is greater than other, else false
 */
function gt(value, other);

/**
 * Checks if value is greater than or equal to other
 * @param {*} value - The value to compare
 * @param {*} other - The other value to compare
 * @returns {boolean} Returns true if value is greater than or equal to other, else false
 */
function gte(value, other);

/**
 * Checks if value is less than other
 * @param {*} value - The value to compare
 * @param {*} other - The other value to compare
 * @returns {boolean} Returns true if value is less than other, else false
 */
function lt(value, other);

/**
 * Checks if value is less than or equal to other
 * @param {*} value - The value to compare
 * @param {*} other - The other value to compare
 * @returns {boolean} Returns true if value is less than or equal to other, else false
 */
function lte(value, other);

Type Conversion Functions

Functions for converting values to different types.

/**
 * Converts value to an array
 * @param {*} value - The value to convert
 * @returns {Array} Returns the converted array
 */
function toArray(value);

/**
 * Converts value to a finite number
 * @param {*} value - The value to convert
 * @returns {number} Returns the converted number
 */
function toFinite(value);

/**
 * Converts value to an integer
 * @param {*} value - The value to convert
 * @returns {number} Returns the converted integer
 */
function toInteger(value);

/**
 * Converts value to an integer suitable for use as the length of an array-like object
 * @param {*} value - The value to convert
 * @returns {number} Returns the converted integer
 */
function toLength(value);

/**
 * Converts value to a number
 * @param {*} value - The value to convert
 * @returns {number} Returns the converted number
 */
function toNumber(value);

/**
 * Converts value to a plain object flattening inherited enumerable string keyed properties
 * @param {*} value - The value to convert
 * @returns {Object} Returns the converted plain object
 */
function toPlainObject(value);

/**
 * Converts value to a safe integer
 * @param {*} value - The value to convert
 * @returns {number} Returns the converted integer
 */
function toSafeInteger(value);

/**
 * Converts value to a string
 * @param {*} value - The value to convert
 * @returns {string} Returns the converted string
 */
function toString(value);

Object Validation

Functions for validating object properties and structure.

/**
 * Checks if object conforms to source by invoking the predicate properties of source with the corresponding property values of object
 * @param {Object} object - The object to inspect
 * @param {Object} source - The object of property predicates to conform to
 * @returns {boolean} Returns true if object conforms, else false
 */
function conformsTo(object, source);

Object Cloning

Functions for creating shallow and deep copies of values.

/**
 * Creates a shallow clone of value
 * @param {*} value - The value to clone
 * @returns {*} Returns the cloned value
 */
function clone(value);

/**
 * Creates a deep clone of value
 * @param {*} value - The value to recursively clone
 * @returns {*} Returns the deep cloned value
 */
function cloneDeep(value);

/**
 * Like clone but accepts a customizer which is invoked to produce the cloned value
 * @param {*} value - The value to clone
 * @param {Function} customizer - The function to customize cloning
 * @returns {*} Returns the cloned value
 */
function cloneWith(value, customizer);

/**
 * Like cloneDeep but accepts a customizer which is invoked to produce the cloned value
 * @param {*} value - The value to recursively clone
 * @param {Function} customizer - The function to customize cloning
 * @returns {*} Returns the deep cloned value
 */
function cloneDeepWith(value, customizer);

Specialized Type Checking

Functions for checking specific object types and browser APIs.

/**
 * Checks if value is classified as a Date object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a date object, else false
 */
function isDate(value);

/**
 * Checks if value is classified as a RegExp object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a regexp, else false
 */
function isRegExp(value);

/**
 * Checks if value is an Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, or URIError object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is an error object, else false
 */
function isError(value);

/**
 * Checks if value is likely a DOM element
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a DOM element, else false
 */
function isElement(value);

/**
 * Checks if value is classified as an arguments object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is an arguments object, else false
 */
function isArguments(value);

/**
 * Checks if value is classified as a Symbol primitive or object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a symbol, else false
 */
function isSymbol(value);

Collection and Buffer Type Checking

Functions for checking collection types and buffer objects.

/**
 * Checks if value is array-like
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is array-like, else false
 */
function isArrayLike(value);

/**
 * Checks if value is array-like and object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is an array-like object, else false
 */
function isArrayLikeObject(value);

/**
 * Checks if value is a buffer
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a buffer, else false
 */
function isBuffer(value);

/**
 * Checks if value is classified as a typed array
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a typed array, else false
 */
function isTypedArray(value);

/**
 * Checks if value is classified as an ArrayBuffer object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is an array buffer, else false
 */
function isArrayBuffer(value);

ES6 Collection Types

Functions for checking ES6 Map, Set, WeakMap, and WeakSet objects.

/**
 * Checks if value is classified as a Map object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a map, else false
 */
function isMap(value);

/**
 * Checks if value is classified as a Set object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a set, else false
 */
function isSet(value);

/**
 * Checks if value is classified as a WeakMap object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a weak map, else false
 */
function isWeakMap(value);

/**
 * Checks if value is classified as a WeakSet object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a weak set, else false
 */
function isWeakSet(value);

Object State and Content Checking

Functions for checking object properties and emptiness.

/**
 * Checks if value is an empty object, collection, map, or set
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is empty, else false
 */
function isEmpty(value);

/**
 * Checks if value is a plain object
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is a plain object, else false
 */
function isPlainObject(value);

/**
 * Checks if value is object-like
 * @param {*} value - The value to check
 * @returns {boolean} Returns true if value is object-like, else false
 */
function isObjectLike(value);

Value Comparison and Validation

Functions for deep equality checking and value matching.

/**
 * Performs a deep comparison between two values to determine if they are equivalent
 * @param {*} value - The value to compare
 * @param {*} other - The other value to compare
 * @returns {boolean} Returns true if the values are equivalent, else false
 */
function isEqual(value, other);

/**
 * Like isEqual but accepts customizer which is invoked to compare values
 * @param {*} value - The value to compare
 * @param {*} other - The other value to compare
 * @param {Function} customizer - The function to customize comparisons
 * @returns {boolean} Returns true if the values are equivalent, else false
 */
function isEqualWith(value, other, customizer);

/**
 * Performs a partial deep comparison between object and source to determine if object contains equivalent property values
 * @param {Object} object - The object to inspect
 * @param {Object} source - The object of property values to match
 * @returns {boolean} Returns true if object is a match, else false
 */
function isMatch(object, source);

/**
 * Like isMatch but accepts customizer which is invoked to compare values
 * @param {Object} object - The object to inspect
 * @param {Object} source - The object of property values to match
 * @param {Function} customizer - The function to customize comparisons
 * @returns {boolean} Returns true if object is a match, else false
 */
function isMatchWith(object, source, customizer);

/**
 * Performs SameValueZero comparison between two values to determine if they are equivalent
 * @param {*} value - The value to compare
 * @param {*} other - The other value to compare
 * @returns {boolean} Returns true if the values are equivalent, else false
 */
function eq(value, other);

Usage Examples

Basic Type Checking

import { isArray, isObject, isString, isNumber, isFunction } from "lodash-es";

// Basic type checks
console.log(isArray([1, 2, 3])); // true
console.log(isArray("hello")); // false

console.log(isObject({})); // true
console.log(isObject(null)); // false

console.log(isString("hello")); // true
console.log(isString(123)); // false

console.log(isNumber(42)); // true
console.log(isNumber("42")); // false

console.log(isFunction(() => {})); // true
console.log(isFunction({})); // false

// Basic type checking examples
const userData = { name: "Alice", age: 25 };
console.log(isObject(userData)); // true
console.log(isString(userData.name)); // true
console.log(isNumber(userData.age)); // true

Collection and Object Validation

import { isEmpty, isPlainObject, isArrayLike, isEqual } from "lodash-es";

// Check if values are empty
console.log(isEmpty([])); // true
console.log(isEmpty({})); // true
console.log(isEmpty("")); // true
console.log(isEmpty([1, 2, 3])); // false

// Check for plain objects (not class instances)
console.log(isPlainObject({})); // true
console.log(isPlainObject(new Date())); // false
console.log(isPlainObject(Object.create(null))); // true

// Check array-like objects
console.log(isArrayLike([1, 2, 3])); // true
console.log(isArrayLike("hello")); // true
console.log(isArrayLike({ 0: 'a', 1: 'b', length: 2 })); // true
console.log(isArrayLike({})); // false

// Deep equality comparison
const obj1 = { a: 1, b: { c: 2 } };
const obj2 = { a: 1, b: { c: 2 } };
const obj3 = { a: 1, b: { c: 3 } };

console.log(isEqual(obj1, obj2)); // true
console.log(isEqual(obj1, obj3)); // false
console.log(obj1 === obj2); // false (reference comparison)

Complex Validation Example

import { 
  isString, isNumber, isBoolean, isArray, 
  isEmpty
} from "lodash-es";

// Example of combining multiple type checks
const formData = {
  name: "Alice",
  age: 25,
  active: true,
  tags: ["developer", "javascript"]
};

// Validate each field
console.log(isString(formData.name) && !isEmpty(formData.name)); // true
console.log(isNumber(formData.age) && formData.age > 0); // true  
console.log(isBoolean(formData.active)); // true
console.log(isArray(formData.tags) && formData.tags.every(isString)); // true

Object Cloning Examples

import { clone, cloneDeep, cloneWith, cloneDeepWith } from "lodash-es";

// Shallow cloning
const original = { a: 1, b: { c: 2 } };
const shallowCopy = clone(original);

console.log(shallowCopy === original); // false
console.log(shallowCopy.b === original.b); // true (shallow)

// Deep cloning
const deepCopy = cloneDeep(original);
console.log(deepCopy.b === original.b); // false (deep)

// Arrays
const arr = [1, 2, [3, 4]];
const shallowArr = clone(arr);
const deepArr = cloneDeep(arr);

console.log(shallowArr[2] === arr[2]); // true (shallow)
console.log(deepArr[2] === arr[2]); // false (deep)

// Custom cloning
const customClone = cloneWith(original, (value) => {
  if (typeof value === 'number') {
    return value * 2; // Double all numbers
  }
});

// Deep custom cloning
const customDeepClone = cloneDeepWith(original, (value) => {
  if (typeof value === 'number') {
    return value * 2;
  }
});

docs

array.md

collection.md

date.md

function.md

index.md

lang.md

math.md

number.md

object.md

seq.md

string.md

util.md

tile.json