First argument to Underscore object functions.
Readonly
VERSIONCurrent version
every
Optional
iteratee: Iteratee<V, boolean, TypeOfCollection<V, never>>Optional
context: anysome
Optional
iteratee: Iteratee<V, boolean, TypeOfCollection<V, never>>Optional
context: anymap
Optional
context: anyfind
Optional
iteratee: Iteratee<V, boolean, TypeOfCollection<V, never>>Optional
context: anyrest
Optional
index: numberreduce
Optional
context: anyreduce
reduceRight
Optional
context: anyreduceRight
each
Optional
context: anyfirst
first
contains
Optional
fromIndex: numbercontains
Optional
fromIndex: numberreduce
Optional
context: anyreduce
filter
Optional
iteratee: Iteratee<V, boolean, TypeOfCollection<V, never>>Optional
context: anyrest
Optional
index: numberfirst
first
By default, Underscore uses ERB-style template delimiters, change the following template settings to use alternative delimiters.
uniq
Optional
isSorted: booleanOptional
iteratee: Iteratee<V, any, TypeOfCollection<V, never>>Optional
context: anyuniq
Optional
iteratee: Iteratee<V, any, TypeOfCollection<V, never>>Optional
context: anyCreates a version of the function that will only be run after first being called count times. Useful for grouping asynchronous responses, where you want to be sure that all the async calls have finished, before proceeding.
Copy of fn
that will not execute until it is invoked count
times.
Creates a version of the function that can be called no more than count times. The result of the last function call is memoized and returned when count has been reached.
Copy of fn
that can only be called count
times.
Bind a function to an object, meaning that whenever the function is called, the value of this will be the object. Optionally, bind arguments to the function to pre-fill them, also known as partial application.
fn
with this
bound to object
.
The function to bind this
to object
.
The this
pointer whenever fn
is called.
Rest
...args: any[]Bind a function to an object, meaning that whenever the function is called, the value of this will be the object. Optionally, bind arguments to the function to pre-fill them, also known as partial application.
fn
with this
bound to object
.
Binds a number of methods on the object, specified by methodNames, to be run in the context of that object whenever they are invoked. Very handy for binding functions that are going to be used as event handlers, which would otherwise be invoked with a fairly useless this. If no methodNames are provided, all of the object's function properties will be bound to it.
The object to bind the methods methodName
to.
Rest
...methodNames: string[]The methods to bind to object
, optional and if not provided all of object
's
methods are bound.
Returns a wrapped object. Calling methods on this object will continue to return wrapped objects until value() is used.
An underscore chain wrapper around the supplied value.
The object to chain.
Chunks list
into multiple arrays, each containing length
or
fewer items.
The contents of list
in chunks no greater than length
in size.
The list to chunk.
The maximum size of the chunks.
Returns a copy of list
with all falsy values removed. In
JavaScript, false, null, 0, "", undefined and NaN are all falsy.
An array containing the elements of list
without falsy
values.
The list to compact.
Returns the composition of a list of functions, where each function consumes the return value of the function that follows. In math terms, composing the functions f(), g(), and h() produces f(g(h())).
Composition of functions
.
Rest
...functions: Function[]List of functions to compose.
Creates a function that returns the same value that is used as the argument of _.constant
Function that return value.
Identity of this object.
Creates a function that returns the same value that is used as the argument of _.constant
Function that return value.
Returns true if the value is present in collection
. Uses indexOf
internally, if collection
is a List. Use fromIndex
to start your
search at a given index.
True if value
is present in collection
after
fromIndex
, otherwise false.
The collection to check for value
.
The value to check collection
for.
Optional
fromIndex: numberThe index to start searching from, optional,
default = 0, only used when collection
is a List.
Sorts collection
into groups and returns a count for the number of
objects in each group. Similar to groupBy
, but instead of
returning a list of values, returns a count for the number of values
in that group.
A dictionary with the group names provided by iteratee
as
properties where each property contains the count of the grouped
elements from collection
.
The collection to count.
Optional
iteratee: Iteratee<V, string | number, TypeOfCollection<V, never>>An iteratee that provides the value to count by for
each item in collection
.
Optional
context: anythis
object in iteratee
, optional.
Creates an object that inherits from the given prototype object. If additional properties are provided then they will be added to the created object.
The prototype that the returned object will inherit from.
Optional
props: objectAdditional props added to the returned object.
Creates and returns a new debounced version of the passed function that will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked. Useful for implementing behavior that should only happen after the input has stopped arriving. For example: rendering a preview of a Markdown comment, recalculating a layout after the window has stopped being resized, and so on.
Pass true for the immediate parameter to cause debounce to trigger the function on the leading instead of the trailing edge of the wait interval. Useful in circumstances like preventing accidental double -clicks on a "submit" button from firing a second time.
Debounced version of fn
that waits wait
ms when invoked.
Function to debounce waitMS
ms.
The number of milliseconds to wait before fn
can be invoked again.
Optional
immediate: booleanTrue if fn
should be invoked on the leading edge of waitMS
instead of the trailing edge.
Fill in null and undefined properties in object with values from the defaults objects, and return the object. As soon as the property is filled, further defaults will have no effect.
object
with added defaults
values.
Fill this object with default values.
Rest
...defaults: any[]The default values to add to object
.
Defers invoking the function until the current call stack has cleared, similar to using setTimeout with a delay of 0. Useful for performing expensive computations or HTML rendering in chunks without blocking the UI thread from updating. If you pass the optional arguments, they will be forwarded on to the function when it is invoked.
The function to defer.
Rest
...args: any[]Much like setTimeout, invokes function after wait milliseconds. If you pass the optional arguments, they will be forwarded on to the function when it is invoked.
Additional arguments to pass to fn
.
Function to delay waitMS
amount of ms.
The amount of milliseconds to delay fn
.
Rest
...args: any[]_delay
Rest
...args: any[]Iterates over a collection
of elements, yielding each in turn to
an iteratee
. The iteratee
is bound to the context object, if one
is passed.
The original collection.
The collection of elements to iterate over.
The iteratee to call for each element in
collection
.
Optional
context: any'this' object in iteratee
, optional.
Returns true if all of the values in collection
pass the
iteratee
truth test. Short-circuits and stops traversing
collection
if a false element is found.
True if all elements pass the truth test, otherwise false.
The collection to evaluate.
Optional
iteratee: Iteratee<V, boolean, TypeOfCollection<V, never>>The truth test to apply.
Optional
context: anythis
object in iteratee
, optional.
Copy all of the properties in the source objects over to the destination object, and return the destination object. It's in-order, so the last source will override properties of the same name in previous arguments.
destination
extended with all the properties from the sources
objects.
Object to extend all the properties from sources
.
Rest
...sources: any[]Extends destination
with all properties from these source objects.
Looks through each value in collection
, returning an array of
all the values that pass a truth test (iteratee
).
The set of values that pass the truth test.
The collection to filter.
Optional
iteratee: Iteratee<V, boolean, TypeOfCollection<V, never>>The truth test to apply.
Optional
context: anythis
object in iteratee
, optional.
Looks through each value in collection
, returning the first one
that passes a truth test (iteratee
), or undefined if no value
passes the test. The function returns as soon as it finds an
acceptable element, and doesn't traverse the entire collection.
The first element in collection
that passes the truth
test or undefined if no elements pass.
The collection to search.
Optional
iteratee: Iteratee<V, boolean, TypeOfCollection<V, never>>The truth test to apply.
Optional
context: anythis
object in iteratee
, optional.
Returns the first index of an element in list
where the iteratee
truth test passes, otherwise returns -1.
The index of the first element in list
where the
truth test passes or -1 if no elements pass.
The list to search for the index of the first element that passes the truth test.
Optional
iteratee: Iteratee<V, boolean, TypeOfCollection<V, never>>The truth test to apply.
Optional
context: anythis
object in iteratee
, optional.
Similar to findIndex
but for keys in objects. Returns the key
where the iteratee
truth test passes or undefined.
The first element in object
that passes the truth test or
undefined if no elements pass.
The object to search.
Optional
iteratee: Iteratee<V, boolean, TypeOfCollection<V, any>>The truth test to apply.
Optional
context: anythis
object in iteratee
, optional.
Returns the last index of an element in list
where the iteratee
truth test passes, otherwise returns -1.
The index of the last element in list
where the
truth test passes or -1 if no elements pass.
The list to search for the index of the last element that passes the truth test.
Optional
iteratee: Iteratee<V, boolean, TypeOfCollection<V, never>>The truth test to apply.
Optional
context: anythis
object in iteratee
, optional.
Looks through collection
and returns the first value that matches
all of the key-value pairs listed in properties
. If no match is
found, or if list is empty, undefined will be returned.
The first element in collection
that matches properties
or undefined if no match is found.
The collection in which to find an element that
matches properties
.
The properties to check for on the elements within
collection
.
Returns the first element of list
. Passing n
will return the
first n
elements of list
.
The first n
elements of list
or the first element if
n
is omitted.
The list to retrieve elements from.
Flattens a nested list
(the nesting can be to any depth). If you
pass true or 1 as the depth, the list
will only be flattened a
single level. Passing a greater number will cause the flattening to
descend deeper into the nesting hierarchy. Omitting the depth
argument, or passing false or Infinity, flattens the list
all the
way to the deepest nesting level.
The flattened list
.
The list to flatten.
True to only flatten one level, optional, default = false.
Optional
depth: number | falseReturns a sorted list of the names of every method in an object - that is to say, the name of every function property of the object.
List of all the function names on object
.
Object to pluck all function property names from.
Returns the specified property of object
. path
may be specified
as a simple key, or as an array of object keys or array indexes,
for deep property fetching. If the property does not exist or is undefined
,
the optional default is returned.
The item on the object
or the defaultValue
The object that maybe contains the property.
The path to the property on object
.
Optional
defaultValue: UOptional
defaultValue: USplits collection
into sets that are grouped by the result of
running each value through iteratee
.
A dictionary with the group names provided by iteratee
as
properties where each property contains the grouped elements from
collection
.
The collection to group.
Optional
iteratee: Iteratee<V, string | number, TypeOfCollection<V, never>>An iteratee that provides the value to group by for
each item in collection
.
Optional
context: anythis
object in iteratee
, optional.
Does the object contain the given key? Identical to object.hasOwnProperty(key), but uses a safe reference to the hasOwnProperty function, in case it's been overridden accidentally.
True if key
is a property on object
, otherwise false.
Object to check for key
.
The key to check for on object
.
Given a collection
and an iteratee
function that returns a key
for each element in collection
, returns an object that acts as an
index of each item. Just like groupBy
, but for when you know your
keys are unique.
A dictionary where each item in collection
is assigned to
the property designated by iteratee
.
The collection to index.
Optional
iteratee: Iteratee<V, string | number, TypeOfCollection<V, never>>An iteratee that provides the value to index by for
each item in collection
.
Optional
context: anythis
object in iteratee
, optional.
Returns the index at which value
can be found in list
, or -1 if
value
is not present. If you're working with a large list and you
know that the list is already sorted, pass true for
isSortedOrFromIndex
to use a faster binary search...or, pass a
number in order to look for the first matching value in the list
after the given index.
The index of the first occurrence of value
within list
or -1 if value
is not found.
The list to search for the index of value
.
The value to search for within list
.
Optional
isSortedOrFromIndex: number | booleanTrue if list
is already sorted OR the
starting index for the search, optional.
Returns everything but the last entry of list
. Especially useful
on the arguments object. Pass n
to exclude the last
n
elements from the result.
The elements of list
with the last n
items omitted.
The list to retrieve elements from.
Optional
n: numberThe number of elements from the end of list
to omit,
optional, default = 1.
Computes the list of values that are the intersection of the
passed-in lists
. Each value in the result is present in each of
the lists.
The intersection of elements within the lists
.
Rest
...lists: List<T>[]The lists to compute the intersection of.
Returns a copy of the object where the keys have become the values and the values the keys. For this to work, all of your object's values should be unique and string serializable.
An inverted key/value paired version of object
.
Object to invert key/value pairs.
Calls the method named by methodName
on each value in
collection
. Any extra arguments passed to invoke will be forwarded
on to the method invocation.
An array containing the result of the method call for each
item in collection
.
The name of the method to call on each element in
collection
.
Rest
...args: any[]Additional arguments to pass to method methodName
.
Returns true if the keys and values in properties
are contained in
object
.
True if all keys and values in properties
are also in
object
.
The object to check.
The properties to check for in object
.
Returns true if object
is an Object. Note that JavaScript arrays
and functions are objects,
while (normal) strings and numbers are not.
True if object
is an Object, otherwise false.
The object to check.
Returns true if object
is a TypedArray.
True if object
is a TypedArray, otherwise false.
The object to check.
A mostly-internal function to generate callbacks that can be applied to each element in a collection, returning the desired result -- either identity, an arbitrary callback, a property matcher, or a propetery accessor.
Callback that can be applied to each element in a collection.
Optional
context: anyReturns the last element of list
. Passing n
will return the last
n
elements of list
.
The last n
elements of list
or the last element if n
is omitted.
The list to retrieve elements from.
Returns the index of the last occurrence of value
in list
, or -1
if value
is not present. Pass fromIndex
to start your search at
a given index.
The index of the last occurrence of value
within list
or -1 if value
is not found.
The list to search for the last occurrence of value
.
The value to search for within list
.
Optional
fromIndex: numberThe starting index for the search, optional.
Produces a new array of values by mapping each value in collection
through a transformation iteratee
.
The mapped result.
The collection to transform.
The iteratee to use to transform each item in
collection
.
Optional
context: anythis
object in iteratee
, optional.
Like map, but for objects. Transform the value of each property in turn.
A new object with all of object
's property values
transformed through iteratee
.
The object to transform.
The iteratee to use to transform property values.
Optional
context: anythis
object in iteratee
, optional.
Returns the maximum value in collection
. If an iteratee
is
provided, it will be used on each element to generate the criterion
by which the element is ranked. -Infinity is returned if list is
empty. Non-numerical values returned by iteratee
will be ignored.
The maximum element within collection
or -Infinity if
collection
is empty.
The collection in which to find the maximum value.
Optional
iteratee: Iteratee<V, any, TypeOfCollection<V, never>>The iteratee that provides the criterion by which each element is ranked, optional if evaluating a collection of numbers.
Optional
context: anythis
object in iteratee
, optional.
Memoizes a given function by caching the computed result. Useful for speeding up slow-running computations. If passed an optional hashFunction, it will be used to compute the hash key for storing the result, based on the arguments to the original function. The default hashFunction just uses the first argument to the memoized function as the key.
Memoized version of fn
.
Computationally expensive function that will now memoized results.
Optional
hashFn: ((...args: any[]) => string)Hash function for storing the result of fn
.
Rest
...args: any[]Returns the minimum value in collection
. If an iteratee
is
provided, it will be used on each element to generate the criterion
by which the element is ranked. Infinity is returned if list is
empty. Non-numerical values returned by iteratee
will be ignored.
The minimum element within collection
or Infinity if
collection
is empty.
Optional
iteratee: Iteratee<V, any, TypeOfCollection<V, never>>The iteratee that provides the criterion by which each element is ranked, optional if evaluating a collection of numbers.
Optional
context: anythis
object in iteratee
, optional.
Allows you to extend Underscore with your own utility functions. Pass a hash of {name: function} definitions to have your functions added to the Underscore object, as well as the OOP wrapper.
Mixin object containing key/function pairs to add to the Underscore object.
Returns a negated version of the pass-in predicate.
(...args: any[]) => boolean
Rest
...args: any[]Returns a negated version of the pass-in predicate.
(...args: any[]) => boolean
Rest
...args: any[]Converts lists into objects. Pass either a single list
of
[key, value] pairs, or a list
of keys and a list of values
.
Passing by pairs is the reverse of pairs. If duplicate keys exist,
the last value wins.
An object comprised of the provided keys and values.
A list of [key, value] pairs or a list of keys.
If list
is a list of keys, a list of values
corresponding to those keys.
Return a copy of object
that is filtered to omit the disallowed
keys (or array of keys).
A copy of object
without the keys
properties.
The object to omit specific keys from.
Rest
...keys: (K | K[])[]The keys to omit from object
.
Return a copy of object
that is filtered to not have values for
the keys selected by a truth test.
A copy of object
without the keys selected by
iterator
.
The object to omit specific keys from.
A truth test that selects the keys to omit from
object
.
Creates a version of the function that can only be called one time. Repeated calls to the modified function will have no effect, returning the value from the original call. Useful for initialization functions, instead of having to set a boolean flag and then check it later.
Copy of fn
that can only be invoked once.
Function to only execute once.
Converts object
into a list of [key, value] pairs. The opposite
of the single-argument signature of _.object
.
The list of [key, value] pairs from object
.
The object to convert.
Partially apply a function by filling in any number of its arguments, without changing its dynamic this value. A close cousin of bind. You may pass _ in your list of arguments to specify an argument that should not be pre-filled, but left open to supply at call-time.
fn
with partially filled in arguments.
Function to partially fill in arguments.
Splits collection
into two arrays: one whose elements all satisfy
iteratee
and one whose elements all do not satisfy iteratee
.
An array composed of two elements, where the first element
contains the elements in collection
that satisfied the predicate
and the second element contains the elements that did not.
Optional
iteratee: Iteratee<V, boolean, TypeOfCollection<V, never>>The iteratee that defines the partitioning scheme
for each element in collection
.
Optional
context: anythis
object in iteratee
, optional.
Return a copy of object
that is filtered to only have values for
the allowed keys (or array of keys).
A copy of object
with only the keys
properties.
The object to pick specific keys in.
Rest
...keys: (K | K[])[]The keys to keep on object
.
Return a copy of object
that is filtered to only have values for
the keys selected by a truth test.
A copy of object
with only the keys selected by
iterator
.
The object to pick specific keys in.
A truth test that selects the keys to keep on
object
.
A convenient version of what is perhaps the most common use-case for map: extracting a list of property values.
The set of values for the specified propertyName
for each
item in collection
.
The collection of items.
The name of a specific property to retrieve from
all items in collection
.
Returns a function that will itself return the key property of any passed-in object.
Function which accept an object an returns the value of key in that object.
Property of the object.
Returns a function that will itself return the key property of any passed-in object.
Function which accept an object an returns the value of key in that object.
Returns a function that will itself return the value of a object key property.
Function which accept a key property in object
and returns its value.
Returns a function that will itself return the value of a object key property.
Function which accept a key property in object
and returns its value.
The object to get the property value from.
Returns a random integer between min and max, inclusive. If you only pass one argument, it will return a number between 0 and that number.
A random number between 0 and max
.
The maximum random number.
_.random
A random number between min
and max
.
The minimum random number.
A function to create flexibly-numbered lists of integers, handy for
each
and map
loops. Returns a list of integers from
startOrStop
(inclusive) to stop
(exclusive), incremented
(or decremented) by step
. Note that ranges that stop
before they
start
are considered to be zero-length instead of negative - if
you'd like a negative range, use a negative step
.
If stop
is not specified, startOrStop
will be the number to stop
at and the default start of 0 will be used.
An array of numbers from start to stop
with increments
of step
.
If stop
is specified, the number to start at.
Otherwise, this is the number to stop at and the default start of 0
will be used.
Optional
stop: numberThe number to stop at.
Optional
step: numberThe number to count up by each iteration, optional, default = 1.
Also known as inject and foldl, reduce boils down a collection
of
values into a single value. memo
is the initial state of the
reduction, and each successive step of it should be returned by
iteratee
.
If no memo is passed to the initial invocation of reduce, iteratee
is not invoked on the first element of collection
. The first
element is instead passed as the memo in the invocation of
iteratee
on the next element in collection
.
The reduced result.
The collection to reduce.
The function to call on each iteration to reduce the collection.
The initial reduce state or undefined to use the first
item in collection
as initial state.
Optional
context: anythis
object in iteratee
, optional.
The right-associative version of reduce.
This is not as useful in JavaScript as it would be in a language with lazy evaluation.
The reduced result.
The collection to reduce.
The function to call on each iteration to reduce the collection.
The initial reduce state or undefined to use the first
item in collection
as the initial state.
Optional
context: anythis
object in iteratee
, optional.
Returns the values in collection
without the elements that pass a
truth test (iteratee
).
The opposite of filter.
The set of values that fail the truth test.
The collection to filter.
Optional
iteratee: Iteratee<V, boolean, TypeOfCollection<V, never>>The truth test to apply.
Optional
context: anythis
object in iteratee
, optional.
Returns the rest of the elements in list
. Pass an index
to
return the values of the list from that index onward.
The elements of list
from index
to the end of the list.
The list to retrieve elements from.
Optional
index: numberThe index to start retrieving elements from, optional, default = 1.
Similar to ES6's rest param (http://ariya.ofilabs.com/2013/03/es6-and-rest-parameter.html) This accumulates the arguments passed into an array, after a given index.
Optional
starIndex: numberIf the value of the named property is a function then invoke it; otherwise, return it.
The result of invoking the function property
on `object.
Object to maybe invoke function property
on.
The function by name to invoke on object
.
Optional
defaultValue: anyThe value to be returned in case property
doesn't exist or is undefined.
Produce a random sample from collection
. Pass a number to return
n
random elements from collection
. Otherwise a single random
item will be returned.
A random sample of n
elements from collection
or a
single element if n
is not specified.
The collection to sample.
The number of elements to sample from collection
.
Returns a shuffled copy of collection
, using a version of the
Fisher-Yates shuffle.
A shuffled copy of collection
.
The collection to shuffle.
Determines the number of values in collection
.
The number of values in collection
.
The collection to determine the number of values for.
Returns true if any of the values in collection
pass the
iteratee
truth test. Short-circuits and stops traversing
collection
if a true element is found.
True if any element passed the truth test, otherwise false.
The collection to evaluate.
Optional
iteratee: Iteratee<V, boolean, TypeOfCollection<V, never>>The truth test to apply.
Optional
context: anythis
object in iteratee
, optional.
Returns a (stably) sorted copy of collection
, ranked in ascending
order by the results of running each value through iteratee
.
A sorted copy of collection
.
The collection to sort.
Optional
iteratee: Iteratee<V, any, TypeOfCollection<V, never>>An iteratee that provides the value to sort by for
each item in collection
.
Optional
context: anythis
object in iteratee
, optional.
Uses a binary search to determine the lowest index at which the
value should be inserted into list
in order to maintain list
's
sorted order. If an iteratee is provided, it will be used to compute
the sort ranking of each value, including the value you pass.
The index where value
should be inserted into list
.
A sorted list.
The value to determine an insert index for to mainain
the sorting in list
.
Optional
iteratee: Iteratee<undefined | V, any, TypeOfCollection<V, never>>Iteratee to compute the sort ranking of each
element including value
, optional.
Optional
context: anythis
object in iteratee
, optional.
Invokes interceptor with the object, and then returns object. The primary purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain.
Modified object
.
Argument to interceptor
.
The function to modify object
before continuing the method chain.
Compiles JavaScript templates into functions that can be evaluated for rendering. Useful for rendering complicated bits of HTML from JSON data sources. Template functions can both interpolate variables, using <%= ... %>, as well as execute arbitrary JavaScript code, with <% ... %>. If you wish to interpolate a value, and have it be HTML-escaped, use <%- ... %> When you evaluate a template function, pass in a data object that has properties corresponding to the template's free variables. If you're writing a one-off, you can pass the data object as the second parameter to template in order to render immediately instead of returning a template function. The settings argument should be a hash containing any _.templateSettings that should be overridden.
Returns the compiled Underscore HTML template.
Underscore HTML template.
Optional
settings: TemplateSettingsSettings to use while compiling.
Creates and returns a new, throttled version of the passed function, that, when invoked repeatedly, will only actually call the original function at most once per every wait milliseconds. Useful for rate-limiting events that occur faster than you can keep up with. By default, throttle will execute the function as soon as you call it for the first time, and, if you call it again any number of times during the wait period, as soon as that period is over. If you'd like to disable the leading-edge call, pass {leading: false}, and if you'd like to disable the execution on the trailing-edge, pass {trailing: false}.
fn
with a throttle of wait
.
Function to throttle waitMS
ms.
The number of milliseconds to wait before fn
can be invoked again.
Optional
options: ThrottleSettingsAllows for disabling execution of the throttled function on either the leading or trailing edge.
Invokes the given iterator function n times. Each invocation of iterator is called with an index argument
Number of times to invoke iterator
.
Function iterator to invoke n
times.
Optional
context: anythis
object in iterator
, optional.
Creates a real Array from collection
(anything that can be
iterated over). Useful for transmuting the arguments object.
An array containing the elements of collection
.
The collection to transform into an array.
Computes the union of the passed-in lists
: the list of unique
items, examined in order from first list to last list, that are
present in one or more of the lists.
The union of elements within lists
.
Rest
...lists: List<T>[]The lists to compute the union of.
Produces a duplicate-free version of list
, using === to test
object equality. If you know in advance that list
is sorted,
passing true for isSorted will run a much faster algorithm. If you
want to compute unique items based on a transformation, pass an
iteratee function.
An array containing only the unique elements in list
.
The list to remove duplicates from.
Optional
isSorted: booleanTrue if list
is already sorted, optional,
default = false.
Optional
iteratee: Iteratee<V, any, TypeOfCollection<V, never>>Transform the elements of list
before comparisons
for uniqueness.
Optional
context: any'this' object in iteratee
, optional.
Optional
iteratee: Iteratee<V, any, TypeOfCollection<V, never>>Optional
context: anyGenerate a globally-unique id for client-side models or DOM elements that need one. If prefix is passed, the id will be appended to it. Without prefix, returns an integer.
Unique string ID beginning with prefix
.
Optional
prefix: stringA prefix string to start the unique ID with.
The opposite of zip. Given a list of lists, returns a series of new arrays, the first of which contains all of the first elements in the input lists, the second of which contains all of the second elements, and so on. (alias: transpose)
The unzipped version of lists
.
Return all of the values of the object's properties.
List of all the values on object
.
Retrieve the values of all the properties on this object.
Return all of the values of the object's properties.
List of all the values on object
.
Retrieve the values of all the properties on this object.
Looks through each value in collection
, returning an array of all
the elements that match the key-value pairs listed in properties
.
The elements in collection
that match properties
.
The collection in which to find elements that
match properties
.
The properties to check for on the elements within
collection
.
Returns a copy of list
with all instances of values
removed.
An array that contains all elements of list
except for
values
.
The list to exclude values
from.
Rest
...values: TypeOfList<V>[]The values to exclude from list
.
Wraps the first function inside of the wrapper function, passing it as the first argument. This allows the wrapper to execute code before and after the function runs, adjust the arguments, and execute it conditionally.
Wrapped version of `fn.
Function to wrap.
The function that will wrap fn
.
Rest
...args: any[]Merges together the values of each of the lists
with the values at
the corresponding position. Useful when you have separate data
sources that are coordinated through matching list indexes.
The zipped version of lists
.
Rest
...lists: List<any>[]The lists to zip.
Underscore OOP Wrapper, all Underscore functions that take an object as the first parameter can be invoked through this function.
Returns
An Underscore wrapper around the supplied value.