The up.util
module contains functions to facilitate the work with basic JavaScript
values like lists, strings or functions.
You will recognize many functions form other utility libraries like Lodash.
While feature parity with Lodash is not a goal of up.util
, you might find it sufficient
to not include another library in your asset bundle.
Merge the own properties of one or more sources
into the target
object.
Returns all elements from the given list that are
neither null
or undefined
.
Returns whether the given value contains another value.
Returns a shallow copy of the given value.
This property contains the name of a method that user-defined classes
may implement to hook into the up.util.copy()
protocol.
Calls the given function for each element (and, optional, index) of the given list or iterator.
Escapes the given string of HTML by replacing control chars with their HTML entities.
If the given value
is a function, calls the function with the given args
.
Otherwise it just returns value
.
Returns whether the given function returns a truthy value for all elements in the given list or iterator.
Returns a copy of the given object that contains all except the given keys.
Returns all elements from the given list that return a truthy value when passed to the given function.
Passes each element in the given array-like value to the given function. Returns the first element for which the function returns a truthy value.
Consecutively calls the given function which each element in the given list. Returns the first truthy return value.
Maps each element using a mapping function, then flattens the result into a new array.
Flattens the given array
a single depth level.
Returns whether the given argument is an array.
Return whether the given argument is considered to be blank.
This property contains the name of a method that user-defined classes
may implement to hook into the up.util.isBlank()
protocol.
Returns whether the given argument is a boolean value.
Returns whether the given argument is not undefined
.
Returns whether the given argument is a DOM element.
Returns whether the two arguments are equal by value.
This property contains the name of a method that user-defined classes
may implement to hook into the up.util.isEqual()
protocol.
Returns whether the given argument is a function.
Returns whether the given argument is neither undefined
nor null
.
Returns whether the given argument is a jQuery collection.
Returns whether the given argument is an array-like value.
Returns whether the given argument is either undefined
or null
.
Returns whether the given argument is null
.
Returns whether the given argument is a number.
Returns whether the given argument is an object.
Returns whether the given argument is not blank.
Returns whether the given argument is an object with a then
method.
Returns whether the given argument is a string.
Returns whether the given argument is undefined
.
Returns the last element of the given array or string.
Translate all items in a list to new array of items.
Creates a new object by merging together the properties from the given objects.
Pushes the given function to the JavaScript microtask queue.
A function that does nothing.
Returns a normalized version of the given URL string.
Returns a copy of the given object that contains all except the given keys.
Returns a copy of the given object that only contains the given keys.
Parses the given URL into components such as hostname and path.
Returns a copy of the given object that only contains the given keys.
Returns a copy of the given object that only contains properties that pass the given tester function.
Deletes the property with the given key from the given object and returns its value.
Returns the given argument if the argument is present,
otherwise returns undefined
.
Returns all elements from the given array-like value that do not return a truthy value when passed to the given function.
Removes the given element from the given array.
Returns whether the given function returns a truthy value for any element in the given array-like value.
Pushes the given function to the JavaScript task queue (also "macrotask queue").
Waits for the given number of milliseconds, the runs the given callback.
Calls the given function for the given number of times.
Converts the given array-like value into an array.
Returns the given array without duplicates.
This function is like uniq
, accept that
the given function is invoked for each element to generate the value
for which uniquness is computed.
Returns an array of values of the given object.
Returns the given value if it is array-like, otherwise returns an array with the given value as its only element.