mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Update doc examples to ES2015.
This commit is contained in:
11
after.js
11
after.js
@@ -11,15 +11,10 @@ import toInteger from './toInteger.js';
|
||||
* @returns {Function} Returns the new restricted function.
|
||||
* @example
|
||||
*
|
||||
* var saves = ['profile', 'settings'];
|
||||
* const saves = ['profile', 'settings'];
|
||||
* const done = after(saves.length, () => console.log('done saving!'));
|
||||
*
|
||||
* var done = after(saves.length, function() {
|
||||
* console.log('done saving!');
|
||||
* });
|
||||
*
|
||||
* forEach(saves, function(type) {
|
||||
* asyncSave({ 'type': type, 'complete': done });
|
||||
* });
|
||||
* forEach(saves, type => asyncSave({ 'type': type, 'complete': done }));
|
||||
* // => Logs 'done saving!' after the two async saves have completed.
|
||||
*/
|
||||
function after(n, func) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import keysIn from './keysIn.js';
|
||||
* return isUndefined(objValue) ? srcValue : objValue;
|
||||
* }
|
||||
*
|
||||
* var defaults = partialRight(assignInWith, customizer);
|
||||
* const defaults = partialRight(assignInWith, customizer);
|
||||
*
|
||||
* defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
|
||||
* // => { 'a': 1, 'b': 2 }
|
||||
|
||||
@@ -23,7 +23,7 @@ import keys from './keys.js';
|
||||
* return isUndefined(objValue) ? srcValue : objValue;
|
||||
* }
|
||||
*
|
||||
* var defaults = partialRight(assignWith, customizer);
|
||||
* const defaults = partialRight(assignWith, customizer);
|
||||
*
|
||||
* defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
|
||||
* // => { 'a': 1, 'b': 2 }
|
||||
|
||||
2
at.js
2
at.js
@@ -10,7 +10,7 @@ import baseAt from './.internal/baseAt.js';
|
||||
* @returns {Array} Returns the picked values.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
|
||||
* const object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
|
||||
*
|
||||
* at(object, ['a[0].b.c', 'a[1]']);
|
||||
* // => [3, 4]
|
||||
|
||||
@@ -13,9 +13,8 @@ import isError from './isError.js';
|
||||
* @example
|
||||
*
|
||||
* // Avoid throwing errors for invalid selectors.
|
||||
* var elements = attempt(function(selector) {
|
||||
* return document.querySelectorAll(selector);
|
||||
* }, '>_>');
|
||||
* const elements = attempt(selector =>
|
||||
* document.querySelectorAll(selector), '>_>');
|
||||
*
|
||||
* if (isError(elements)) {
|
||||
* elements = [];
|
||||
|
||||
6
bind.js
6
bind.js
@@ -28,14 +28,14 @@ const WRAP_PARTIAL_FLAG = 32;
|
||||
* return greeting + ' ' + this.user + punctuation;
|
||||
* }
|
||||
*
|
||||
* var object = { 'user': 'fred' };
|
||||
* const object = { 'user': 'fred' };
|
||||
*
|
||||
* var bound = bind(greet, object, 'hi');
|
||||
* const bound = bind(greet, object, 'hi');
|
||||
* bound('!');
|
||||
* // => 'hi fred!'
|
||||
*
|
||||
* // Bound with placeholders.
|
||||
* var bound = bind(greet, object, _, '!');
|
||||
* const bound = bind(greet, object, _, '!');
|
||||
* bound('hi');
|
||||
* // => 'hi fred!'
|
||||
*/
|
||||
|
||||
@@ -16,11 +16,9 @@ import toKey from './.internal/toKey.js';
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* var view = {
|
||||
* const view = {
|
||||
* 'label': 'docs',
|
||||
* 'click': function() {
|
||||
* console.log('clicked ' + this.label);
|
||||
* }
|
||||
* 'click': () => console.log(`clicked ${ this.label }`)
|
||||
* };
|
||||
*
|
||||
* bindAll(view, ['click']);
|
||||
|
||||
@@ -27,14 +27,14 @@ const WRAP_PARTIAL_FLAG = 32;
|
||||
* @returns {Function} Returns the new bound function.
|
||||
* @example
|
||||
*
|
||||
* var object = {
|
||||
* const object = {
|
||||
* 'user': 'fred',
|
||||
* 'greet': function(greeting, punctuation) {
|
||||
* return greeting + ' ' + this.user + punctuation;
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* var bound = bindKey(object, 'greet', 'hi');
|
||||
* const bound = bindKey(object, 'greet', 'hi');
|
||||
* bound('!');
|
||||
* // => 'hi fred!'
|
||||
*
|
||||
@@ -46,7 +46,7 @@ const WRAP_PARTIAL_FLAG = 32;
|
||||
* // => 'hiya fred!'
|
||||
*
|
||||
* // Bound with placeholders.
|
||||
* var bound = bindKey(object, 'greet', _, '!');
|
||||
* const bound = bindKey(object, 'greet', _, '!');
|
||||
* bound('hi');
|
||||
* // => 'hiya fred!'
|
||||
*/
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* castArray();
|
||||
* // => []
|
||||
*
|
||||
* var array = [1, 2, 3];
|
||||
* const array = [1, 2, 3];
|
||||
* console.log(castArray(array) === array);
|
||||
* // => true
|
||||
*/
|
||||
|
||||
4
clone.js
4
clone.js
@@ -21,9 +21,9 @@ const CLONE_SYMBOLS_FLAG = 4;
|
||||
* @see cloneDeep
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'a': 1 }, { 'b': 2 }];
|
||||
* const objects = [{ 'a': 1 }, { 'b': 2 }];
|
||||
*
|
||||
* var shallow = clone(objects);
|
||||
* const shallow = clone(objects);
|
||||
* console.log(shallow[0] === objects[0]);
|
||||
* // => true
|
||||
*/
|
||||
|
||||
@@ -14,9 +14,9 @@ const CLONE_SYMBOLS_FLAG = 4;
|
||||
* @see clone
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'a': 1 }, { 'b': 2 }];
|
||||
* const objects = [{ 'a': 1 }, { 'b': 2 }];
|
||||
*
|
||||
* var deep = cloneDeep(objects);
|
||||
* const deep = cloneDeep(objects);
|
||||
* console.log(deep[0] === objects[0]);
|
||||
* // => false
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@ const CLONE_SYMBOLS_FLAG = 4;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* var el = cloneDeepWith(document.body, customizer);
|
||||
* const el = cloneDeepWith(document.body, customizer);
|
||||
*
|
||||
* console.log(el === document.body);
|
||||
* // => false
|
||||
|
||||
@@ -23,7 +23,7 @@ const CLONE_SYMBOLS_FLAG = 4;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* var el = cloneWith(document.body, customizer);
|
||||
* const el = cloneWith(document.body, customizer);
|
||||
*
|
||||
* console.log(el === document.body);
|
||||
* // => false
|
||||
|
||||
@@ -13,8 +13,8 @@ import copyArray from './.internal/copyArray.js';
|
||||
* @returns {Array} Returns the new concatenated array.
|
||||
* @example
|
||||
*
|
||||
* var array = [1];
|
||||
* var other = concat(array, 2, [3], [[4]]);
|
||||
* const array = [1];
|
||||
* const other = concat(array, 2, [3], [[4]]);
|
||||
*
|
||||
* console.log(other);
|
||||
* // => [1, 2, 3, [4]]
|
||||
|
||||
6
cond.js
6
cond.js
@@ -13,10 +13,10 @@ import arrayMap from './.internal/arrayMap.js';
|
||||
* @returns {Function} Returns the new composite function.
|
||||
* @example
|
||||
*
|
||||
* var func = cond([
|
||||
* [matches({ 'a': 1 }), constant('matches A')],
|
||||
* const func = cond([
|
||||
* [matches({ 'a': 1 }), constant('matches A')],
|
||||
* [conforms({ 'b': isNumber }), constant('matches B')],
|
||||
* [stubTrue, constant('no match')]
|
||||
* [stubTrue, constant('no match')]
|
||||
* ]);
|
||||
*
|
||||
* func({ 'a': 1, 'b': 2 });
|
||||
|
||||
@@ -18,7 +18,7 @@ const CLONE_DEEP_FLAG = 1;
|
||||
* @returns {Function} Returns the new spec function.
|
||||
* @example
|
||||
*
|
||||
* var objects = [
|
||||
* const objects = [
|
||||
* { 'a': 2, 'b': 1 },
|
||||
* { 'a': 1, 'b': 2 }
|
||||
* ];
|
||||
|
||||
@@ -15,7 +15,7 @@ import keys from './keys.js';
|
||||
* @returns {boolean} Returns `true` if `object` conforms, else `false`.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1, 'b': 2 };
|
||||
* const object = { 'a': 1, 'b': 2 };
|
||||
*
|
||||
* conformsTo(object, { 'b': function(n) { return n > 1; } });
|
||||
* // => true
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @returns {Function} Returns the new constant function.
|
||||
* @example
|
||||
*
|
||||
* var objects = times(2, constant({ 'a': 1 }));
|
||||
* const objects = times(2, constant({ 'a': 1 }));
|
||||
*
|
||||
* console.log(objects);
|
||||
* // => [{ 'a': 1 }, { 'a': 1 }]
|
||||
|
||||
@@ -26,7 +26,7 @@ import baseCreate from './.internal/baseCreate.js';
|
||||
* 'constructor': Circle
|
||||
* });
|
||||
*
|
||||
* var circle = new Circle;
|
||||
* const circle = new Circle;
|
||||
* circle instanceof Circle;
|
||||
* // => true
|
||||
*
|
||||
|
||||
4
curry.js
4
curry.js
@@ -23,11 +23,11 @@ const WRAP_CURRY_FLAG = 8;
|
||||
* @returns {Function} Returns the new curried function.
|
||||
* @example
|
||||
*
|
||||
* var abc = function(a, b, c) {
|
||||
* const abc = function(a, b, c) {
|
||||
* return [a, b, c];
|
||||
* };
|
||||
*
|
||||
* var curried = curry(abc);
|
||||
* const curried = curry(abc);
|
||||
*
|
||||
* curried(1)(2)(3);
|
||||
* // => [1, 2, 3]
|
||||
|
||||
@@ -20,11 +20,11 @@ const WRAP_CURRY_RIGHT_FLAG = 16;
|
||||
* @returns {Function} Returns the new curried function.
|
||||
* @example
|
||||
*
|
||||
* var abc = function(a, b, c) {
|
||||
* const abc = function(a, b, c) {
|
||||
* return [a, b, c];
|
||||
* };
|
||||
*
|
||||
* var curried = curryRight(abc);
|
||||
* const curried = curryRight(abc);
|
||||
*
|
||||
* curried(3)(2)(1);
|
||||
* // => [1, 2, 3]
|
||||
|
||||
@@ -50,8 +50,8 @@ const nativeMin = Math.min;
|
||||
* }));
|
||||
*
|
||||
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
||||
* var debounced = debounce(batchLog, 250, { 'maxWait': 1000 });
|
||||
* var source = new EventSource('/stream');
|
||||
* const debounced = debounce(batchLog, 250, { 'maxWait': 1000 });
|
||||
* const source = new EventSource('/stream');
|
||||
* jQuery(source).on('message', debounced);
|
||||
*
|
||||
* // Cancel the trailing debounced invocation.
|
||||
|
||||
4
defer.js
4
defer.js
@@ -11,9 +11,7 @@ import baseDelay from './.internal/baseDelay.js';
|
||||
* @returns {number} Returns the timer id.
|
||||
* @example
|
||||
*
|
||||
* defer(function(text) {
|
||||
* console.log(text);
|
||||
* }, 'deferred');
|
||||
* defer(text => console.log(text), 'deferred');
|
||||
* // => Logs 'deferred' after one millisecond.
|
||||
*/
|
||||
function defer(func, ...args) {
|
||||
|
||||
4
delay.js
4
delay.js
@@ -13,9 +13,7 @@ import toNumber from './toNumber.js';
|
||||
* @returns {number} Returns the timer id.
|
||||
* @example
|
||||
*
|
||||
* delay(function(text) {
|
||||
* console.log(text);
|
||||
* }, 1000, 'later');
|
||||
* delay(text => console.log(text), 1000, 'later');
|
||||
* // => Logs 'later' after one second.
|
||||
*/
|
||||
function delay(func, wait, ...args) {
|
||||
|
||||
@@ -19,7 +19,7 @@ import last from './last.js';
|
||||
* @returns {Array} Returns the new array of filtered values.
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
|
||||
* const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
|
||||
*
|
||||
* differenceWith(objects, [{ 'x': 1, 'y': 2 }], isEqual);
|
||||
* // => [{ 'x': 2, 'y': 1 }]
|
||||
|
||||
@@ -12,13 +12,13 @@ import baseWhile from './.internal/baseWhile.js';
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* const users = [
|
||||
* { 'user': 'barney', 'active': true },
|
||||
* { 'user': 'fred', 'active': false },
|
||||
* { 'user': 'pebbles', 'active': false }
|
||||
* ];
|
||||
*
|
||||
* dropRightWhile(users, function(o) { return !o.active; });
|
||||
* dropRightWhile(users, o => !o.active);
|
||||
* // => objects for ['barney']
|
||||
*/
|
||||
function dropRightWhile(array, predicate) {
|
||||
|
||||
@@ -12,13 +12,13 @@ import baseWhile from './.internal/baseWhile.js';
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* const users = [
|
||||
* { 'user': 'barney', 'active': false },
|
||||
* { 'user': 'fred', 'active': false },
|
||||
* { 'user': 'pebbles', 'active': true }
|
||||
* ];
|
||||
*
|
||||
* dropWhile(users, function(o) { return !o.active; });
|
||||
* dropWhile(users, o => !o.active);
|
||||
* // => objects for ['pebbles']
|
||||
*/
|
||||
function dropWhile(array, predicate) {
|
||||
|
||||
4
eq.js
4
eq.js
@@ -10,8 +10,8 @@
|
||||
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1 };
|
||||
* var other = { 'a': 1 };
|
||||
* const object = { 'a': 1 };
|
||||
* const other = { 'a': 1 };
|
||||
*
|
||||
* eq(object, object);
|
||||
* // => true
|
||||
|
||||
2
fill.js
2
fill.js
@@ -16,7 +16,7 @@ import isIterateeCall from './.internal/isIterateeCall.js';
|
||||
* @returns {Array} Returns `array`.
|
||||
* @example
|
||||
*
|
||||
* var array = [1, 2, 3];
|
||||
* const array = [1, 2, 3];
|
||||
*
|
||||
* fill(array, 'a');
|
||||
* console.log(array);
|
||||
|
||||
@@ -16,12 +16,12 @@ import baseFilter from './.internal/baseFilter.js';
|
||||
* @see reject
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* const users = [
|
||||
* { 'user': 'barney', 'age': 36, 'active': true },
|
||||
* { 'user': 'fred', 'age': 40, 'active': false }
|
||||
* ];
|
||||
*
|
||||
* filter(users, function(o) { return !o.active; });
|
||||
* filter(users, o => !o.active);
|
||||
* // => objects for ['fred']
|
||||
*/
|
||||
function filter(collection, predicate) {
|
||||
|
||||
4
find.js
4
find.js
@@ -14,13 +14,13 @@ import findIndex from './findIndex.js';
|
||||
* @returns {*} Returns the matched element, else `undefined`.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* const users = [
|
||||
* { 'user': 'barney', 'age': 36, 'active': true },
|
||||
* { 'user': 'fred', 'age': 40, 'active': false },
|
||||
* { 'user': 'pebbles', 'age': 1, 'active': true }
|
||||
* ];
|
||||
*
|
||||
* find(users, function(o) { return o.age < 40; });
|
||||
* find(users, o => o.age < 40);
|
||||
* // => object for 'barney'
|
||||
*/
|
||||
const find = createFind(findIndex);
|
||||
|
||||
@@ -16,13 +16,13 @@ const nativeMax = Math.max;
|
||||
* @returns {number} Returns the index of the found element, else `-1`.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* const users = [
|
||||
* { 'user': 'barney', 'active': false },
|
||||
* { 'user': 'fred', 'active': false },
|
||||
* { 'user': 'pebbles', 'active': true }
|
||||
* ];
|
||||
*
|
||||
* findIndex(users, function(o) { return o.user == 'barney'; });
|
||||
* findIndex(users, o => o.user == 'barney');
|
||||
* // => 0
|
||||
*/
|
||||
function findIndex(array, predicate, fromIndex) {
|
||||
|
||||
@@ -13,13 +13,13 @@ import baseForOwn from './.internal/baseForOwn.js';
|
||||
* else `undefined`.
|
||||
* @example
|
||||
*
|
||||
* var users = {
|
||||
* const users = {
|
||||
* 'barney': { 'age': 36, 'active': true },
|
||||
* 'fred': { 'age': 40, 'active': false },
|
||||
* 'pebbles': { 'age': 1, 'active': true }
|
||||
* };
|
||||
*
|
||||
* findKey(users, function(o) { return o.age < 40; });
|
||||
* findKey(users, o => o.age < 40);
|
||||
* // => 'barney' (iteration order is not guaranteed)
|
||||
*/
|
||||
function findKey(object, predicate) {
|
||||
|
||||
@@ -13,9 +13,7 @@ import findLastIndex from './findLastIndex.js';
|
||||
* @returns {*} Returns the matched element, else `undefined`.
|
||||
* @example
|
||||
*
|
||||
* findLast([1, 2, 3, 4], function(n) {
|
||||
* return n % 2 == 1;
|
||||
* });
|
||||
* findLast([1, 2, 3, 4], n => n % 2 == 1);
|
||||
* // => 3
|
||||
*/
|
||||
const findLast = createFind(findLastIndex);
|
||||
|
||||
@@ -17,13 +17,13 @@ const nativeMin = Math.min;
|
||||
* @returns {number} Returns the index of the found element, else `-1`.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* const users = [
|
||||
* { 'user': 'barney', 'active': true },
|
||||
* { 'user': 'fred', 'active': false },
|
||||
* { 'user': 'pebbles', 'active': false }
|
||||
* ];
|
||||
*
|
||||
* findLastIndex(users, function(o) { return o.user == 'pebbles'; });
|
||||
* findLastIndex(users, o => o.user == 'pebbles');
|
||||
* // => 2
|
||||
*/
|
||||
function findLastIndex(array, predicate, fromIndex) {
|
||||
|
||||
@@ -13,13 +13,13 @@ import baseForOwnRight from './.internal/baseForOwnRight.js';
|
||||
* else `undefined`.
|
||||
* @example
|
||||
*
|
||||
* var users = {
|
||||
* const users = {
|
||||
* 'barney': { 'age': 36, 'active': true },
|
||||
* 'fred': { 'age': 40, 'active': false },
|
||||
* 'pebbles': { 'age': 1, 'active': true }
|
||||
* };
|
||||
*
|
||||
* findLastKey(users, function(o) { return o.age < 40; });
|
||||
* findLastKey(users, o => o.age < 40);
|
||||
* // => returns 'pebbles' assuming `findKey` returns 'barney'
|
||||
*/
|
||||
function findLastKey(object, predicate) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import toInteger from './toInteger.js';
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
* @example
|
||||
*
|
||||
* var array = [1, [2, [3, [4]], 5]];
|
||||
* const array = [1, [2, [3, [4]], 5]];
|
||||
*
|
||||
* flattenDepth(array, 1);
|
||||
* // => [1, 2, [3, [4]], 5]
|
||||
|
||||
4
flip.js
4
flip.js
@@ -12,9 +12,7 @@ const WRAP_FLIP_FLAG = 512;
|
||||
* @returns {Function} Returns the new flipped function.
|
||||
* @example
|
||||
*
|
||||
* var flipped = flip(function() {
|
||||
* return toArray(arguments);
|
||||
* });
|
||||
* const flipped = flip((...args) => args);
|
||||
*
|
||||
* flipped('a', 'b', 'c', 'd');
|
||||
* // => ['d', 'c', 'b', 'a']
|
||||
|
||||
2
flow.js
2
flow.js
@@ -16,7 +16,7 @@ import createFlow from './.internal/createFlow.js';
|
||||
* return n * n;
|
||||
* }
|
||||
*
|
||||
* var addSquare = flow([add, square]);
|
||||
* const addSquare = flow([add, square]);
|
||||
* addSquare(1, 2);
|
||||
* // => 9
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,7 @@ import createFlow from './.internal/createFlow.js';
|
||||
* return n * n;
|
||||
* }
|
||||
*
|
||||
* var addSquare = flowRight([square, add]);
|
||||
* const addSquare = flowRight([square, add]);
|
||||
* addSquare(1, 2);
|
||||
* // => 9
|
||||
*/
|
||||
|
||||
@@ -19,14 +19,10 @@ import baseEach from './.internal/baseEach.js';;
|
||||
* @see forEachRight
|
||||
* @example
|
||||
*
|
||||
* forEach([1, 2], function(value) {
|
||||
* console.log(value);
|
||||
* });
|
||||
* forEach([1, 2], value => console.log(value));
|
||||
* // => Logs `1` then `2`.
|
||||
*
|
||||
* forEach({ 'a': 1, 'b': 2 }, function(value, key) {
|
||||
* console.log(key);
|
||||
* });
|
||||
* forEach({ 'a': 1, 'b': 2 }, (value, key) => console.log(key));
|
||||
* // => Logs 'a' then 'b' (iteration order is not guaranteed).
|
||||
*/
|
||||
function forEach(collection, iteratee) {
|
||||
|
||||
@@ -14,9 +14,7 @@ import baseEachRight from './.internal/baseEachRight.js';
|
||||
* @see forEach
|
||||
* @example
|
||||
*
|
||||
* forEachRight([1, 2], function(value) {
|
||||
* console.log(value);
|
||||
* });
|
||||
* forEachRight([1, 2], value => console.log(value));
|
||||
* // => Logs `2` then `1`.
|
||||
*/
|
||||
function forEachRight(collection, iteratee) {
|
||||
|
||||
2
get.js
2
get.js
@@ -12,7 +12,7 @@ import baseGet from './.internal/baseGet.js';
|
||||
* @returns {*} Returns the resolved value.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
||||
* const object = { 'a': [{ 'b': { 'c': 3 } }] };
|
||||
*
|
||||
* get(object, 'a[0].b.c');
|
||||
* // => 3
|
||||
|
||||
4
has.js
4
has.js
@@ -11,8 +11,8 @@ import hasPath from './.internal/hasPath.js';
|
||||
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': { 'b': 2 } };
|
||||
* var other = create({ 'a': create({ 'b': 2 }) });
|
||||
* const object = { 'a': { 'b': 2 } };
|
||||
* const other = create({ 'a': create({ 'b': 2 }) });
|
||||
*
|
||||
* has(object, 'a');
|
||||
* // => true
|
||||
|
||||
2
hasIn.js
2
hasIn.js
@@ -11,7 +11,7 @@ import hasPath from './.internal/hasPath.js';
|
||||
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
||||
* @example
|
||||
*
|
||||
* var object = create({ 'a': create({ 'b': 2 }) });
|
||||
* const object = create({ 'a': create({ 'b': 2 }) });
|
||||
*
|
||||
* hasIn(object, 'a');
|
||||
* // => true
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @returns {*} Returns `value`.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1 };
|
||||
* const object = { 'a': 1 };
|
||||
*
|
||||
* console.log(identity(object) === object);
|
||||
* // => true
|
||||
|
||||
@@ -16,8 +16,8 @@ import last from './last.js';
|
||||
* @returns {Array} Returns the new array of intersecting values.
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
|
||||
* var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
|
||||
* const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
|
||||
* const others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
|
||||
*
|
||||
* intersectionWith(objects, others, isEqual);
|
||||
* // => [{ 'x': 1, 'y': 2 }]
|
||||
|
||||
@@ -13,7 +13,7 @@ import identity from './identity.js';
|
||||
* @returns {Object} Returns the new inverted object.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1, 'b': 2, 'c': 1 };
|
||||
* const object = { 'a': 1, 'b': 2, 'c': 1 };
|
||||
*
|
||||
* invert(object);
|
||||
* // => { '1': 'c', '2': 'b' }
|
||||
|
||||
@@ -17,11 +17,9 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
* @returns {Object} Returns the new inverted object.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1, 'b': 2, 'c': 1 };
|
||||
* const object = { 'a': 1, 'b': 2, 'c': 1 };
|
||||
*
|
||||
* invertBy(object, function(value) {
|
||||
* return 'group' + value;
|
||||
* });
|
||||
* invertBy(object, value => `group${ value }`);
|
||||
* // => { 'group1': ['a', 'c'], 'group2': ['b'] }
|
||||
*/
|
||||
const invertBy = createInverter((result, value, key) => {
|
||||
|
||||
@@ -11,7 +11,7 @@ import baseInvoke from './.internal/baseInvoke.js';
|
||||
* @returns {*} Returns the result of the invoked method.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
|
||||
* const object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
|
||||
*
|
||||
* invoke(object, 'a[0].b.c.slice', 1, 3);
|
||||
* // => [2, 3]
|
||||
|
||||
@@ -17,8 +17,8 @@ import baseIsEqual from './.internal/baseIsEqual.js';
|
||||
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1 };
|
||||
* var other = { 'a': 1 };
|
||||
* const object = { 'a': 1 };
|
||||
* const other = { 'a': 1 };
|
||||
*
|
||||
* isEqual(object, other);
|
||||
* // => true
|
||||
|
||||
@@ -24,8 +24,8 @@ import baseIsEqual from './.internal/baseIsEqual.js';
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* var array = ['hello', 'goodbye'];
|
||||
* var other = ['hi', 'goodbye'];
|
||||
* const array = ['hello', 'goodbye'];
|
||||
* const other = ['hi', 'goodbye'];
|
||||
*
|
||||
* isEqualWith(array, other, customizer);
|
||||
* // => true
|
||||
|
||||
@@ -19,7 +19,7 @@ import getMatchData from './.internal/getMatchData.js';
|
||||
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1, 'b': 2 };
|
||||
* const object = { 'a': 1, 'b': 2 };
|
||||
*
|
||||
* isMatch(object, { 'b': 2 });
|
||||
* // => true
|
||||
|
||||
@@ -25,8 +25,8 @@ import getMatchData from './.internal/getMatchData.js';
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* var object = { 'greeting': 'hello' };
|
||||
* var source = { 'greeting': 'hi' };
|
||||
* const object = { 'greeting': 'hello' };
|
||||
* const source = { 'greeting': 'hi' };
|
||||
*
|
||||
* isMatchWith(object, source, customizer);
|
||||
* // => true
|
||||
|
||||
2
keyBy.js
2
keyBy.js
@@ -14,7 +14,7 @@ import createAggregator from './.internal/createAggregator.js';
|
||||
* @returns {Object} Returns the composed aggregate object.
|
||||
* @example
|
||||
*
|
||||
* var array = [
|
||||
* const array = [
|
||||
* { 'dir': 'left', 'code': 97 },
|
||||
* { 'dir': 'right', 'code': 100 }
|
||||
* ];
|
||||
|
||||
@@ -15,12 +15,12 @@ import baseForOwn from './.internal/baseForOwn.js';
|
||||
* @see mapKeys
|
||||
* @example
|
||||
*
|
||||
* var users = {
|
||||
* const users = {
|
||||
* 'fred': { 'user': 'fred', 'age': 40 },
|
||||
* 'pebbles': { 'user': 'pebbles', 'age': 1 }
|
||||
* };
|
||||
*
|
||||
* mapValues(users, function(o) { return o.age; });
|
||||
* mapValues(users, o => o.age);
|
||||
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
|
||||
*/
|
||||
function mapValues(object, iteratee) {
|
||||
|
||||
@@ -22,7 +22,7 @@ const CLONE_DEEP_FLAG = 1;
|
||||
* @returns {Function} Returns the new spec function.
|
||||
* @example
|
||||
*
|
||||
* var objects = [
|
||||
* const objects = [
|
||||
* { 'a': 1, 'b': 2, 'c': 3 },
|
||||
* { 'a': 4, 'b': 5, 'c': 6 }
|
||||
* ];
|
||||
|
||||
@@ -20,7 +20,7 @@ const CLONE_DEEP_FLAG = 1;
|
||||
* @returns {Function} Returns the new spec function.
|
||||
* @example
|
||||
*
|
||||
* var objects = [
|
||||
* const objects = [
|
||||
* { 'a': 1, 'b': 2, 'c': 3 },
|
||||
* { 'a': 4, 'b': 5, 'c': 6 }
|
||||
* ];
|
||||
|
||||
4
maxBy.js
4
maxBy.js
@@ -13,9 +13,9 @@ import baseGt from './.internal/baseGt.js';
|
||||
* @returns {*} Returns the maximum value.
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'n': 1 }, { 'n': 2 }];
|
||||
* const objects = [{ 'n': 1 }, { 'n': 2 }];
|
||||
*
|
||||
* maxBy(objects, function(o) { return o.n; });
|
||||
* maxBy(objects, o => o.n);
|
||||
* // => { 'n': 2 }
|
||||
*/
|
||||
function maxBy(array, iteratee) {
|
||||
|
||||
@@ -15,9 +15,9 @@ const NAN = 0 / 0;
|
||||
* @returns {number} Returns the mean.
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
|
||||
* const objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
|
||||
*
|
||||
* meanBy(objects, function(o) { return o.n; });
|
||||
* meanBy(objects, o => o.n);
|
||||
* // => 5
|
||||
*/
|
||||
function meanBy(array, iteratee) {
|
||||
|
||||
@@ -20,10 +20,10 @@ import MapCache from './.internal/MapCache.js';
|
||||
* @returns {Function} Returns the new memoized function.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1, 'b': 2 };
|
||||
* var other = { 'c': 3, 'd': 4 };
|
||||
* const object = { 'a': 1, 'b': 2 };
|
||||
* const other = { 'c': 3, 'd': 4 };
|
||||
*
|
||||
* var values = memoize(values);
|
||||
* const values = memoize(values);
|
||||
* values(object);
|
||||
* // => [1, 2]
|
||||
*
|
||||
|
||||
4
merge.js
4
merge.js
@@ -19,11 +19,11 @@ import createAssigner from './.internal/createAssigner.js';
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* var object = {
|
||||
* const object = {
|
||||
* 'a': [{ 'b': 2 }, { 'd': 4 }]
|
||||
* };
|
||||
*
|
||||
* var other = {
|
||||
* const other = {
|
||||
* 'a': [{ 'c': 3 }, { 'e': 5 }]
|
||||
* };
|
||||
*
|
||||
|
||||
@@ -24,8 +24,8 @@ import createAssigner from './.internal/createAssigner.js';
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* var object = { 'a': [1], 'b': [2] };
|
||||
* var other = { 'a': [3], 'b': [4] };
|
||||
* const object = { 'a': [1], 'b': [2] };
|
||||
* const other = { 'a': [3], 'b': [4] };
|
||||
*
|
||||
* mergeWith(object, other, customizer);
|
||||
* // => { 'a': [1, 3], 'b': [2, 4] }
|
||||
|
||||
@@ -11,7 +11,7 @@ import baseInvoke from './.internal/baseInvoke.js';
|
||||
* @returns {Function} Returns the new invoker function.
|
||||
* @example
|
||||
*
|
||||
* var objects = [
|
||||
* const objects = [
|
||||
* { 'a': { 'b': constant(2) } },
|
||||
* { 'a': { 'b': constant(1) } }
|
||||
* ];
|
||||
|
||||
@@ -12,8 +12,8 @@ import baseInvoke from './.internal/baseInvoke.js';
|
||||
* @returns {Function} Returns the new invoker function.
|
||||
* @example
|
||||
*
|
||||
* var array = times(3, constant),
|
||||
* object = { 'a': array, 'b': array, 'c': array };
|
||||
* const array = times(3, constant);
|
||||
* const object = { 'a': array, 'b': array, 'c': array };
|
||||
*
|
||||
* map(['a[2]', 'c[0]'], methodOf(object));
|
||||
* // => [2, 0]
|
||||
|
||||
4
minBy.js
4
minBy.js
@@ -13,9 +13,9 @@ import baseLt from './.internal/baseLt.js';
|
||||
* @returns {*} Returns the minimum value.
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'n': 1 }, { 'n': 2 }];
|
||||
* const objects = [{ 'n': 1 }, { 'n': 2 }];
|
||||
*
|
||||
* minBy(objects, function(o) { return o.n; });
|
||||
* minBy(objects, o => o.n);
|
||||
* // => { 'n': 1 }
|
||||
*/
|
||||
function minBy(array, iteratee) {
|
||||
|
||||
2
nth.js
2
nth.js
@@ -12,7 +12,7 @@ import toInteger from './toInteger.js';
|
||||
* @returns {*} Returns the nth element of `array`.
|
||||
* @example
|
||||
*
|
||||
* var array = ['a', 'b', 'c', 'd'];
|
||||
* const array = ['a', 'b', 'c', 'd'];
|
||||
*
|
||||
* nth(array, 1);
|
||||
* // => 'b'
|
||||
|
||||
@@ -11,11 +11,11 @@ import toInteger from './toInteger.js';
|
||||
* @returns {Function} Returns the new pass-thru function.
|
||||
* @example
|
||||
*
|
||||
* var func = nthArg(1);
|
||||
* const func = nthArg(1);
|
||||
* func('a', 'b', 'c', 'd');
|
||||
* // => 'b'
|
||||
*
|
||||
* var func = nthArg(-2);
|
||||
* const func = nthArg(-2);
|
||||
* func('a', 'b', 'c', 'd');
|
||||
* // => 'c'
|
||||
*/
|
||||
|
||||
2
once.js
2
once.js
@@ -11,7 +11,7 @@ import before from './before.js';
|
||||
* @returns {Function} Returns the new restricted function.
|
||||
* @example
|
||||
*
|
||||
* var initialize = once(createApplication);
|
||||
* const initialize = once(createApplication);
|
||||
* initialize();
|
||||
* initialize();
|
||||
* // => `createApplication` is invoked once
|
||||
|
||||
@@ -16,7 +16,7 @@ import baseOrderBy from './.internal/baseOrderBy.js';
|
||||
* @returns {Array} Returns the new sorted array.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* const users = [
|
||||
* { 'user': 'fred', 'age': 48 },
|
||||
* { 'user': 'barney', 'age': 34 },
|
||||
* { 'user': 'fred', 'age': 40 },
|
||||
|
||||
2
over.js
2
over.js
@@ -12,7 +12,7 @@ import createOver from './.internal/createOver.js';
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var func = over([Math.max, Math.min]);
|
||||
* const func = over([Math.max, Math.min]);
|
||||
*
|
||||
* func(1, 2, 3, 4);
|
||||
* // => [4, 1]
|
||||
|
||||
@@ -23,9 +23,7 @@ const nativeMin = Math.min;
|
||||
* return n * n;
|
||||
* }
|
||||
*
|
||||
* var func = overArgs(function(x, y) {
|
||||
* return [x, y];
|
||||
* }, [square, doubled]);
|
||||
* const func = overArgs((x, y) => [x, y], [square, doubled]);
|
||||
*
|
||||
* func(9, 3);
|
||||
* // => [81, 6]
|
||||
|
||||
@@ -12,7 +12,7 @@ import createOver from './.internal/createOver.js';
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var func = overEvery([Boolean, isFinite]);
|
||||
* const func = overEvery([Boolean, isFinite]);
|
||||
*
|
||||
* func('1');
|
||||
* // => true
|
||||
|
||||
@@ -12,7 +12,7 @@ import createOver from './.internal/createOver.js';
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var func = overSome([Boolean, isFinite]);
|
||||
* const func = overSome([Boolean, isFinite]);
|
||||
*
|
||||
* func('1');
|
||||
* // => true
|
||||
|
||||
@@ -13,13 +13,13 @@ import createAggregator from './.internal/createAggregator.js';
|
||||
* @returns {Array} Returns the array of grouped elements.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* const users = [
|
||||
* { 'user': 'barney', 'age': 36, 'active': false },
|
||||
* { 'user': 'fred', 'age': 40, 'active': true },
|
||||
* { 'user': 'pebbles', 'age': 1, 'active': false }
|
||||
* ];
|
||||
*
|
||||
* partition(users, function(o) { return o.active; });
|
||||
* partition(users, o => o.active);
|
||||
* // => objects for [['fred'], ['barney', 'pebbles']]
|
||||
*/
|
||||
const partition = createAggregator((result, value, key) =>
|
||||
|
||||
2
pick.js
2
pick.js
@@ -10,7 +10,7 @@ import basePick from './.internal/basePick.js';
|
||||
* @returns {Object} Returns the new object.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1, 'b': '2', 'c': 3 };
|
||||
* const object = { 'a': 1, 'b': '2', 'c': 3 };
|
||||
*
|
||||
* pick(object, ['a', 'c']);
|
||||
* // => { 'a': 1, 'c': 3 }
|
||||
|
||||
@@ -13,7 +13,7 @@ import getAllKeysIn from './.internal/getAllKeysIn.js';
|
||||
* @returns {Object} Returns the new object.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1, 'b': '2', 'c': 3 };
|
||||
* const object = { 'a': 1, 'b': '2', 'c': 3 };
|
||||
*
|
||||
* pickBy(object, isNumber);
|
||||
* // => { 'a': 1, 'c': 3 }
|
||||
|
||||
@@ -12,7 +12,7 @@ import toKey from './.internal/toKey.js';
|
||||
* @returns {Function} Returns the new accessor function.
|
||||
* @example
|
||||
*
|
||||
* var objects = [
|
||||
* const objects = [
|
||||
* { 'a': { 'b': 2 } },
|
||||
* { 'a': { 'b': 1 } }
|
||||
* ];
|
||||
|
||||
@@ -10,8 +10,8 @@ import baseGet from './.internal/baseGet.js';
|
||||
* @returns {Function} Returns the new accessor function.
|
||||
* @example
|
||||
*
|
||||
* var array = [0, 1, 2],
|
||||
* object = { 'a': array, 'b': array, 'c': array };
|
||||
* const array = [0, 1, 2];
|
||||
* const object = { 'a': array, 'b': array, 'c': array };
|
||||
*
|
||||
* map(['a[2]', 'c[0]'], propertyOf(object));
|
||||
* // => [2, 0]
|
||||
|
||||
2
pull.js
2
pull.js
@@ -15,7 +15,7 @@ import pullAll from './pullAll.js';
|
||||
* @returns {Array} Returns `array`.
|
||||
* @example
|
||||
*
|
||||
* var array = ['a', 'b', 'c', 'a', 'b', 'c'];
|
||||
* const array = ['a', 'b', 'c', 'a', 'b', 'c'];
|
||||
*
|
||||
* pull(array, 'a', 'c');
|
||||
* console.log(array);
|
||||
|
||||
@@ -12,7 +12,7 @@ import basePullAll from './.internal/basePullAll.js';
|
||||
* @returns {Array} Returns `array`.
|
||||
* @example
|
||||
*
|
||||
* var array = ['a', 'b', 'c', 'a', 'b', 'c'];
|
||||
* const array = ['a', 'b', 'c', 'a', 'b', 'c'];
|
||||
*
|
||||
* pullAll(array, ['a', 'c']);
|
||||
* console.log(array);
|
||||
|
||||
@@ -15,7 +15,7 @@ import basePullAll from './.internal/basePullAll.js';
|
||||
* @returns {Array} Returns `array`.
|
||||
* @example
|
||||
*
|
||||
* var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
|
||||
* const array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
|
||||
*
|
||||
* pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
|
||||
* console.log(array);
|
||||
|
||||
@@ -15,7 +15,7 @@ import basePullAll from './.internal/basePullAll.js';
|
||||
* @returns {Array} Returns `array`.
|
||||
* @example
|
||||
*
|
||||
* var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
|
||||
* const array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
|
||||
*
|
||||
* pullAllWith(array, [{ 'x': 3, 'y': 4 }], isEqual);
|
||||
* console.log(array);
|
||||
|
||||
@@ -17,8 +17,8 @@ import isIndex from './.internal/isIndex.js';
|
||||
* @returns {Array} Returns the new array of removed elements.
|
||||
* @example
|
||||
*
|
||||
* var array = ['a', 'b', 'c', 'd'];
|
||||
* var pulled = pullAt(array, [1, 3]);
|
||||
* const array = ['a', 'b', 'c', 'd'];
|
||||
* const pulled = pullAt(array, [1, 3]);
|
||||
*
|
||||
* console.log(array);
|
||||
* // => ['a', 'c']
|
||||
|
||||
6
rearg.js
6
rearg.js
@@ -16,11 +16,9 @@ const WRAP_REARG_FLAG = 256;
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var rearged = rearg(function(a, b, c) {
|
||||
* return [a, b, c];
|
||||
* }, [2, 0, 1]);
|
||||
* const rearged = rearg((a, b, c) => [a, b, c], [2, 0, 1]);
|
||||
*
|
||||
* rearged('b', 'c', 'a')
|
||||
* rearged('b', 'c', 'a');
|
||||
* // => ['a', 'b', 'c']
|
||||
*/
|
||||
function rearg(func, ...indexes) {
|
||||
|
||||
@@ -26,12 +26,10 @@ import baseReduce from './.internal/baseReduce.js';
|
||||
* @see reduceRight
|
||||
* @example
|
||||
*
|
||||
* reduce([1, 2], function(sum, n) {
|
||||
* return sum + n;
|
||||
* }, 0);
|
||||
* reduce([1, 2], (sum, n) => sum + n, 0);
|
||||
* // => 3
|
||||
*
|
||||
* reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
|
||||
* reduce({ 'a': 1, 'b': 2, 'c': 1 }, (result, value, key) => {
|
||||
* (result[value] || (result[value] = [])).push(key);
|
||||
* return result;
|
||||
* }, {});
|
||||
|
||||
@@ -15,11 +15,9 @@ import baseReduce from './.internal/baseReduce.js';
|
||||
* @see reduce
|
||||
* @example
|
||||
*
|
||||
* var array = [[0, 1], [2, 3], [4, 5]];
|
||||
* const array = [[0, 1], [2, 3], [4, 5]];
|
||||
*
|
||||
* reduceRight(array, function(flattened, other) {
|
||||
* return flattened.concat(other);
|
||||
* }, []);
|
||||
* reduceRight(array, (flattened, other) => flattened.concat(other), []);
|
||||
* // => [4, 5, 2, 3, 0, 1]
|
||||
*/
|
||||
function reduceRight(collection, iteratee, accumulator) {
|
||||
|
||||
@@ -14,12 +14,12 @@ import negate from './negate.js';
|
||||
* @see filter
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* const users = [
|
||||
* { 'user': 'barney', 'age': 36, 'active': false },
|
||||
* { 'user': 'fred', 'age': 40, 'active': true }
|
||||
* ];
|
||||
*
|
||||
* reject(users, function(o) { return !o.active; });
|
||||
* reject(users, o => !o.active);
|
||||
* // => objects for ['fred']
|
||||
*/
|
||||
function reject(collection, predicate) {
|
||||
|
||||
@@ -15,10 +15,8 @@ import basePullAt from './.internal/basePullAt.js';
|
||||
* @returns {Array} Returns the new array of removed elements.
|
||||
* @example
|
||||
*
|
||||
* var array = [1, 2, 3, 4];
|
||||
* var evens = remove(array, function(n) {
|
||||
* return n % 2 == 0;
|
||||
* });
|
||||
* const array = [1, 2, 3, 4];
|
||||
* const evens = remove(array, n => n % 2 == 0);
|
||||
*
|
||||
* console.log(array);
|
||||
* // => [1, 3]
|
||||
|
||||
@@ -15,7 +15,7 @@ import toKey from './.internal/toKey.js';
|
||||
* @returns {*} Returns the resolved value.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': [{ 'b': { 'c1': 3, 'c2': constant(4) } }] };
|
||||
* const object = { 'a': [{ 'b': { 'c1': 3, 'c2': constant(4) } }] };
|
||||
*
|
||||
* result(object, 'a[0].b.c1');
|
||||
* // => 3
|
||||
|
||||
@@ -14,7 +14,7 @@ const nativeReverse = Array.prototype.reverse;
|
||||
* @returns {Array} Returns `array`.
|
||||
* @example
|
||||
*
|
||||
* var array = [1, 2, 3];
|
||||
* const array = [1, 2, 3];
|
||||
*
|
||||
* reverse(array);
|
||||
* // => [3, 2, 1]
|
||||
|
||||
2
set.js
2
set.js
@@ -16,7 +16,7 @@ import baseSet from './.internal/baseSet.js';
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
||||
* const object = { 'a': [{ 'b': { 'c': 3 } }] };
|
||||
*
|
||||
* set(object, 'a[0].b.c', 4);
|
||||
* console.log(object.a[0].b.c);
|
||||
|
||||
@@ -17,7 +17,7 @@ import baseSet from './.internal/baseSet.js';
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* var object = {};
|
||||
* const object = {};
|
||||
*
|
||||
* setWith(object, '[0][1]', 'a', Object);
|
||||
* // => { '0': { '1': 'a' } }
|
||||
|
||||
@@ -14,9 +14,9 @@ import baseSortedIndexBy from './.internal/baseSortedIndexBy.js';
|
||||
* into `array`.
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'x': 4 }, { 'x': 5 }];
|
||||
* const objects = [{ 'x': 4 }, { 'x': 5 }];
|
||||
*
|
||||
* sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
|
||||
* sortedIndexBy(objects, { 'x': 4 }, o => o.x);
|
||||
* // => 0
|
||||
*/
|
||||
function sortedIndexBy(array, value, iteratee) {
|
||||
|
||||
@@ -14,9 +14,9 @@ import baseSortedIndexBy from './.internal/baseSortedIndexBy.js';
|
||||
* into `array`.
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'x': 4 }, { 'x': 5 }];
|
||||
* const objects = [{ 'x': 4 }, { 'x': 5 }];
|
||||
*
|
||||
* sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
|
||||
* sortedLastIndexBy(objects, { 'x': 4 }, o => o.x);
|
||||
* // => 1
|
||||
*/
|
||||
function sortedLastIndexBy(array, value, iteratee) {
|
||||
|
||||
10
spread.js
10
spread.js
@@ -21,21 +21,17 @@ const nativeMax = Math.max;
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var say = spread(function(who, what) {
|
||||
* return who + ' says ' + what;
|
||||
* });
|
||||
* const say = spread((who, what) => `${ who } says ${ what }`);
|
||||
*
|
||||
* say(['fred', 'hello']);
|
||||
* // => 'fred says hello'
|
||||
*
|
||||
* var numbers = Promise.all([
|
||||
* const numbers = Promise.all([
|
||||
* Promise.resolve(40),
|
||||
* Promise.resolve(36)
|
||||
* ]);
|
||||
*
|
||||
* numbers.then(spread(function(x, y) {
|
||||
* return x + y;
|
||||
* }));
|
||||
* numbers.then(spread((x, y) => x + y));
|
||||
* // => a Promise of 76
|
||||
*/
|
||||
function spread(func, start) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* @returns {Array} Returns the new empty array.
|
||||
* @example
|
||||
*
|
||||
* var arrays = times(2, stubArray);
|
||||
* const arrays = times(2, stubArray);
|
||||
*
|
||||
* console.log(arrays);
|
||||
* // => [[], []]
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* @returns {Object} Returns the new empty object.
|
||||
* @example
|
||||
*
|
||||
* var objects = times(2, stubObject);
|
||||
* const objects = times(2, stubObject);
|
||||
*
|
||||
* console.log(objects);
|
||||
* // => [{}, {}]
|
||||
|
||||
4
sumBy.js
4
sumBy.js
@@ -12,9 +12,9 @@ import baseSum from './.internal/baseSum.js';
|
||||
* @returns {number} Returns the sum.
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
|
||||
* const objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
|
||||
*
|
||||
* sumBy(objects, function(o) { return o.n; });
|
||||
* sumBy(objects, o => o.n);
|
||||
* // => 20
|
||||
*/
|
||||
function sumBy(array, iteratee) {
|
||||
|
||||
@@ -12,13 +12,13 @@ import baseWhile from './.internal/baseWhile.js';
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* const users = [
|
||||
* { 'user': 'barney', 'active': true },
|
||||
* { 'user': 'fred', 'active': false },
|
||||
* { 'user': 'pebbles', 'active': false }
|
||||
* ];
|
||||
*
|
||||
* takeRightWhile(users, function(o) { return !o.active; });
|
||||
* takeRightWhile(users, o => !o.active);
|
||||
* // => objects for ['fred', 'pebbles']
|
||||
*/
|
||||
function takeRightWhile(array, predicate) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user