code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function flowRight() {
var funcs = arguments,
fromIndex = funcs.length - 1;
if (fromIndex < 0) {
return function() {};
}
if (!arrayEvery(funcs, isFunction)) {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function() {
var index = fromIndex,
result = funcs[index].apply(this, arguments);
while (index--) {
result = funcs[index].call(this, result);
}
return result;
};
}
|
This method is like `_.flow` except that it creates a function that
invokes the provided functions from right to left.
@static
@memberOf _
@alias backflow, compose
@category Function
@param {...Function} [funcs] Functions to invoke.
@returns {Function} Returns the new function.
@example
function add(x, y) {
return x + y;
}
function square(n) {
return n * n;
}
var addSquare = _.flowRight(square, add);
addSquare(1, 2);
// => 9
|
flowRight
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function negate(predicate) {
if (!isFunction(predicate)) {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function() {
return !predicate.apply(this, arguments);
};
}
|
Creates a function that negates the result of the predicate `func`. The
`func` predicate is invoked with the `this` binding and arguments of the
created function.
@static
@memberOf _
@category Function
@param {Function} predicate The predicate to negate.
@returns {Function} Returns the new function.
@example
function isEven(n) {
return n % 2 == 0;
}
_.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
// => [1, 3, 5]
|
negate
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function partial(func) {
var partials = slice(arguments, 1),
holders = replaceHolders(partials, partial.placeholder);
return createWrapper(func, PARTIAL_FLAG, null, partials, holders);
}
|
Creates a function that invokes `func` with `partial` arguments prepended
to those provided to the new function. This method is similar to `_.bind`
except it does **not** alter the `this` binding.
**Note:** This method does not set the `length` property of partially
applied functions.
@static
@memberOf _
@category Function
@param {Function} func The function to partially apply arguments to.
@param {...*} [args] The arguments to be partially applied.
@returns {Function} Returns the new partially applied function.
@example
var greet = function(greeting, name) { return greeting + ' ' + name; };
var sayHelloTo = _.partial(greet, 'hello');
sayHelloTo('fred');
// => 'hello fred'
|
partial
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function partialRight(func) {
var partials = slice(arguments, 1),
holders = replaceHolders(partials, partialRight.placeholder);
return createWrapper(func, PARTIAL_RIGHT_FLAG, null, partials, holders);
}
|
This method is like `_.partial` except that partially applied arguments
are appended to those provided to the new function.
**Note:** This method does not set the `length` property of partially applied
functions.
@static
@memberOf _
@category Function
@param {Function} func The function to partially apply arguments to.
@param {...*} [args] The arguments to be partially applied.
@returns {Function} Returns the new partially applied function.
@example
var greet = function(greeting, name) { return greeting + ' ' + name; };
var greetFred = _.partialRight(greet, 'fred');
greetFred('hello');
// => 'hello fred'
// create a deep `_.defaults`
var defaultsDeep = _.partialRight(_.merge, function deep(value, other) {
return _.merge(value, other, deep);
});
var object = { 'a': { 'b': { 'c': 1 } } },
source = { 'a': { 'b': { 'c': 2, 'd': 2 } } };
defaultsDeep(object, source);
// => { 'a': { 'b': { 'c': 1, 'd': 2 } } }
|
partialRight
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function rearg(func) {
var indexes = baseFlatten(arguments, false, false, 1);
return indexes.length
? createWrapper(func, REARG_FLAG, null, null, null, [indexes])
: createWrapper(func);
}
|
Creates a function that invokes `func` with arguments arranged according
to the specified indexes where the argument value at the first index is
provided as the first argument, the argument value at the second index is
provided as the second argument, and so on.
@static
@memberOf _
@category Function
@param {Function} func The function to rearrange arguments for.
@param {...(number|number[])} [indexes] The arranged argument indexes,
specified as individual indexes or arrays of indexes.
@returns {Function} Returns the new function.
@example
var rearged = _.rearg(function(a, b, c) {
return [a, b, c];
}, 2, 0, 1);
rearged('b', 'c', 'a')
// => ['a', 'b', 'c']
var map = _.rearg(_.map, [1, 0]);
map(function(n) { return n * 3; }, [1, 2, 3]);
// => [3, 6, 9]
|
rearg
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function throttle(func, wait, options) {
var leading = true,
trailing = true;
if (!isFunction(func)) {
throw new TypeError(FUNC_ERROR_TEXT);
}
if (options === false) {
leading = false;
} else if (isObject(options)) {
leading = 'leading' in options ? !!options.leading : leading;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
debounceOptions.leading = leading;
debounceOptions.maxWait = +wait;
debounceOptions.trailing = trailing;
return debounce(func, wait, debounceOptions);
}
|
Creates a function that only invokes `func` at most once per every `wait`
milliseconds. The created function comes with a `cancel` method to cancel
delayed invocations. Provide an options object to indicate that `func`
should be invoked on the leading and/or trailing edge of the `wait` timeout.
Subsequent calls to the throttled function return the result of the last
`func` call.
**Note:** If `leading` and `trailing` options are `true`, `func` is invoked
on the trailing edge of the timeout only if the the throttled function is
invoked more than once during the `wait` timeout.
See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
for details over the differences between `_.throttle` and `_.debounce`.
@static
@memberOf _
@category Function
@param {Function} func The function to throttle.
@param {number} wait The number of milliseconds to throttle invocations to.
@param {Object} [options] The options object.
@param {boolean} [options.leading=true] Specify invoking on the leading
edge of the timeout.
@param {boolean} [options.trailing=true] Specify invoking on the trailing
edge of the timeout.
@returns {Function} Returns the new throttled function.
@example
// avoid excessively updating the position while scrolling
jQuery(window).on('scroll', _.throttle(updatePosition, 100));
// invoke `renewToken` when the click event is fired, but not more than once every 5 minutes
var throttled = _.throttle(renewToken, 300000, { 'trailing': false })
jQuery('.interactive').on('click', throttled);
// cancel a trailing throttled call
jQuery(window).on('popstate', throttled.cancel);
|
throttle
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function wrap(value, wrapper) {
wrapper = wrapper == null ? identity : wrapper;
return createWrapper(wrapper, PARTIAL_FLAG, null, [value]);
}
|
Creates a function that provides `value` to the wrapper function as its
first argument. Any additional arguments provided to the function are
appended to those provided to the wrapper function. The wrapper is invoked
with the `this` binding of the created function.
@static
@memberOf _
@category Function
@param {*} value The value to wrap.
@param {Function} wrapper The wrapper function.
@returns {Function} Returns the new function.
@example
var p = _.wrap(_.escape, function(func, text) {
return '<p>' + func(text) + '</p>';
});
p('fred, barney, & pebbles');
// => '<p>fred, barney, & pebbles</p>'
|
wrap
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function clone(value, isDeep, customizer, thisArg) {
// juggle arguments
if (typeof isDeep != 'boolean' && isDeep != null) {
thisArg = customizer;
customizer = isIterateeCall(value, isDeep, thisArg) ? null : isDeep;
isDeep = false;
}
customizer = typeof customizer == 'function' && baseCallback(customizer, thisArg, 1);
return baseClone(value, isDeep, customizer);
}
|
Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned,
otherwise they are assigned by reference. If `customizer` is provided it is
invoked to produce the cloned values. If `customizer` returns `undefined`
cloning is handled by the method instead. The `customizer` is bound to
`thisArg` and invoked with two argument; (value, index|key).
**Note:** This method is loosely based on the structured clone algorithm.
The enumerable properties of `arguments` objects and objects created by
constructors other than `Object` are cloned to plain `Object` objects. An
empty object is returned for uncloneable values such as functions, DOM nodes,
Maps, Sets, and WeakMaps. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm)
for more details.
@static
@memberOf _
@category Lang
@param {*} value The value to clone.
@param {boolean} [isDeep=false] Specify a deep clone.
@param {Function} [customizer] The function to customize cloning values.
@param {*} [thisArg] The `this` binding of `customizer`.
@returns {*} Returns the cloned value.
@example
var users = [
{ 'user': 'barney', 'age': 36 },
{ 'user': 'fred', 'age': 40 }
];
var shallow = _.clone(users);
shallow[0] === users[0];
// => true
var deep = _.clone(users, true);
deep[0] === users[0];
// => false
_.mixin({
'clone': _.partialRight(_.clone, function(value) {
return _.isElement(value) ? value.cloneNode(false) : undefined;
})
});
var clone = _.clone(document.body);
clone.childNodes.length;
// => 0
|
clone
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function cloneDeep(value, customizer, thisArg) {
customizer = typeof customizer == 'function' && baseCallback(customizer, thisArg, 1);
return baseClone(value, true, customizer);
}
|
Creates a deep clone of `value`. If `customizer` is provided it is invoked
to produce the cloned values. If `customizer` returns `undefined` cloning
is handled by the method instead. The `customizer` is bound to `thisArg`
and invoked with two argument; (value, index|key).
**Note:** This method is loosely based on the structured clone algorithm.
The enumerable properties of `arguments` objects and objects created by
constructors other than `Object` are cloned to plain `Object` objects. An
empty object is returned for uncloneable values such as functions, DOM nodes,
Maps, Sets, and WeakMaps. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm)
for more details.
@static
@memberOf _
@category Lang
@param {*} value The value to deep clone.
@param {Function} [customizer] The function to customize cloning values.
@param {*} [thisArg] The `this` binding of `customizer`.
@returns {*} Returns the deep cloned value.
@example
var users = [
{ 'user': 'barney', 'age': 36 },
{ 'user': 'fred', 'age': 40 }
];
var deep = _.cloneDeep(users);
deep[0] === users[0];
// => false
var view = {
'label': 'docs',
'node': element
};
var clone = _.cloneDeep(view, function(value) {
return _.isElement(value) ? value.cloneNode(true) : undefined;
});
clone.node == view.node;
// => false
|
cloneDeep
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function isArguments(value) {
var length = (value && typeof value == 'object') ? value.length : undefined;
return (isLength(length) && toString.call(value) == argsClass) || false;
}
|
Checks if `value` is classified as an `arguments` object.
@static
@memberOf _
@category Lang
@param {*} value The value to check.
@returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
@example
(function() { return _.isArguments(arguments); })();
// => true
_.isArguments([1, 2, 3]);
// => false
|
isArguments
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function isDate(value) {
return (value && typeof value == 'object' && toString.call(value) == dateClass) || false;
}
|
Checks if `value` is classified as a `Date` object.
@static
@memberOf _
@category Lang
@param {*} value The value to check.
@returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
@example
_.isDate(new Date);
// => true
_.isDate('Mon April 23 2012');
// => false
|
isDate
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function isElement(value) {
return (value && typeof value == 'object' && value.nodeType === 1 &&
(lodash.support.nodeClass ? toString.call(value).indexOf('Element') > -1 : isHostObject(value))) || false;
}
|
Checks if `value` is a DOM element.
@static
@memberOf _
@category Lang
@param {*} value The value to check.
@returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
@example
_.isElement(document.body);
// => true
_.isElement('<body>');
// => false
|
isElement
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function isEmpty(value) {
if (value == null) {
return true;
}
var length = value.length;
if (isLength(length) && (isArray(value) || isString(value) || isArguments(value) ||
(typeof value == 'object' && isFunction(value.splice)))) {
return !length;
}
return !keys(value).length;
}
|
Checks if a collection is empty. A value is considered empty unless it is
an array-like value with a length greater than `0` or an object with own
enumerable properties.
@static
@memberOf _
@category Lang
@param {Array|Object|string} value The value to inspect.
@returns {boolean} Returns `true` if `value` is empty, else `false`.
@example
_.isEmpty(null);
// => true
_.isEmpty(true);
// => true
_.isEmpty(1);
// => true
_.isEmpty([1, 2, 3]);
// => false
_.isEmpty({ 'a': 1 });
// => false
|
isEmpty
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function isEqual(value, other, customizer, thisArg) {
customizer = typeof customizer == 'function' && baseCallback(customizer, thisArg, 3);
return (!customizer && isStrictComparable(value) && isStrictComparable(other))
? value === other
: baseIsEqual(value, other, customizer);
}
|
Performs a deep comparison between two values to determine if they are
equivalent. If `customizer` is provided it is invoked to compare values.
If `customizer` returns `undefined` comparisons are handled by the method
instead. The `customizer` is bound to `thisArg` and invoked with three
arguments; (value, other, key).
**Note:** This method supports comparing arrays, booleans, `Date` objects,
numbers, `Object` objects, regexes, and strings. Functions and DOM nodes
are **not** supported. Provide a customizer function to extend support
for comparing other values.
@static
@memberOf _
@category Lang
@param {*} value The value to compare to `other`.
@param {*} other The value to compare to `value`.
@param {Function} [customizer] The function to customize comparing values.
@param {*} [thisArg] The `this` binding of `customizer`.
@returns {boolean} Returns `true` if the values are equivalent, else `false`.
@example
var object = { 'user': 'fred' };
var other = { 'user': 'fred' };
object == other;
// => false
_.isEqual(object, other);
// => true
var words = ['hello', 'goodbye'];
var otherWords = ['hi', 'goodbye'];
_.isEqual(words, otherWords, function() {
return _.every(arguments, _.bind(RegExp.prototype.test, /^h(?:i|ello)$/)) || undefined;
});
// => true
|
isEqual
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function isError(value) {
return (value && typeof value == 'object' && toString.call(value) == errorClass) || false;
}
|
Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
`SyntaxError`, `TypeError`, or `URIError` object.
@static
@memberOf _
@category Lang
@param {*} value The value to check.
@returns {boolean} Returns `true` if `value` is an error object, else `false`.
@example
_.isError(new Error);
// => true
_.isError(Error);
// => false
|
isError
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function isFunction(value) {
// Use `|| false` to avoid a Chakra bug in compatibility modes of IE 11.
// See https://github.com/jashkenas/underscore/issues/1621.
return typeof value == 'function' || false;
}
|
Checks if `value` is classified as a `Function` object.
@static
@memberOf _
@category Lang
@param {*} value The value to check.
@returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
@example
_.isFunction(_);
// => true
_.isFunction(/abc/);
// => false
|
isFunction
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function isObject(value) {
// Avoid a V8 bug in Chrome 19-20.
// See https://code.google.com/p/v8/issues/detail?id=2291.
var type = typeof value;
return type == 'function' || (value && type == 'object') || false;
}
|
Checks if `value` is the language type of `Object`.
(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
**Note:** See the [ES5 spec](http://es5.github.io/#x8) for more details.
@static
@memberOf _
@category Lang
@param {*} value The value to check.
@returns {boolean} Returns `true` if `value` is an object, else `false`.
@example
_.isObject({});
// => true
_.isObject([1, 2, 3]);
// => true
_.isObject(1);
// => false
|
isObject
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function isNaN(value) {
// `NaN` as a primitive is the only value that is not equal to itself
// (perform the `[[Class]]` check first to avoid errors with some host objects in IE)
return isNumber(value) && value != +value;
}
|
Checks if `value` is `NaN`.
**Note:** This method is not the same as native `isNaN` which returns `true`
for `undefined` and other non-numeric values. See the [ES5 spec](http://es5.github.io/#x15.1.2.4)
for more details.
@static
@memberOf _
@category Lang
@param {*} value The value to check.
@returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
@example
_.isNaN(NaN);
// => true
_.isNaN(new Number(NaN));
// => true
isNaN(undefined);
// => true
_.isNaN(undefined);
// => false
|
isNaN
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function isNative(value) {
if (value == null) {
return false;
}
if (toString.call(value) == funcClass) {
return reNative.test(fnToString.call(value));
}
return (typeof value == 'object' &&
(isHostObject(value) ? reNative : reHostCtor).test(value)) || false;
}
|
Checks if `value` is a native function.
@static
@memberOf _
@category Lang
@param {*} value The value to check.
@returns {boolean} Returns `true` if `value` is a native function, else `false`.
@example
_.isNative(Array.prototype.push);
// => true
_.isNative(_);
// => false
|
isNative
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function isNull(value) {
return value === null;
}
|
Checks if `value` is `null`.
@static
@memberOf _
@category Lang
@param {*} value The value to check.
@returns {boolean} Returns `true` if `value` is `null`, else `false`.
@example
_.isNull(null);
// => true
_.isNull(void 0);
// => false
|
isNull
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function isRegExp(value) {
return (isObject(value) && toString.call(value) == regexpClass) || false;
}
|
Checks if `value` is classified as a `RegExp` object.
@static
@memberOf _
@category Lang
@param {*} value The value to check.
@returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
@example
_.isRegExp(/abc/);
// => true
_.isRegExp('/abc/');
// => false
|
isRegExp
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function isUndefined(value) {
return typeof value == 'undefined';
}
|
Checks if `value` is `undefined`.
@static
@memberOf _
@category Lang
@param {*} value The value to check.
@returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
@example
_.isUndefined(void 0);
// => true
_.isUndefined(null);
// => false
|
isUndefined
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function create(prototype, properties, guard) {
var result = baseCreate(prototype);
properties = guard ? null : properties;
return properties ? baseAssign(result, properties) : result;
}
|
Creates an object that inherits from the given `prototype` object. If a
`properties` object is provided its own enumerable properties are assigned
to the created object.
@static
@memberOf _
@category Object
@param {Object} prototype The object to inherit from.
@param {Object} [properties] The properties to assign to the object.
@param- {Object} [guard] Enables use as a callback for functions like `_.map`.
@returns {Object} Returns the new object.
@example
function Shape() {
this.x = 0;
this.y = 0;
}
function Circle() {
Shape.call(this);
}
Circle.prototype = _.create(Shape.prototype, { 'constructor': Circle });
var circle = new Circle;
circle instanceof Circle;
// => true
circle instanceof Shape;
// => true
|
create
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function defaults(object) {
if (object == null) {
return object;
}
var args = baseSlice(arguments);
args.push(assignDefaults);
return assign.apply(undefined, args);
}
|
Assigns own enumerable properties of source object(s) to the destination
object for all destination properties that resolve to `undefined`. Once a
property is set, additional defaults of the same property are ignored.
**Note:** See the [documentation example of `_.partialRight`](http://lodash.com/docs#partialRight)
for a deep version of this method.
@static
@memberOf _
@category Object
@param {Object} object The destination object.
@param {...Object} [sources] The source objects.
@returns {Object} Returns the destination object.
@example
_.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred', 'status': 'busy' });
// => { 'user': 'barney', 'age': 36, 'status': 'busy' }
|
defaults
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function findKey(object, predicate, thisArg) {
predicate = getCallback(predicate, thisArg, 3);
return baseFind(object, predicate, baseForOwn, true);
}
|
This method is like `_.findIndex` except that it returns the key of the
first element `predicate` returns truthy for, instead of the element itself.
If a property name is provided for `predicate` the created "_.pluck" style
callback returns the property value of the given element.
If an object is provided for `predicate` the created "_.where" style callback
returns `true` for elements that have the properties of the given object,
else `false`.
@static
@memberOf _
@category Object
@param {Object} object The object to search.
@param {Function|Object|string} [predicate=_.identity] The function invoked
per iteration. If a property name or object is provided it is used to
create a "_.pluck" or "_.where" style callback respectively.
@param {*} [thisArg] The `this` binding of `predicate`.
@returns {string|undefined} Returns the key of the matched element, else `undefined`.
@example
var users = {
'barney': { 'age': 36, 'active': true },
'fred': { 'age': 40, 'active': false },
'pebbles': { 'age': 1, 'active': true }
};
_.findKey(users, function(chr) { return chr.age < 40; });
// => 'barney' (iteration order is not guaranteed)
// using "_.where" callback shorthand
_.findKey(users, { 'age': 1 });
// => 'pebbles'
// using "_.pluck" callback shorthand
_.findKey(users, 'active');
// => 'barney'
|
findKey
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function findLastKey(object, predicate, thisArg) {
predicate = getCallback(predicate, thisArg, 3);
return baseFind(object, predicate, baseForOwnRight, true);
}
|
This method is like `_.findKey` except that it iterates over elements of
a collection in the opposite order.
If a property name is provided for `predicate` the created "_.pluck" style
callback returns the property value of the given element.
If an object is provided for `predicate` the created "_.where" style callback
returns `true` for elements that have the properties of the given object,
else `false`.
@static
@memberOf _
@category Object
@param {Object} object The object to search.
@param {Function|Object|string} [predicate=_.identity] The function invoked
per iteration. If a property name or object is provided it is used to
create a "_.pluck" or "_.where" style callback respectively.
@param {*} [thisArg] The `this` binding of `predicate`.
@returns {string|undefined} Returns the key of the matched element, else `undefined`.
@example
var users = {
'barney': { 'age': 36, 'active': true },
'fred': { 'age': 40, 'active': false },
'pebbles': { 'age': 1, 'active': true }
};
_.findLastKey(users, function(chr) { return chr.age < 40; });
// => returns `pebbles` assuming `_.findKey` returns `barney`
// using "_.where" callback shorthand
_.findLastKey(users, { 'age': 40 });
// => 'fred'
// using "_.pluck" callback shorthand
_.findLastKey(users, 'active');
// => 'pebbles'
|
findLastKey
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function forIn(object, iteratee, thisArg) {
if (typeof iteratee != 'function' || typeof thisArg != 'undefined') {
iteratee = baseCallback(iteratee, thisArg, 3);
}
return baseFor(object, iteratee, keysIn);
}
|
Iterates over own and inherited enumerable properties of an object invoking
`iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked
with three arguments; (value, key, object). Iterator functions may exit
iteration early by explicitly returning `false`.
@static
@memberOf _
@category Object
@param {Object} object The object to iterate over.
@param {Function} [iteratee=_.identity] The function invoked per iteration.
@param {*} [thisArg] The `this` binding of `iteratee`.
@returns {Object} Returns `object`.
@example
function Shape() {
this.x = 0;
this.y = 0;
}
Shape.prototype.z = 0;
_.forIn(new Shape, function(value, key) {
console.log(key);
});
// => logs 'x', 'y', and 'z' (iteration order is not guaranteed)
|
forIn
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function forInRight(object, iteratee, thisArg) {
iteratee = baseCallback(iteratee, thisArg, 3);
return baseForRight(object, iteratee, keysIn);
}
|
This method is like `_.forIn` except that it iterates over properties of
`object` in the opposite order.
@static
@memberOf _
@category Object
@param {Object} object The object to iterate over.
@param {Function} [iteratee=_.identity] The function invoked per iteration.
@param {*} [thisArg] The `this` binding of `iteratee`.
@returns {Object} Returns `object`.
@example
function Shape() {
this.x = 0;
this.y = 0;
}
Shape.prototype.z = 0;
_.forInRight(new Shape, function(value, key) {
console.log(key);
});
// => logs 'z', 'y', and 'x' assuming `_.forIn ` logs 'x', 'y', and 'z'
|
forInRight
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function forOwn(object, iteratee, thisArg) {
if (typeof iteratee != 'function' || typeof thisArg != 'undefined') {
iteratee = baseCallback(iteratee, thisArg, 3);
}
return baseForOwn(object, iteratee);
}
|
Iterates over own enumerable properties of an object invoking `iteratee`
for each property. The `iteratee` is bound to `thisArg` and invoked with
three arguments; (value, key, object). Iterator functions may exit iteration
early by explicitly returning `false`.
@static
@memberOf _
@category Object
@param {Object} object The object to iterate over.
@param {Function} [iteratee=_.identity] The function invoked per iteration.
@param {*} [thisArg] The `this` binding of `iteratee`.
@returns {Object} Returns `object`.
@example
_.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) {
console.log(key);
});
// => logs '0', '1', and 'length' (iteration order is not guaranteed)
|
forOwn
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function forOwnRight(object, iteratee, thisArg) {
iteratee = baseCallback(iteratee, thisArg, 3);
return baseForRight(object, iteratee, keys);
}
|
This method is like `_.forOwn` except that it iterates over properties of
`object` in the opposite order.
@static
@memberOf _
@category Object
@param {Object} object The object to iterate over.
@param {Function} [iteratee=_.identity] The function invoked per iteration.
@param {*} [thisArg] The `this` binding of `iteratee`.
@returns {Object} Returns `object`.
@example
_.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) {
console.log(key);
});
// => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length'
|
forOwnRight
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function functions(object) {
return baseFunctions(object, keysIn(object));
}
|
Creates an array of function property names from all enumerable properties,
own and inherited, of `object`.
@static
@memberOf _
@alias methods
@category Object
@param {Object} object The object to inspect.
@returns {Array} Returns the new array of property names.
@example
_.functions(_);
// => ['all', 'any', 'bind', ...]
|
functions
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function has(object, key) {
return object ? hasOwnProperty.call(object, key) : false;
}
|
Checks if the specified property name exists as a direct property of `object`,
instead of an inherited property.
@static
@memberOf _
@category Object
@param {Object} object The object to inspect.
@param {string} key The name of the property to check.
@returns {boolean} Returns `true` if `key` is a direct property, else `false`.
@example
_.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
// => true
|
has
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function invert(object, multiValue, guard) {
multiValue = guard ? null : multiValue;
var index = -1,
props = keys(object),
length = props.length,
result = {};
while (++index < length) {
var key = props[index],
value = object[key];
if (multiValue) {
if (hasOwnProperty.call(result, value)) {
result[value].push(key);
} else {
result[value] = [key];
}
}
else {
result[value] = key;
}
}
return result;
}
|
Creates an object composed of the inverted keys and values of `object`.
If `object` contains duplicate values, subsequent values overwrite property
assignments of previous values unless `multiValue` is `true`.
@static
@memberOf _
@category Object
@param {Object} object The object to invert.
@param {boolean} [multiValue=false] Allow multiple values per key.
@param- {Object} [guard] Enables use as a callback for functions like `_.map`.
@returns {Object} Returns the new inverted object.
@example
_.invert({ 'first': 'fred', 'second': 'barney' });
// => { 'fred': 'first', 'barney': 'second' }
// without `multiValue`
_.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' });
// => { 'fred': 'third', 'barney': 'second' }
// with `multiValue`
_.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' }, true);
// => { 'fred': ['first', 'third'], 'barney': ['second'] }
|
invert
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function keysIn(object) {
if (object == null) {
return [];
}
if (!isObject(object)) {
object = Object(object);
}
var length = object.length,
support = lodash.support;
length = (typeof length == 'number' && length > 0 &&
(isArray(object) || (support.nonEnumStrings && isString(object)) ||
(support.nonEnumArgs && isArguments(object))) && length) || 0;
var Ctor = object.constructor,
index = -1,
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto,
isProto = proto === object,
result = Array(length),
skipIndexes = length > 0,
skipErrorProps = support.enumErrorProps && (object === errorProto || object instanceof Error),
skipProto = support.enumPrototypes && typeof object == 'function';
while (++index < length) {
result[index] = String(index);
}
// Lo-Dash skips the `constructor` property when it infers it is iterating
// over a `prototype` object because IE < 9 can't set the `[[Enumerable]]`
// attribute of an existing property and the `constructor` property of a
// prototype defaults to non-enumerable
for (var key in object) {
if (!(skipProto && key == 'prototype') &&
!(skipErrorProps && (key == 'message' || key == 'name')) &&
!(skipIndexes && isIndex(key, length)) &&
!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
result.push(key);
}
}
if (support.nonEnumShadows && object !== objectProto) {
var className = object === stringProto ? stringClass : object === errorProto ? errorClass : toString.call(object),
nonEnums = nonEnumProps[className] || nonEnumProps[objectClass];
if (className == objectClass) {
proto = objectProto;
}
length = shadowedProps.length;
while (length--) {
key = shadowedProps[length];
var nonEnum = nonEnums[key];
if (!(isProto && nonEnum) &&
(nonEnum ? hasOwnProperty.call(object, key) : object[key] !== proto[key])) {
result.push(key);
}
}
}
return result;
}
|
Creates an array of the own and inherited enumerable property names of `object`.
@static
@memberOf _
@category Object
@param {Object} object The object to inspect.
@returns {Array} Returns the array of property names.
@example
function Shape() {
this.x = 0;
this.y = 0;
}
Shape.prototype.z = 0;
_.keysIn(new Shape);
// => ['x', 'y', 'z'] (iteration order is not guaranteed)
|
keysIn
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function mapValues(object, iteratee, thisArg) {
iteratee = getCallback(iteratee, thisArg, 3);
var result = {}
baseForOwn(object, function(value, key, object) {
result[key] = iteratee(value, key, object);
});
return result;
}
|
Creates an object with the same keys as `object` and values generated by
running each own enumerable property of `object` through `iteratee`. The
iteratee function is bound to `thisArg` and invoked with three arguments;
(value, key, object).
If a property name is provided for `iteratee` the created "_.pluck" style
callback returns the property value of the given element.
If an object is provided for `iteratee` the created "_.where" style callback
returns `true` for elements that have the properties of the given object,
else `false`.
@static
@memberOf _
@category Object
@param {Object} object The object to iterate over.
@param {Function|Object|string} [iteratee=_.identity] The function invoked
per iteration. If a property name or object is provided it is used to
create a "_.pluck" or "_.where" style callback respectively.
@param {*} [thisArg] The `this` binding of `iteratee`.
@returns {Object} Returns the new mapped object.
@example
_.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(n) { return n * 3; });
// => { 'a': 3, 'b': 6, 'c': 9 }
var users = {
'fred': { 'user': 'fred', 'age': 40 },
'pebbles': { 'user': 'pebbles', 'age': 1 }
};
// using "_.pluck" callback shorthand
_.mapValues(users, 'age');
// => { 'fred': 40, 'pebbles': 1 }
|
mapValues
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function pairs(object) {
var index = -1,
props = keys(object),
length = props.length,
result = Array(length);
while (++index < length) {
var key = props[index];
result[index] = [key, object[key]];
}
return result;
}
|
Creates a two dimensional array of the key-value pairs for `object`,
e.g. `[[key1, value1], [key2, value2]]`.
@static
@memberOf _
@category Object
@param {Object} object The object to inspect.
@returns {Array} Returns the new array of key-value pairs.
@example
_.pairs({ 'barney': 36, 'fred': 40 });
// => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)
|
pairs
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function pick(object, predicate, thisArg) {
if (object == null) {
return {};
}
return typeof predicate == 'function'
? pickByCallback(object, getCallback(predicate, thisArg, 3))
: pickByArray(object, baseFlatten(arguments, false, false, 1));
}
|
Creates a shallow clone of `object` composed of the specified properties.
Property names may be specified as individual arguments or as arrays of
property names. If `predicate` is provided it is invoked for each property
of `object` picking the properties `predicate` returns truthy for. The
predicate is bound to `thisArg` and invoked with three arguments;
(value, key, object).
@static
@memberOf _
@category Object
@param {Object} object The source object.
@param {Function|...(string|string[])} [predicate] The function invoked per
iteration or property names to pick, specified as individual property
names or arrays of property names.
@param {*} [thisArg] The `this` binding of `predicate`.
@returns {Object} Returns the new object.
@example
_.pick({ 'user': 'fred', '_userid': 'fred1' }, 'user');
// => { 'user': 'fred' }
_.pick({ 'user': 'fred', '_userid': 'fred1' }, function(value, key) {
return key.charAt(0) != '_';
});
// => { 'user': 'fred' }
|
pick
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function transform(object, iteratee, accumulator, thisArg) {
iteratee = getCallback(iteratee, thisArg, 4);
var isArr = isArrayLike(object);
if (accumulator == null) {
if (isArr || isObject(object)) {
var Ctor = object.constructor;
if (isArr) {
accumulator = isArray(object) ? new Ctor : [];
} else {
accumulator = baseCreate(typeof Ctor == 'function' && Ctor.prototype);
}
} else {
accumulator = {};
}
}
(isArr ? arrayEach : baseForOwn)(object, function(value, index, object) {
return iteratee(accumulator, value, index, object);
});
return accumulator;
}
|
An alternative to `_.reduce`; this method transforms `object` to a new
`accumulator` object which is the result of running each of its own
enumerable properties through `iteratee`, with each invocation potentially
mutating the `accumulator` object. The `iteratee` is bound to `thisArg`
and invoked with four arguments; (accumulator, value, key, object). Iterator
functions may exit iteration early by explicitly returning `false`.
@static
@memberOf _
@category Object
@param {Array|Object} object The object to iterate over.
@param {Function} [iteratee=_.identity] The function invoked per iteration.
@param {*} [accumulator] The custom accumulator value.
@param {*} [thisArg] The `this` binding of `iteratee`.
@returns {*} Returns the accumulated value.
@example
var squares = _.transform([1, 2, 3, 4, 5, 6], function(result, n) {
n *= n;
if (n % 2) {
return result.push(n) < 3;
}
});
// => [1, 9, 25]
var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) {
result[key] = n * 3;
});
// => { 'a': 3, 'b': 6, 'c': 9 }
|
transform
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function values(object) {
return baseValues(object, keys);
}
|
Creates an array of the own enumerable property values of `object`.
@static
@memberOf _
@category Object
@param {Object} object The object to inspect.
@returns {Array} Returns the array of property values.
@example
function Shape(x, y) {
this.x = x;
this.y = y;
}
Shape.prototype.z = 0;
_.values(new Shape(2, 1));
// => [2, 1] (iteration order is not guaranteed)
|
values
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function valuesIn(object) {
return baseValues(object, keysIn);
}
|
Creates an array of the own and inherited enumerable property values
of `object`.
@static
@memberOf _
@category Object
@param {Object} object The object to inspect.
@returns {Array} Returns the array of property values.
@example
function Shape(x, y) {
this.x = x;
this.y = y;
}
Shape.prototype.z = 0;
_.valuesIn(new Shape(2, 1));
// => [2, 1, 0] (iteration order is not guaranteed)
|
valuesIn
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function capitalize(string) {
string = string == null ? '' : String(string);
return string ? (string.charAt(0).toUpperCase() + string.slice(1)) : string;
}
|
Capitalizes the first character of `string`.
@static
@memberOf _
@category String
@param {string} [string=''] The string to capitalize.
@returns {string} Returns the capitalized string.
@example
_.capitalize('fred');
// => 'Fred'
|
capitalize
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function endsWith(string, target, position) {
string = string == null ? '' : String(string);
target = String(target);
var length = string.length;
position = (typeof position == 'undefined' ? length : nativeMin(position < 0 ? 0 : (+position || 0), length)) - target.length;
return position >= 0 && string.indexOf(target, position) == position;
}
|
Checks if `string` ends with the given target string.
@static
@memberOf _
@category String
@param {string} [string=''] The string to search.
@param {string} [target] The string to search for.
@param {number} [position=string.length] The position to search from.
@returns {boolean} Returns `true` if `string` ends with `target`, else `false`.
@example
_.endsWith('abc', 'c');
// => true
_.endsWith('abc', 'b');
// => false
_.endsWith('abc', 'b', 2);
// => true
|
endsWith
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function escape(string) {
// reset `lastIndex` because in IE < 9 `String#replace` does not
string = string == null ? '' : String(string);
return string && (reUnescapedHtml.lastIndex = 0, reUnescapedHtml.test(string))
? string.replace(reUnescapedHtml, escapeHtmlChar)
: string;
}
|
Converts the characters "&", "<", ">", '"', "'", and '`', in `string` to
their corresponding HTML entities.
**Note:** No other characters are escaped. To escape additional characters
use a third-party library like [_he_](http://mths.be/he).
When working with HTML you should always quote attribute values to reduce
XSS vectors. See [Ryan Grove's article](http://wonko.com/post/html-escaping)
for more details.
@static
@memberOf _
@category String
@param {string} [string=''] The string to escape.
@returns {string} Returns the escaped string.
@example
_.escape('fred, barney, & pebbles');
// => 'fred, barney, & pebbles'
|
escape
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function escapeRegExp(string) {
string = string == null ? '' : String(string);
return string && (reRegExpChars.lastIndex = 0, reRegExpChars.test(string))
? string.replace(reRegExpChars, '\\$&')
: string;
}
|
Escapes the `RegExp` special characters "\", "^", "$", ".", "|", "?", "*",
"+", "(", ")", "[", "]", "{" and "}" in `string`.
@static
@memberOf _
@category String
@param {string} [string=''] The string to escape.
@returns {string} Returns the escaped string.
@example
_.escapeRegExp('[lodash](http://lodash.com/)');
// => '\[lodash\]\(http://lodash\.com/\)'
|
escapeRegExp
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function pad(string, length, chars) {
string = string == null ? '' : String(string);
length = +length;
var strLength = string.length;
if (strLength >= length || !nativeIsFinite(length)) {
return string;
}
var mid = (length - strLength) / 2,
leftLength = floor(mid),
rightLength = ceil(mid);
chars = createPad('', rightLength, chars);
return chars.slice(0, leftLength) + string + chars;
}
|
Pads `string` on the left and right sides if it is shorter then the given
padding length. The `chars` string may be truncated if the number of padding
characters can't be evenly divided by the padding length.
@static
@memberOf _
@category String
@param {string} [string=''] The string to pad.
@param {number} [length=0] The padding length.
@param {string} [chars=' '] The string used as padding.
@returns {string} Returns the padded string.
@example
_.pad('abc', 8);
// => ' abc '
_.pad('abc', 8, '_-');
// => '_-abc_-_'
_.pad('abc', 3);
// => 'abc'
|
pad
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function padLeft(string, length, chars) {
string = string == null ? '' : String(string);
return string ? (createPad(string, length, chars) + string) : string;
}
|
Pads `string` on the left side if it is shorter then the given padding
length. The `chars` string may be truncated if the number of padding
characters exceeds the padding length.
@static
@memberOf _
@category String
@param {string} [string=''] The string to pad.
@param {number} [length=0] The padding length.
@param {string} [chars=' '] The string used as padding.
@returns {string} Returns the padded string.
@example
_.padLeft('abc', 6);
// => ' abc'
_.padLeft('abc', 6, '_-');
// => '_-_abc'
_.padLeft('abc', 3);
// => 'abc'
|
padLeft
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function padRight(string, length, chars) {
string = string == null ? '' : String(string);
return string ? (string + createPad(string, length, chars)) : string;
}
|
Pads `string` on the right side if it is shorter then the given padding
length. The `chars` string may be truncated if the number of padding
characters exceeds the padding length.
@static
@memberOf _
@category String
@param {string} [string=''] The string to pad.
@param {number} [length=0] The padding length.
@param {string} [chars=' '] The string used as padding.
@returns {string} Returns the padded string.
@example
_.padRight('abc', 6);
// => 'abc '
_.padRight('abc', 6, '_-');
// => 'abc_-_'
_.padRight('abc', 3);
// => 'abc'
|
padRight
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function repeat(string, n) {
var result = '';
n = +n;
if (n < 1 || string == null || !nativeIsFinite(n)) {
return result;
}
string = String(string);
// leverage the exponentiation by squaring algorithm for a faster repeat
// http://en.wikipedia.org/wiki/Exponentiation_by_squaring
do {
if (n % 2) {
result += string;
}
n = floor(n / 2);
string += string;
} while (n);
return result;
}
|
Repeats the given string `n` times.
@static
@memberOf _
@category String
@param {string} [string=''] The string to repeat.
@param {number} [n=0] The number of times to repeat the string.
@returns {string} Returns the repeated string.
@example
_.repeat('*', 3);
// => '***'
_.repeat('abc', 2);
// => 'abcabc'
_.repeat('abc', 0);
// => ''
|
repeat
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function startsWith(string, target, position) {
string = string == null ? '' : String(string);
position = typeof position == 'undefined' ? 0 : nativeMin(position < 0 ? 0 : (+position || 0), string.length);
return string.lastIndexOf(target, position) == position;
}
|
Checks if `string` starts with the given target string.
@static
@memberOf _
@category String
@param {string} [string=''] The string to search.
@param {string} [target] The string to search for.
@param {number} [position=0] The position to search from.
@returns {boolean} Returns `true` if `string` starts with `target`, else `false`.
@example
_.startsWith('abc', 'a');
// => true
_.startsWith('abc', 'b');
// => false
_.startsWith('abc', 'b', 1);
// => true
|
startsWith
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function trim(string, chars, guard) {
string = string == null ? '' : String(string);
if (!string) {
return string;
}
if (guard || chars == null) {
return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1);
}
chars = String(chars);
return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1);
}
|
Removes leading and trailing whitespace or specified characters from `string`.
@static
@memberOf _
@category String
@param {string} [string=''] The string to trim.
@param {string} [chars=whitespace] The characters to trim.
@param- {Object} [guard] Enables use as a callback for functions like `_.map`.
@returns {string} Returns the trimmed string.
@example
_.trim(' fred ');
// => 'fred'
_.trim('-_-fred-_-', '_-');
// => 'fred'
|
trim
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function trimLeft(string, chars, guards) {
string = string == null ? '' : String(string);
if (!string) {
return string;
}
if (guards || chars == null) {
return string.slice(trimmedLeftIndex(string))
}
chars = String(chars);
return string.slice(charsLeftIndex(string, chars));
}
|
Removes leading whitespace or specified characters from `string`.
@static
@memberOf _
@category String
@param {string} [string=''] The string to trim.
@param {string} [chars=whitespace] The characters to trim.
@param- {Object} [guard] Enables use as a callback for functions like `_.map`.
@returns {string} Returns the trimmed string.
@example
_.trimLeft(' fred ');
// => 'fred '
_.trimLeft('-_-fred-_-', '_-');
// => 'fred-_-'
|
trimLeft
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function trimRight(string, chars, guard) {
string = string == null ? '' : String(string);
if (!string) {
return string;
}
if (guard || chars == null) {
return string.slice(0, trimmedRightIndex(string) + 1)
}
chars = String(chars);
return string.slice(0, charsRightIndex(string, chars) + 1);
}
|
Removes trailing whitespace or specified characters from `string`.
@static
@memberOf _
@category String
@param {string} [string=''] The string to trim.
@param {string} [chars=whitespace] The characters to trim.
@param- {Object} [guard] Enables use as a callback for functions like `_.map`.
@returns {string} Returns the trimmed string.
@example
_.trimRight(' fred ');
// => ' fred'
_.trimRight('-_-fred-_-', '_-');
// => '-_-fred'
|
trimRight
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function unescape(string) {
string = string == null ? '' : String(string);
return string && (reEscapedHtml.lastIndex = 0, reEscapedHtml.test(string))
? string.replace(reEscapedHtml, unescapeHtmlChar)
: string;
}
|
The inverse of `_.escape`; this method converts the HTML entities
`&`, `<`, `>`, `"`, `'`, and ``` in `string` to their
corresponding characters.
**Note:** No other HTML entities are unescaped. To unescape additional HTML
entities use a third-party library like [_he_](http://mths.be/he).
@static
@memberOf _
@category String
@param {string} [string=''] The string to unescape.
@returns {string} Returns the unescaped string.
@example
_.unescape('fred, barney, & pebbles');
// => 'fred, barney, & pebbles'
|
unescape
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function words(string, pattern, guard) {
string = string != null && String(string);
pattern = guard ? null : pattern;
return (string && string.match(pattern || reWords)) || [];
}
|
Splits `string` into an array of its words.
@static
@memberOf _
@category String
@param {string} [string=''] The string to inspect.
@param {RegExp|string} [pattern] The pattern to match words.
@param- {Object} [guard] Enables use as a callback for functions like `_.map`.
@returns {Array} Returns the words of `string`.
@example
_.words('fred, barney, & pebbles');
// => ['fred', 'barney', 'pebbles']
_.words('fred, barney, & pebbles', /[^, ]+/g);
// => ['fred', 'barney', '&', 'pebbles']
|
words
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function attempt(func) {
try {
return func();
} catch(e) {
return isError(e) ? e : Error(e);
}
}
|
Attempts to invoke `func`, returning either the result or the caught
error object.
@static
@memberOf _
@category Utility
@param {*} func The function to attempt.
@returns {*} Returns the `func` result or error object.
@example
// avoid throwing errors for invalid selectors
var elements = _.attempt(function() {
return document.querySelectorAll(selector);
});
if (_.isError(elements)) {
elements = [];
}
|
attempt
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function callback(func, thisArg, guard) {
return baseCallback(func, guard ? undefined : thisArg);
}
|
Creates a function bound to an optional `thisArg`. If `func` is a property
name the created callback returns the property value for a given element.
If `func` is an object the created callback returns `true` for elements
that contain the equivalent object properties, otherwise it returns `false`.
@static
@memberOf _
@alias iteratee
@category Utility
@param {*} [func=_.identity] The value to convert to a callback.
@param {*} [thisArg] The `this` binding of the created callback.
@param- {Object} [guard] Enables use as a callback for functions like `_.map`.
@returns {Function} Returns the new function.
@example
var users = [
{ 'user': 'barney', 'age': 36 },
{ 'user': 'fred', 'age': 40 }
];
// wrap to create custom callback shorthands
_.callback = _.wrap(_.callback, function(callback, func, thisArg) {
var match = /^(.+?)__([gl]t)(.+)$/.exec(func);
if (!match) {
return callback(func, thisArg);
}
return function(object) {
return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
};
});
_.filter(users, 'age__gt38');
// => [{ 'user': 'fred', 'age': 40 }]
|
callback
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function constant(value) {
return function() {
return value;
};
}
|
Creates a function that returns `value`.
@static
@memberOf _
@category Utility
@param {*} value The value to return from the new function.
@returns {Function} Returns the new function.
@example
var object = { 'user': 'fred' };
var getter = _.constant(object);
getter() === object;
// => true
|
constant
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function identity(value) {
return value;
}
|
This method returns the first argument provided to it.
@static
@memberOf _
@category Utility
@param {*} value Any value.
@returns {*} Returns `value`.
@example
var object = { 'user': 'fred' };
_.identity(object) === object;
// => true
|
identity
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function matches(source) {
var props = keys(source),
length = props.length;
if (length == 1) {
var key = props[0],
value = source[key];
if (isStrictComparable(value)) {
return function(object) {
return object != null && value === object[key] && hasOwnProperty.call(object, key);
};
}
}
var index = length,
values = Array(length),
strictCompareFlags = Array(length);
while (index--) {
value = source[props[index]];
var isStrict = isStrictComparable(value);
values[index] = isStrict ? value : baseClone(value, true, clonePassthru);
strictCompareFlags[index] = isStrict;
}
return function(object) {
index = length;
if (object == null) {
return !index;
}
while (index--) {
if (strictCompareFlags[index]
? values[index] !== object[props[index]]
: !hasOwnProperty.call(object, props[index])
) {
return false;
}
}
index = length;
while (index--) {
if (strictCompareFlags[index]
? !hasOwnProperty.call(object, props[index])
: !baseIsEqual(values[index], object[props[index]], null, true)
) {
return false;
}
}
return true;
};
}
|
Creates a "_.where" style predicate function which performs a deep comparison
between a given object and the `source` object, returning `true` if the given
object has equivalent property values, else `false`.
@static
@memberOf _
@category Utility
@param {Object} source The object of property values to match.
@returns {Function} Returns the new function.
@example
var users = [
{ 'user': 'fred', 'age': 40 },
{ 'user': 'barney', 'age': 36 }
];
var matchesAge = _.matches({ 'age': 36 });
_.filter(users, matchesAge);
// => [{ 'user': 'barney', 'age': 36 }]
_.find(users, matchesAge);
// => { 'user': 'barney', 'age': 36 }
|
matches
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function mixin(object, source, options) {
var chain = true,
isObj = isObject(source),
noOpts = options == null,
props = noOpts && isObj && keys(source),
methodNames = props && baseFunctions(source, props);
if ((props && props.length && !methodNames.length) || (noOpts && !isObj)) {
if (noOpts) {
options = source;
}
methodNames = false;
source = object;
object = this;
}
methodNames || (methodNames = baseFunctions(source, keys(source)));
if (options === false) {
chain = false;
} else if (isObject(options) && 'chain' in options) {
chain = options.chain;
}
var index = -1,
isFunc = isFunction(object),
length = methodNames.length;
while (++index < length) {
var methodName = methodNames[index];
object[methodName] = source[methodName];
if (isFunc) {
object.prototype[methodName] = (function(methodName) {
return function() {
var chainAll = this.__chain__;
if (chain || chainAll) {
var result = object(this.__wrapped__);
result.__chain__ = chainAll;
(result.__queue__ = baseSlice(this.__queue__)).push({ 'args': arguments, 'object': object, 'name': methodName });
return result;
}
var args = [this.value()];
push.apply(args, arguments);
return object[methodName].apply(object, args);
};
}(methodName));
}
}
return object;
}
|
Adds all own enumerable function properties of a source object to the
destination object. If `object` is a function then methods are added to
its prototype as well.
@static
@memberOf _
@category Utility
@param {Function|Object} [object=this] object The destination object.
@param {Object} source The object of functions to add.
@param {Object} [options] The options object.
@param {boolean} [options.chain=true] Specify whether the functions added
are chainable.
@returns {Function|Object} Returns `object`.
@example
function vowels(string) {
return _.filter(string, function(v) {
return /[aeiou]/i.test(v);
});
}
_.mixin({ 'vowels': vowels });
_.vowels('fred');
// => ['e']
_('fred').vowels().value();
// => ['e']
_.mixin({ 'vowels': vowels }, { 'chain': false });
_('fred').vowels();
// => ['e']
|
mixin
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function noConflict() {
context._ = oldDash;
return this;
}
|
Reverts the `_` variable to its previous value and returns a reference to
the `lodash` function.
@static
@memberOf _
@category Utility
@returns {Function} Returns the `lodash` function.
@example
var lodash = _.noConflict();
|
noConflict
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function noop() {
// no operation performed
}
|
A no-operation function.
@static
@memberOf _
@category Utility
@example
var object = { 'user': 'fred' };
_.noop(object) === undefined;
// => true
|
noop
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function parseInt(value, radix, guard) {
return nativeParseInt(value, guard ? 0 : radix);
}
|
Converts `value` to an integer of the specified radix. If `radix` is
`undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal,
in which case a `radix` of `16` is used.
**Note:** This method aligns with the ES5 implementation of `parseInt`.
See the [ES5 spec](http://es5.github.io/#E) for more details.
@static
@memberOf _
@category Utility
@param {string} value The value to parse.
@param {number} [radix] The radix to interpret `value` by.
@param- {Object} [guard] Enables use as a callback for functions like `_.map`.
@returns {number} Returns the converted integer.
@example
_.parseInt('08');
// => 8
|
parseInt
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function property(key) {
key = String(key);
return function(object) {
return object == null ? undefined : object[key];
};
}
|
Creates a "_.pluck" style function which returns the property value
of `key` on a given object.
@static
@memberOf _
@category Utility
@param {string} key The name of the property to retrieve.
@returns {Function} Returns the new function.
@example
var users = [
{ 'user': 'fred', 'age': 40 },
{ 'user': 'barney', 'age': 36 }
];
var getName = _.property('user');
_.map(users, getName);
// => ['fred', barney']
_.pluck(_.sortBy(users, getName), 'user');
// => ['barney', 'fred']
|
property
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function propertyOf(object) {
return function(key) {
return object == null ? undefined : object[key];
};
}
|
The inverse of `_.property`; this method creates a function which returns
the property value of a given key on `object`.
@static
@memberOf _
@category Utility
@param {Object} object The object to inspect.
@returns {Function} Returns the new function.
@example
var fred = { 'user': 'fred', 'age': 40, 'active': true };
_.map(['age', 'active'], _.propertyOf(fred));
// => [40, true]
var object = { 'a': 3, 'b': 1, 'c': 2 };
_.sortBy(['a', 'b', 'c'], _.propertyOf(object));
// => ['b', 'c', 'a']
|
propertyOf
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function random(min, max, floating) {
if (floating && isIterateeCall(min, max, floating)) {
max = floating = null;
}
var noMin = min == null,
noMax = max == null;
if (floating == null) {
if (noMax && typeof min == 'boolean') {
floating = min;
min = 1;
}
else if (typeof max == 'boolean') {
floating = max;
noMax = true;
}
}
if (noMin && noMax) {
max = 1;
noMax = false;
}
min = +min || 0;
if (noMax) {
max = min;
min = 0;
} else {
max = +max || 0;
}
if (floating || min % 1 || max % 1) {
var rand = nativeRandom();
return nativeMin(min + (rand * (max - min + parseFloat('1e-' + (String(rand).length - 1)))), max);
}
return baseRandom(min, max);
}
|
Produces a random number between `min` and `max` (inclusive). If only one
argument is provided a number between `0` and the given number is returned.
If `floating` is `true`, or either `min` or `max` are floats, a floating-point
number is returned instead of an integer.
@static
@memberOf _
@category Utility
@param {number} [min=0] The minimum possible value.
@param {number} [max=1] The maximum possible value.
@param {boolean} [floating=false] Specify returning a floating-point number.
@returns {number} Returns the random number.
@example
_.random(0, 5);
// => an integer between 0 and 5
_.random(5);
// => also an integer between 0 and 5
_.random(5, true);
// => a floating-point number between 0 and 5
_.random(1.2, 5.2);
// => a floating-point number between 1.2 and 5.2
|
random
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function range(start, end, step) {
if (step && isIterateeCall(start, end, step)) {
end = step = null;
}
start = +start || 0;
step = step == null ? 1 : (+step || 0);
if (end == null) {
end = start;
start = 0;
} else {
end = +end || 0;
}
// use `Array(length)` so engines like Chakra and V8 avoid slower modes
// http://youtu.be/XAqIpGU8ZZk#t=17m25s
var index = -1,
length = nativeMax(ceil((end - start) / (step || 1)), 0),
result = Array(length);
while (++index < length) {
result[index] = start;
start += step;
}
return result;
}
|
Creates an array of numbers (positive and/or negative) progressing from
`start` up to, but not including, `end`. If `start` is less than `end` a
zero-length range is created unless a negative `step` is specified.
@static
@memberOf _
@category Utility
@param {number} [start=0] The start of the range.
@param {number} end The end of the range.
@param {number} [step=1] The value to increment or decrement by.
@returns {Array} Returns the new array of numbers.
@example
_.range(4);
// => [0, 1, 2, 3]
_.range(1, 5);
// => [1, 2, 3, 4]
_.range(0, 20, 5);
// => [0, 5, 10, 15]
_.range(0, -4, -1);
// => [0, -1, -2, -3]
_.range(1, 4, 0);
// => [1, 1, 1]
_.range(0);
// => []
|
range
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function result(object, key, defaultValue) {
var value = object == null ? undefined : object[key];
if (typeof value == 'undefined') {
return defaultValue;
}
return isFunction(value) ? object[key]() : value;
}
|
Resolves the value of property `key` on `object`. If `key` is a function
it is invoked with the `this` binding of `object` and its result returned,
else the property value is returned. If `object` is `null` or `undefined`
then `undefined` is returned. If a default value is provided it is returned
if the property value resolves to `undefined`.
@static
@memberOf _
@category Utility
@param {Object} object The object to inspect.
@param {string} key The name of the property to resolve.
@param {*} [defaultValue] The value returned if the property value
resolves to `undefined`.
@returns {*} Returns the resolved value.
@example
var object = {
'user': 'fred',
'age': function() {
return 40;
}
};
_.result(object, 'user');
// => 'fred'
_.result(object, 'age');
// => 40
_.result(object, 'status', 'busy');
// => 'busy'
|
result
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function times(n, iteratee, thisArg) {
n = nativeIsFinite(n = +n) && n > -1 ? n : 0;
iteratee = baseCallback(iteratee, thisArg, 1);
var index = -1,
result = Array(nativeMin(n, MAX_ARRAY_LENGTH));
while (++index < n) {
if (index < MAX_ARRAY_LENGTH) {
result[index] = iteratee(index);
} else {
iteratee(index);
}
}
return result;
}
|
Invokes the iteratee function `n` times, returning an array of the results
of each invocation. The `iteratee` is bound to `thisArg` and invoked with
one argument; (index).
@static
@memberOf _
@category Utility
@param {number} n The number of times to invoke `iteratee`.
@param {Function} [iteratee=_.identity] The function invoked per iteration.
@param {*} [thisArg] The `this` binding of `iteratee`.
@returns {Array} Returns the array of results.
@example
var diceRolls = _.times(3, _.partial(_.random, 1, 6, false));
// => [3, 6, 4]
_.times(3, function(n) { mage.castSpell(n); });
// => invokes `mage.castSpell(n)` three times with `n` of `0`, `1`, and `2` respectively
_.times(3, function(n) { this.cast(n); }, mage);
// => also invokes `mage.castSpell(n)` three times
|
times
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function uniqueId(prefix) {
var id = ++idCounter;
return String(prefix == null ? '' : prefix) + id;
}
|
Generates a unique ID. If `prefix` is provided the ID is appended to it.
@static
@memberOf _
@category Utility
@param {string} [prefix] The value to prefix the ID with.
@returns {string} Returns the unique ID.
@example
_.uniqueId('contact_');
// => 'contact_104'
_.uniqueId();
// => '105'
|
uniqueId
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
_ = function(obj) {
if (obj instanceof _) return obj;
if (!(this instanceof _)) return new _(obj);
this._wrapped = obj;
}
|
The semantic version number.
@static
@memberOf _
@type string
|
_
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
optimizeCb = function(func, context, argCount) {
if (context === void 0) return func;
switch (argCount == null ? 3 : argCount) {
case 1: return function(value) {
return func.call(context, value);
};
case 2: return function(value, other) {
return func.call(context, value, other);
};
case 3: return function(value, index, collection) {
return func.call(context, value, index, collection);
};
case 4: return function(accumulator, value, index, collection) {
return func.call(context, accumulator, value, index, collection);
};
}
return function() {
return func.apply(context, arguments);
};
}
|
The semantic version number.
@static
@memberOf _
@type string
|
optimizeCb
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
cb = function(value, context, argCount) {
if (value == null) return _.identity;
if (_.isFunction(value)) return optimizeCb(value, context, argCount);
if (_.isObject(value)) return _.matches(value);
return _.property(value);
}
|
The semantic version number.
@static
@memberOf _
@type string
|
cb
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
group = function(behavior) {
return function(obj, iteratee, context) {
var result = {};
iteratee = cb(iteratee, context);
_.each(obj, function(value, index) {
var key = iteratee(value, index, obj);
behavior(result, value, key);
});
return result;
};
}
|
The semantic version number.
@static
@memberOf _
@type string
|
group
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
flatten = function(input, shallow, strict, startIndex) {
var output = [], idx = 0, value;
for (var i = startIndex || 0, length = input && input.length; i < length; i++) {
value = input[i];
if (value && value.length >= 0 && (_.isArray(value) || _.isArguments(value))) {
//flatten current level of array or arguments object
if (!shallow) value = flatten(value, shallow, strict);
var j = 0, len = value.length;
output.length += len;
while (j < len) {
output[idx++] = value[j++];
}
} else if (!strict) {
output[idx++] = value;
}
}
return output;
}
|
The semantic version number.
@static
@memberOf _
@type string
|
flatten
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
executeBound = function(sourceFunc, boundFunc, context, callingContext, args) {
if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
Ctor.prototype = sourceFunc.prototype;
var self = new Ctor;
Ctor.prototype = null;
var result = sourceFunc.apply(self, args);
if (_.isObject(result)) return result;
return self;
}
|
The semantic version number.
@static
@memberOf _
@type string
|
executeBound
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
memoize = function(key) {
var cache = memoize.cache;
var address = '' + (hasher ? hasher.apply(this, arguments) : key);
if (!_.has(cache, address)) cache[address] = func.apply(this, arguments);
return cache[address];
}
|
The semantic version number.
@static
@memberOf _
@type string
|
memoize
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
later = function() {
previous = options.leading === false ? 0 : _.now();
timeout = null;
result = func.apply(context, args);
if (!timeout) context = args = null;
}
|
The semantic version number.
@static
@memberOf _
@type string
|
later
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
later = function() {
var last = _.now() - timestamp;
if (last < wait && last >= 0) {
timeout = setTimeout(later, wait - last);
} else {
timeout = null;
if (!immediate) {
result = func.apply(context, args);
if (!timeout) context = args = null;
}
}
}
|
The semantic version number.
@static
@memberOf _
@type string
|
later
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function collectNonEnumProps(obj, keys) {
var nonEnumIdx = nonEnumerableProps.length;
var proto = typeof obj.constructor === 'function' ? FuncProto : ObjProto;
while (nonEnumIdx--) {
var prop = nonEnumerableProps[nonEnumIdx];
if (prop === 'constructor' ? _.has(obj, prop) : prop in obj &&
obj[prop] !== proto[prop] && !_.contains(keys, prop)) {
keys.push(prop);
}
}
}
|
The semantic version number.
@static
@memberOf _
@type string
|
collectNonEnumProps
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
eq = function(a, b, aStack, bStack) {
// Identical objects are equal. `0 === -0`, but they aren't identical.
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
if (a === b) return a !== 0 || 1 / a === 1 / b;
// A strict comparison is necessary because `null == undefined`.
if (a == null || b == null) return a === b;
// Unwrap any wrapped objects.
if (a instanceof _) a = a._wrapped;
if (b instanceof _) b = b._wrapped;
// Compare `[[Class]]` names.
var className = toString.call(a);
if (className !== toString.call(b)) return false;
switch (className) {
// Strings, numbers, regular expressions, dates, and booleans are compared by value.
case '[object RegExp]':
// RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
case '[object String]':
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
// equivalent to `new String("5")`.
return '' + a === '' + b;
case '[object Number]':
// `NaN`s are equivalent, but non-reflexive.
// Object(NaN) is equivalent to NaN
if (+a !== +a) return +b !== +b;
// An `egal` comparison is performed for other numeric values.
return +a === 0 ? 1 / +a === 1 / b : +a === +b;
case '[object Date]':
case '[object Boolean]':
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
// millisecond representations. Note that invalid dates with millisecond representations
// of `NaN` are not equivalent.
return +a === +b;
}
var areArrays = className === '[object Array]';
if (!areArrays) {
if (typeof a != 'object' || typeof b != 'object') return false;
// Objects with different constructors are not equivalent, but `Object`s or `Array`s
// from different frames are.
var aCtor = a.constructor, bCtor = b.constructor;
if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor &&
_.isFunction(bCtor) && bCtor instanceof bCtor)
&& ('constructor' in a && 'constructor' in b)) {
return false;
}
}
// Assume equality for cyclic structures. The algorithm for detecting cyclic
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
var length = aStack.length;
while (length--) {
// Linear search. Performance is inversely proportional to the number of
// unique nested structures.
if (aStack[length] === a) return bStack[length] === b;
}
// Add the first object to the stack of traversed objects.
aStack.push(a);
bStack.push(b);
// Recursively compare objects and arrays.
if (areArrays) {
// Compare array lengths to determine if a deep comparison is necessary.
length = a.length;
if (length !== b.length) return false;
// Deep compare the contents, ignoring non-numeric properties.
while (length--) {
if (!(eq(a[length], b[length], aStack, bStack))) return false;
}
} else {
// Deep compare objects.
var keys = _.keys(a), key;
length = keys.length;
// Ensure that both objects contain the same number of properties before comparing deep equality.
if (_.keys(b).length !== length) return false;
while (length--) {
// Deep compare each member
key = keys[length];
if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
}
}
// Remove the first object from the stack of traversed objects.
aStack.pop();
bStack.pop();
return true;
}
|
The semantic version number.
@static
@memberOf _
@type string
|
eq
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
createEscaper = function(map) {
var escaper = function(match) {
return map[match];
};
// Regexes for identifying a key that needs to be escaped
var source = '(?:' + _.keys(map).join('|') + ')';
var testRegexp = RegExp(source);
var replaceRegexp = RegExp(source, 'g');
return function(string) {
string = string == null ? '' : '' + string;
return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
};
}
|
The semantic version number.
@static
@memberOf _
@type string
|
createEscaper
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
escaper = function(match) {
return map[match];
}
|
The semantic version number.
@static
@memberOf _
@type string
|
escaper
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
escapeChar = function(match) {
return '\\' + escapes[match];
}
|
The semantic version number.
@static
@memberOf _
@type string
|
escapeChar
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
template = function(data) {
return render.call(this, data, _);
}
|
The semantic version number.
@static
@memberOf _
@type string
|
template
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
result = function(instance, obj) {
return instance._chain ? _(obj).chain() : obj;
}
|
The semantic version number.
@static
@memberOf _
@type string
|
result
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function bindInternal_0_0_1 (func, thisContext, numArgs) {
switch (numArgs) {
case 3: return function(a, b, c) {
return func.call(thisContext, a, b, c);
};
case 4: return function(a, b, c, d) {
return func.call(thisContext, a, b, c, d);
};
}
return function() {
return func.apply(thisContext, arguments);
};
}
|
Intern a string to make comparisons faster.
> Note: This is a relatively expensive operation, you
shouldn't usually do the actual interning at runtime, instead
use this at compile time to make future work faster.
@param {String} string The string to intern.
@return {String} The interned string.
|
bindInternal_0_0_1
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function bindInternal3_0_0_2a (func, thisContext) {
return function (a, b, c) {
return func.call(thisContext, a, b, c);
};
}
|
Intern a string to make comparisons faster.
> Note: This is a relatively expensive operation, you
shouldn't usually do the actual interning at runtime, instead
use this at compile time to make future work faster.
@param {String} string The string to intern.
@return {String} The interned string.
|
bindInternal3_0_0_2a
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function bindInternal4_0_0_2a (func, thisContext) {
return function (a, b, c, d) {
return func.call(thisContext, a, b, c, d);
};
}
|
Intern a string to make comparisons faster.
> Note: This is a relatively expensive operation, you
shouldn't usually do the actual interning at runtime, instead
use this at compile time to make future work faster.
@param {String} string The string to intern.
@return {String} The interned string.
|
bindInternal4_0_0_2a
|
javascript
|
codemix/fast.js
|
dist/bench.js
|
https://github.com/codemix/fast.js/blob/master/dist/bench.js
|
MIT
|
function Fast (value) {
if (!(this instanceof Fast)) {
return new Fast(value);
}
this.value = value || [];
}
|
# Constructor
Provided as a convenient wrapper around Fast functions.
```js
var arr = fast([1,2,3,4,5,6]);
var result = arr.filter(function (item) {
return item % 2 === 0;
});
result instanceof Fast; // true
result.length; // 3
```
@param {Array} value The value to wrap.
|
Fast
|
javascript
|
codemix/fast.js
|
dist/fast.js
|
https://github.com/codemix/fast.js/blob/master/dist/fast.js
|
MIT
|
function addActiveClass($target) {
if (!$target) {
return;
}
$target.find('button').addClass('active');
$selectedNode = $target;
}
|
show image dialog
@param {jQuery} $dialog
@return {Promise}
|
addActiveClass
|
javascript
|
summernote/summernote
|
public/plugin/specialchars/summernote-ext-specialchars.js
|
https://github.com/summernote/summernote/blob/master/public/plugin/specialchars/summernote-ext-specialchars.js
|
MIT
|
function removeActiveClass($target) {
$target.find('button').removeClass('active');
$selectedNode = null;
}
|
show image dialog
@param {jQuery} $dialog
@return {Promise}
|
removeActiveClass
|
javascript
|
summernote/summernote
|
public/plugin/specialchars/summernote-ext-specialchars.js
|
https://github.com/summernote/summernote/blob/master/public/plugin/specialchars/summernote-ext-specialchars.js
|
MIT
|
function findNextNode(row, column) {
var findNode = null;
$.each($specialCharNode, function(idx, $node) {
var findRow = Math.ceil((idx + 1) / COLUMN_LENGTH);
var findColumn = ((idx + 1) % COLUMN_LENGTH === 0) ? COLUMN_LENGTH : (idx + 1) % COLUMN_LENGTH;
if (findRow === row && findColumn === column) {
findNode = $node;
return false;
}
});
return $(findNode);
}
|
show image dialog
@param {jQuery} $dialog
@return {Promise}
|
findNextNode
|
javascript
|
summernote/summernote
|
public/plugin/specialchars/summernote-ext-specialchars.js
|
https://github.com/summernote/summernote/blob/master/public/plugin/specialchars/summernote-ext-specialchars.js
|
MIT
|
function arrowKeyHandler(keyCode) {
// left, right, up, down key
var $nextNode;
var lastRowColumnLength = $specialCharNode.length % totalColumn;
if (KEY.LEFT === keyCode) {
if (currentColumn > 1) {
currentColumn = currentColumn - 1;
} else if (currentRow === 1 && currentColumn === 1) {
currentColumn = lastRowColumnLength;
currentRow = totalRow;
} else {
currentColumn = totalColumn;
currentRow = currentRow - 1;
}
} else if (KEY.RIGHT === keyCode) {
if (currentRow === totalRow && lastRowColumnLength === currentColumn) {
currentColumn = 1;
currentRow = 1;
} else if (currentColumn < totalColumn) {
currentColumn = currentColumn + 1;
} else {
currentColumn = 1;
currentRow = currentRow + 1;
}
} else if (KEY.UP === keyCode) {
if (currentRow === 1 && lastRowColumnLength < currentColumn) {
currentRow = totalRow - 1;
} else {
currentRow = currentRow - 1;
}
} else if (KEY.DOWN === keyCode) {
currentRow = currentRow + 1;
}
if (currentRow === totalRow && currentColumn > lastRowColumnLength) {
currentRow = 1;
} else if (currentRow > totalRow) {
currentRow = 1;
} else if (currentRow < 1) {
currentRow = totalRow;
}
$nextNode = findNextNode(currentRow, currentColumn);
if ($nextNode) {
removeActiveClass($selectedNode);
addActiveClass($nextNode);
}
}
|
show image dialog
@param {jQuery} $dialog
@return {Promise}
|
arrowKeyHandler
|
javascript
|
summernote/summernote
|
public/plugin/specialchars/summernote-ext-specialchars.js
|
https://github.com/summernote/summernote/blob/master/public/plugin/specialchars/summernote-ext-specialchars.js
|
MIT
|
function enterKeyHandler() {
if (!$selectedNode) {
return;
}
deferred.resolve(decodeURIComponent($selectedNode.find('button').attr('data-value')));
$specialCharDialog.modal('hide');
}
|
show image dialog
@param {jQuery} $dialog
@return {Promise}
|
enterKeyHandler
|
javascript
|
summernote/summernote
|
public/plugin/specialchars/summernote-ext-specialchars.js
|
https://github.com/summernote/summernote/blob/master/public/plugin/specialchars/summernote-ext-specialchars.js
|
MIT
|
function keyDownEventHandler(event) {
event.preventDefault();
var keyCode = event.keyCode;
if (keyCode === undefined || keyCode === null) {
return;
}
// check arrowKeys match
if (ARROW_KEYS.indexOf(keyCode) > -1) {
if ($selectedNode === null) {
addActiveClass($specialCharNode.eq(0));
currentColumn = 1;
currentRow = 1;
return;
}
arrowKeyHandler(keyCode);
} else if (keyCode === ENTER_KEY) {
enterKeyHandler();
}
return false;
}
|
show image dialog
@param {jQuery} $dialog
@return {Promise}
|
keyDownEventHandler
|
javascript
|
summernote/summernote
|
public/plugin/specialchars/summernote-ext-specialchars.js
|
https://github.com/summernote/summernote/blob/master/public/plugin/specialchars/summernote-ext-specialchars.js
|
MIT
|
constructor($note, options) {
this.$note = $note;
this.memos = {};
this.modules = {};
this.layoutInfo = {};
this.options = $.extend(true, {}, options);
// init ui with options
$.summernote.ui = $.summernote.ui_template(this.options);
this.ui = $.summernote.ui;
this.initialize();
}
|
@param {jQuery} $note
@param {Object} options
|
constructor
|
javascript
|
summernote/summernote
|
src/js/Context.js
|
https://github.com/summernote/summernote/blob/master/src/js/Context.js
|
MIT
|
initialize() {
this.layoutInfo = this.ui.createLayout(this.$note);
this._initialize();
this.$note.hide();
return this;
}
|
create layout and initialize modules and other resources
|
initialize
|
javascript
|
summernote/summernote
|
src/js/Context.js
|
https://github.com/summernote/summernote/blob/master/src/js/Context.js
|
MIT
|
destroy() {
this._destroy();
this.$note.removeData('summernote');
this.ui.removeLayout(this.$note, this.layoutInfo);
}
|
destroy modules and other resources and remove layout
|
destroy
|
javascript
|
summernote/summernote
|
src/js/Context.js
|
https://github.com/summernote/summernote/blob/master/src/js/Context.js
|
MIT
|
reset() {
const disabled = this.isDisabled();
this.code(dom.emptyPara);
this._destroy();
this._initialize();
if (disabled) {
this.disable();
}
}
|
destory modules and other resources and initialize it again
|
reset
|
javascript
|
summernote/summernote
|
src/js/Context.js
|
https://github.com/summernote/summernote/blob/master/src/js/Context.js
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.