Skip to content

Commit

Permalink
Update doc examples to ES2015.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jan 10, 2017
1 parent 8c97051 commit ef2c4bf
Show file tree
Hide file tree
Showing 113 changed files with 188 additions and 228 deletions.
11 changes: 3 additions & 8 deletions after.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion assignInWith.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion assignWith.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion at.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 2 additions & 3 deletions attempt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
6 changes: 3 additions & 3 deletions bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!'
*/
Expand Down
6 changes: 2 additions & 4 deletions bindAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
6 changes: 3 additions & 3 deletions bindKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!'
*
Expand All @@ -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!'
*/
Expand Down
2 changes: 1 addition & 1 deletion castArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* castArray();
* // => []
*
* var array = [1, 2, 3];
* const array = [1, 2, 3];
* console.log(castArray(array) === array);
* // => true
*/
Expand Down
4 changes: 2 additions & 2 deletions clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
4 changes: 2 additions & 2 deletions cloneDeep.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion cloneDeepWith.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cloneWith.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
6 changes: 3 additions & 3 deletions cond.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
2 changes: 1 addition & 1 deletion conforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
* ];
Expand Down
2 changes: 1 addition & 1 deletion conformsTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }]
Expand Down
2 changes: 1 addition & 1 deletion create.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import baseCreate from './.internal/baseCreate.js';
* 'constructor': Circle
* });
*
* var circle = new Circle;
* const circle = new Circle;
* circle instanceof Circle;
* // => true
*
Expand Down
4 changes: 2 additions & 2 deletions curry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions curryRight.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions debounce.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions defer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions delay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion differenceWith.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }]
Expand Down
4 changes: 2 additions & 2 deletions dropRightWhile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions dropWhile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions eq.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions find.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions findIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit ef2c4bf

Please sign in to comment.