Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • LoDashStatic

Index

Methods

castArray

  • castArray<T>(value?: Many<T>): T[]
  • Casts value as an array if it’s not one.

    Type parameters

    • T

    Parameters

    • Optional value: Many<T>

      The value to inspect.

    Returns T[]

    Returns the cast array.

clone

  • clone<T>(value: T): T
  • Creates a shallow clone of value.

    Note: This method is loosely based on the structured clone algorithm and supports cloning arrays, array buffers, booleans, date objects, maps, numbers, Object objects, regexes, sets, strings, symbols, and typed arrays. The own enumerable properties of arguments objects are cloned as plain objects. An empty object is returned for uncloneable values such as error objects, functions, DOM nodes, and WeakMaps.

    Type parameters

    • T

    Parameters

    • value: T

      The value to clone.

    Returns T

    Returns the cloned value.

cloneDeep

  • cloneDeep<T>(value: T): T
  • This method is like _.clone except that it recursively clones value.

    Type parameters

    • T

    Parameters

    • value: T

      The value to recursively clone.

    Returns T

    Returns the deep cloned value.

cloneDeepWith

  • This method is like _.cloneWith except that it recursively clones value.

    Type parameters

    • T

    Parameters

    • value: T

      The value to recursively clone.

    • customizer: CloneDeepWithCustomizer<T>

      The function to customize cloning.

    Returns any

    Returns the deep cloned value.

  • see

    _.cloneDeepWith

    Type parameters

    • T

    Parameters

    • value: T

    Returns T

cloneWith

  • cloneWith<T, TResult>(value: T, customizer: CloneWithCustomizer<T, TResult>): TResult
  • cloneWith<T, TResult>(value: T, customizer: CloneWithCustomizer<T, TResult | undefined>): TResult | T
  • cloneWith<T>(value: T): T
  • This method is like _.clone except that it accepts customizer which is invoked to produce the cloned value. If customizer returns undefined cloning is handled by the method instead.

    Type parameters

    • T

    • TResult: object | string | number | boolean | null

    Parameters

    • value: T

      The value to clone.

    • customizer: CloneWithCustomizer<T, TResult>

      The function to customize cloning.

    Returns TResult

    Returns the cloned value.

  • see

    _.cloneWith

    Type parameters

    • T

    • TResult

    Parameters

    Returns TResult | T

  • see

    _.cloneWith

    Type parameters

    • T

    Parameters

    • value: T

    Returns T

conformsTo

  • 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.

    Type parameters

    • T

    Parameters

    Returns boolean

eq

  • eq(value: any, other: any): boolean
  • Performs a SameValueZero comparison between two values to determine if they are equivalent.

    category

    Lang

    example

    var object = { 'user': 'fred' }; var other = { 'user': 'fred' };

    _.eq(object, object); // => true

    _.eq(object, other); // => false

    _.eq('a', 'a'); // => true

    _.eq('a', Object('a')); // => false

    _.eq(NaN, NaN); // => true

    Parameters

    • value: any

      The value to compare.

    • other: any

      The other value to compare.

    Returns boolean

    Returns true if the values are equivalent, else false.

gt

  • gt(value: any, other: any): boolean
  • Checks if value is greater than other.

    Parameters

    • value: any

      The value to compare.

    • other: any

      The other value to compare.

    Returns boolean

    Returns true if value is greater than other, else false.

gte

  • gte(value: any, other: any): boolean
  • Checks if value is greater than or equal to other.

    Parameters

    • value: any

      The value to compare.

    • other: any

      The other value to compare.

    Returns boolean

    Returns true if value is greater than or equal to other, else false.

isArguments

  • isArguments(value?: any): boolean
  • Checks if value is classified as an arguments object.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is correctly classified, else false.

isArray

  • isArray(value?: any): boolean
  • isArray<T>(value?: any): boolean
  • Checks if value is classified as an Array object.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is correctly classified, else false.

  • DEPRECATED

    Type parameters

    • T

    Parameters

    • Optional value: any

    Returns boolean

isArrayBuffer

  • isArrayBuffer(value?: any): boolean
  • Checks if value is classified as an ArrayBuffer object.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is correctly classified, else false.

isArrayLike

  • isArrayLike<T>(value: T & string & number): boolean
  • isArrayLike(value: function | null | undefined): boolean
  • isArrayLike(value: any): boolean
  • Checks if value is array-like. A value is considered array-like if it's not a function and has a value.length that's an integer greater than or equal to 0 and less than or equal to Number.MAX_SAFE_INTEGER.

    category

    Lang

    example

    _.isArrayLike([1, 2, 3]); // => true

    _.isArrayLike(document.body.children); // => true

    _.isArrayLike('abc'); // => true

    .isArrayLike(.noop); // => false

    Type parameters

    • T

    Parameters

    • value: T & string & number

      The value to check.

    Returns boolean

    Returns true if value is array-like, else false.

  • see

    _.isArrayLike

    Parameters

    • value: function | null | undefined

    Returns boolean

  • see

    _.isArrayLike

    Parameters

    • value: any

    Returns boolean

isArrayLikeObject

  • isArrayLikeObject<T>(value: T & string & number): boolean
  • isArrayLikeObject(value: function | Function | string | boolean | number | null | undefined): boolean
  • isArrayLikeObject<T>(value: T | function | Function | string | boolean | number | null | undefined): boolean
  • This method is like _.isArrayLike except that it also checks if value is an object.

    category

    Lang

    example

    _.isArrayLikeObject([1, 2, 3]); // => true

    _.isArrayLikeObject(document.body.children); // => true

    _.isArrayLikeObject('abc'); // => false

    .isArrayLikeObject(.noop); // => false

    Type parameters

    • T

    Parameters

    • value: T & string & number

      The value to check.

    Returns boolean

    Returns true if value is an array-like object, else false.

  • see

    _.isArrayLike

    Parameters

    • value: function | Function | string | boolean | number | null | undefined

    Returns boolean

  • see

    _.isArrayLike

    Type parameters

    • T: object

    Parameters

    • value: T | function | Function | string | boolean | number | null | undefined

    Returns boolean

isBoolean

  • isBoolean(value?: any): boolean
  • Checks if value is classified as a boolean primitive or object.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is correctly classified, else false.

isBuffer

  • isBuffer(value?: any): boolean
  • Checks if value is a buffer.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is a buffer, else false.

isDate

  • isDate(value?: any): boolean
  • Checks if value is classified as a Date object.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is correctly classified, else false.

isElement

  • isElement(value?: any): boolean
  • Checks if value is a DOM element.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is a DOM element, else false.

isEmpty

  • isEmpty(value?: any): boolean
  • Checks if value is empty. A value is considered empty unless it’s an arguments object, array, string, or jQuery-like collection with a length greater than 0 or an object with own enumerable properties.

    Parameters

    • Optional value: any

      The value to inspect.

    Returns boolean

    Returns true if value is empty, else false.

isEqual

  • isEqual(value: any, other: any): boolean
  • Performs a deep comparison between two values to determine if they are equivalent.

    Note: This method supports comparing arrays, array buffers, booleans, date objects, error objects, maps, numbers, Object objects, regexes, sets, strings, symbols, and typed arrays. Object objects are compared by their own, not inherited, enumerable properties. Functions and DOM nodes are not supported.

    category

    Lang

    example

    var object = { 'user': 'fred' }; var other = { 'user': 'fred' };

    _.isEqual(object, other); // => true

    object === other; // => false

    Parameters

    • value: any

      The value to compare.

    • other: any

      The other value to compare.

    Returns boolean

    Returns true if the values are equivalent, else false.

isEqualWith

  • This method is like _.isEqual except that it accepts customizer which is invoked to compare values. If customizer returns undefined comparisons are handled by the method instead. The customizer is invoked with up to seven arguments: (objValue, othValue [, index|key, object, other, stack]).

    category

    Lang

    example

    function isGreeting(value) { return /^h(?:i|ello)$/.test(value); }

    function customizer(objValue, othValue) { if (isGreeting(objValue) && isGreeting(othValue)) { return true; } }

    var array = ['hello', 'goodbye']; var other = ['hi', 'goodbye'];

    _.isEqualWith(array, other, customizer); // => true

    Parameters

    • value: any

      The value to compare.

    • other: any

      The other value to compare.

    • Optional customizer: IsEqualCustomizer

    Returns boolean

    Returns true if the values are equivalent, else false.

isError

  • isError(value: any): boolean
  • Checks if value is an Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, or URIError object.

    Parameters

    • value: any

      The value to check.

    Returns boolean

    Returns true if value is an error object, else false.

isFinite

  • isFinite(value?: any): boolean
  • Checks if value is a finite primitive number.

    Note: This method is based on Number.isFinite.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is a finite number, else false.

isFunction

  • isFunction(value: any): boolean
  • Checks if value is a callable function.

    Parameters

    • value: any

      The value to check.

    Returns boolean

    Returns true if value is correctly classified, else false.

isInteger

  • isInteger(value?: any): boolean
  • Checks if value is an integer.

    Note: This method is based on Number.isInteger.

    category

    Lang

    example

    _.isInteger(3); // => true

    .isInteger(Number.MINVALUE); // => false

    _.isInteger(Infinity); // => false

    _.isInteger('3'); // => false

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is an integer, else false.

isLength

  • isLength(value?: any): boolean
  • Checks if value is a valid array-like length.

    Note: This function is loosely based on ToLength.

    category

    Lang

    example

    _.isLength(3); // => true

    .isLength(Number.MINVALUE); // => false

    _.isLength(Infinity); // => false

    _.isLength('3'); // => false

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is a valid length, else false.

isMap

  • isMap(value?: any): boolean
  • Checks if value is classified as a Map object.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is correctly classified, else false.

isMatch

  • isMatch(object: object, source: object): boolean
  • Performs a deep comparison between object and source to determine if object contains equivalent property values.

    Note: This method supports comparing the same values as _.isEqual.

    category

    Lang

    example

    var object = { 'user': 'fred', 'age': 40 };

    _.isMatch(object, { 'age': 40 }); // => true

    _.isMatch(object, { 'age': 36 }); // => false

    Parameters

    • object: object

      The object to inspect.

    • source: object

      The object of property values to match.

    Returns boolean

    Returns true if object is a match, else false.

isMatchWith

  • This method is like _.isMatch except that it accepts customizer which is invoked to compare values. If customizer returns undefined comparisons are handled by the method instead. The customizer is invoked with three arguments: (objValue, srcValue, index|key, object, source).

    category

    Lang

    example

    function isGreeting(value) { return /^h(?:i|ello)$/.test(value); }

    function customizer(objValue, srcValue) { if (isGreeting(objValue) && isGreeting(srcValue)) { return true; } }

    var object = { 'greeting': 'hello' }; var source = { 'greeting': 'hi' };

    _.isMatchWith(object, source, customizer); // => true

    Parameters

    • object: object

      The object to inspect.

    • source: object

      The object of property values to match.

    • customizer: isMatchWithCustomizer

    Returns boolean

    Returns true if object is a match, else false.

isNaN

  • isNaN(value?: any): boolean
  • Checks if value is NaN.

    Note: This method is not the same as isNaN which returns true for undefined and other non-numeric values.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is NaN, else false.

isNative

  • isNative(value: any): boolean
  • Checks if value is a native function.

    retrun

    Returns true if value is a native function, else false.

    Parameters

    • value: any

      The value to check.

    Returns boolean

isNil

  • isNil(value: any): boolean
  • Checks if value is null or undefined.

    category

    Lang

    example

    _.isNil(null); // => true

    _.isNil(void 0); // => true

    _.isNil(NaN); // => false

    Parameters

    • value: any

      The value to check.

    Returns boolean

    Returns true if value is nullish, else false.

isNull

  • isNull(value: any): boolean
  • Checks if value is null.

    Parameters

    • value: any

      The value to check.

    Returns boolean

    Returns true if value is null, else false.

isNumber

  • isNumber(value?: any): boolean
  • Checks if value is classified as a Number primitive or object.

    Note: To exclude Infinity, -Infinity, and NaN, which are classified as numbers, use the _.isFinite method.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is correctly classified, else false.

isObject

  • isObject(value?: any): boolean
  • Checks if value is the language type of Object. (e.g. arrays, functions, objects, regexes, new Number(0), and new String(''))

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is an object, else false.

isObjectLike

  • isObjectLike(value?: any): boolean
  • Checks if value is object-like. A value is object-like if it's not null and has a typeof result of "object".

    category

    Lang

    example

    _.isObjectLike({}); // => true

    _.isObjectLike([1, 2, 3]); // => true

    .isObjectLike(.noop); // => false

    _.isObjectLike(null); // => false

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is object-like, else false.

isPlainObject

  • isPlainObject(value?: any): boolean
  • Checks if value is a plain object, that is, an object created by the Object constructor or one with a [[Prototype]] of null.

    Note: This method assumes objects created by the Object constructor have no inherited enumerable properties.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is a plain object, else false.

isRegExp

  • isRegExp(value?: any): boolean
  • Checks if value is classified as a RegExp object.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is correctly classified, else false.

isSafeInteger

  • isSafeInteger(value: any): boolean
  • Checks if value is a safe integer. An integer is safe if it's an IEEE-754 double precision number which isn't the result of a rounded unsafe integer.

    Note: This method is based on Number.isSafeInteger.

    category

    Lang

    example

    _.isSafeInteger(3); // => true

    .isSafeInteger(Number.MINVALUE); // => false

    _.isSafeInteger(Infinity); // => false

    _.isSafeInteger('3'); // => false

    Parameters

    • value: any

      The value to check.

    Returns boolean

    Returns true if value is a safe integer, else false.

isSet

  • isSet(value?: any): boolean
  • Checks if value is classified as a Set object.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is correctly classified, else false.

isString

  • isString(value?: any): boolean
  • Checks if value is classified as a String primitive or object.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is correctly classified, else false.

isSymbol

  • isSymbol(value: any): boolean
  • Checks if value is classified as a Symbol primitive or object.

    category

    Lang

    example

    _.isSymbol(Symbol.iterator); // => true

    _.isSymbol('abc'); // => false

    Parameters

    • value: any

      The value to check.

    Returns boolean

    Returns true if value is correctly classified, else false.

isTypedArray

  • isTypedArray(value: any): boolean
  • Checks if value is classified as a typed array.

    Parameters

    • value: any

      The value to check.

    Returns boolean

    Returns true if value is correctly classified, else false.

isUndefined

  • isUndefined(value: any): boolean
  • Checks if value is undefined.

    Parameters

    • value: any

      The value to check.

    Returns boolean

    Returns true if value is undefined, else false.

isWeakMap

  • isWeakMap(value?: any): boolean
  • Checks if value is classified as a WeakMap object.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is correctly classified, else false.

isWeakSet

  • isWeakSet(value?: any): boolean
  • Checks if value is classified as a WeakSet object.

    Parameters

    • Optional value: any

      The value to check.

    Returns boolean

    Returns true if value is correctly classified, else false.

lt

  • lt(value: any, other: any): boolean
  • Checks if value is less than other.

    Parameters

    • value: any

      The value to compare.

    • other: any

      The other value to compare.

    Returns boolean

    Returns true if value is less than other, else false.

lte

  • lte(value: any, other: any): boolean
  • Checks if value is less than or equal to other.

    Parameters

    • value: any

      The value to compare.

    • other: any

      The other value to compare.

    Returns boolean

    Returns true if value is less than or equal to other, else false.

toArray

  • Converts value to an array.

    Type parameters

    • T

    Parameters

    Returns T[]

    Returns the converted array.

  • see

    _.toArray

    Type parameters

    • T

    Parameters

    • value: T

    Returns Array<T[keyof T]>

  • see

    _.toArray

    Returns any[]

toFinite

  • toFinite(value: any): number
  • Converts value to a finite number.

    since

    4.12.0

    category

    Lang

    example

    _.toFinite(3.2); // => 3.2

    .toFinite(Number.MINVALUE); // => 5e-324

    _.toFinite(Infinity); // => 1.7976931348623157e+308

    _.toFinite('3.2'); // => 3.2

    Parameters

    • value: any

      The value to convert.

    Returns number

    Returns the converted number.

toInteger

  • toInteger(value: any): number
  • Converts value to an integer.

    Note: This function is loosely based on ToInteger.

    category

    Lang

    example

    _.toInteger(3); // => 3

    .toInteger(Number.MINVALUE); // => 0

    _.toInteger(Infinity); // => 1.7976931348623157e+308

    _.toInteger('3'); // => 3

    Parameters

    • value: any

      The value to convert.

    Returns number

    Returns the converted integer.

toLength

  • toLength(value: any): number
  • Converts value to an integer suitable for use as the length of an array-like object.

    Note: This method is based on ToLength.

    category

    Lang

    example

    _.toLength(3); // => 3

    .toLength(Number.MINVALUE); // => 0

    _.toLength(Infinity); // => 4294967295

    _.toLength('3'); // => 3

    Parameters

    • value: any

      The value to convert.

    Returns number

    Returns the converted integer.

toNumber

  • toNumber(value: any): number
  • Converts value to a number.

    category

    Lang

    example

    _.toNumber(3); // => 3

    .toNumber(Number.MINVALUE); // => 5e-324

    _.toNumber(Infinity); // => Infinity

    _.toNumber('3'); // => 3

    Parameters

    • value: any

      The value to process.

    Returns number

    Returns the number.

toPlainObject

  • toPlainObject(value?: any): any
  • Converts value to a plain object flattening inherited enumerable properties of value to own properties of the plain object.

    Parameters

    • Optional value: any

      The value to convert.

    Returns any

    Returns the converted plain object.

toSafeInteger

  • toSafeInteger(value: any): number
  • Converts value to a safe integer. A safe integer can be compared and represented correctly.

    category

    Lang

    example

    _.toSafeInteger(3); // => 3

    .toSafeInteger(Number.MINVALUE); // => 0

    _.toSafeInteger(Infinity); // => 9007199254740991

    _.toSafeInteger('3'); // => 3

    Parameters

    • value: any

      The value to convert.

    Returns number

    Returns the converted integer.

toString

  • toString(value: any): string
  • Converts value to a string if it's not one. An empty string is returned for null and undefined values. The sign of -0 is preserved.

    category

    Lang

    example

    _.toString(null); // => ''

    _.toString(-0); // => '-0'

    _.toString([1, 2, 3]); // => '1,2,3'

    Parameters

    • value: any

      The value to process.

    Returns string

    Returns the string.

Generated using TypeDoc