Skip to content

Commit

Permalink
- Renamed pick to pickIn and pickKeys to pick
Browse files Browse the repository at this point in the history
- Renamed `skip` to `skipIn` and `skipKeys` to `skip`
  • Loading branch information
ascartabelli committed Jun 30, 2020
1 parent 74338b0 commit cf45fe5
Show file tree
Hide file tree
Showing 19 changed files with 391 additions and 391 deletions.
162 changes: 81 additions & 81 deletions dist/lamb.esm.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @overview lamb - A lightweight, and docile, JavaScript library to help embracing functional programming.
* @author Andrea Scartabelli <andrea.scartabelli@gmail.com>
* @version 0.59.0-alpha.3
* @version 0.59.0-alpha.4
* @module lamb
* @license MIT
*/
Expand Down Expand Up @@ -5934,19 +5934,19 @@ function pathSatisfies (predicate, path, separator) {
* @example
* var user = {name: "john", surname: "doe", age: 30};
*
* _.pick(user, ["name", "age"]) // => {"name": "john", "age": 30};
* _.pick(user, ["name", "email"]) // => {"name": "john"}
* _.pickIn(user, ["name", "age"]) // => {"name": "john", "age": 30};
* _.pickIn(user, ["name", "email"]) // => {"name": "john"}
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.pickIf|pickIf}, {@link module:lamb.pickKeys|pickKeys}
* @see {@link module:lamb.skip|skip}, {@link module:lamb.skipIf|skipIf}
* @see {@link module:lamb.pickIf|pickIf}, {@link module:lamb.pick|pick}
* @see {@link module:lamb.skipIn|skipIn}, {@link module:lamb.skipIf|skipIf}
* @since 0.1.0
* @param {Object} source
* @param {String[]} whitelist
* @returns {Object}
*/
function pick (source, whitelist) {
function pickIn (source, whitelist) {
var result = {};

for (var i = 0, len = whitelist.length, key; i < len; i++) {
Expand All @@ -5960,6 +5960,45 @@ function pick (source, whitelist) {
return result;
}

/**
* A curried version of {@link module:lamb.pickIn|pickIn}, expecting a whitelist of keys to build
* a function waiting for the object to act upon.
* @example
* var user = {id: 1, name: "Jane", surname: "Doe", active: false};
* var getUserInfo = _.pick(["id", "active"]);
*
* getUserInfo(user) // => {id: 1, active: false}
*
* @example <caption>A useful composition with <code>mapWith</code>:</caption>
* var users = [
* {id: 1, name: "Jane", surname: "Doe", active: false},
* {id: 2, name: "John", surname: "Doe", active: true},
* {id: 3, name: "Mario", surname: "Rossi", active: true},
* {id: 4, name: "Paolo", surname: "Bianchi", active: false}
* ];
* var select = _.compose(_.mapWith, _.pick);
* var selectUserInfo = select(["id", "active"]);
*
* selectUserInfo(users) // =>
* // [
* // {id: 1, active: false},
* // {id: 2, active: true},
* // {id: 3, active: true},
* // {id: 4, active: false}
* // ]
*
* @memberof module:lamb
* @category Object
* @function
* @see {@link module:lamb.pickIn|pickIn}, {@link module:lamb.pickIf|pickIf}
* @see {@link module:lamb.skipIn|skipIn}, {@link module:lamb.skip|skip},
* {@link module:lamb.skipIf|skipIf}
* @since 0.35.0
* @param {String[]} whitelist
* @returns {Function}
*/
var pick = _curry2(pickIn, true);

/**
* Builds a function expecting an object whose enumerable properties will be checked
* against the given predicate.<br/>
Expand All @@ -5972,8 +6011,8 @@ function pick (source, whitelist) {
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.pick|pick}, {@link module:lamb.pickKeys|pickKeys}
* @see {@link module:lamb.skip|skip}, {@link module:lamb.skipKeys|skipKeys},
* @see {@link module:lamb.pickIn|pickIn}, {@link module:lamb.pick|pick}
* @see {@link module:lamb.skipIn|skipIn}, {@link module:lamb.skip|skip},
* {@link module:lamb.skipIf|skipIf}
* @since 0.1.0
* @param {ObjectIteratorCallback} predicate
Expand All @@ -5997,45 +6036,6 @@ function pickIf (predicate) {
};
}

/**
* A curried version of {@link module:lamb.pick|pick}, expecting a whitelist of keys to build
* a function waiting for the object to act upon.
* @example
* var user = {id: 1, name: "Jane", surname: "Doe", active: false};
* var getUserInfo = _.pickKeys(["id", "active"]);
*
* getUserInfo(user) // => {id: 1, active: false}
*
* @example <caption>A useful composition with <code>mapWith</code>:</caption>
* var users = [
* {id: 1, name: "Jane", surname: "Doe", active: false},
* {id: 2, name: "John", surname: "Doe", active: true},
* {id: 3, name: "Mario", surname: "Rossi", active: true},
* {id: 4, name: "Paolo", surname: "Bianchi", active: false}
* ];
* var select = _.compose(_.mapWith, _.pickKeys);
* var selectUserInfo = select(["id", "active"]);
*
* selectUserInfo(users) // =>
* // [
* // {id: 1, active: false},
* // {id: 2, active: true},
* // {id: 3, active: true},
* // {id: 4, active: false}
* // ]
*
* @memberof module:lamb
* @category Object
* @function
* @see {@link module:lamb.pick|pick}, {@link module:lamb.pickIf|pickIf}
* @see {@link module:lamb.skip|skip}, {@link module:lamb.skipKeys|skipKeys},
* {@link module:lamb.skipIf|skipIf}
* @since 0.35.0
* @param {String[]} whitelist
* @returns {Function}
*/
var pickKeys = _curry2(pick, true);

/**
* Creates a copy of the given object with its enumerable keys renamed as
* indicated in the provided lookup table.
Expand Down Expand Up @@ -6357,20 +6357,20 @@ function setPath (path, value, separator) {
* @example
* var user = {name: "john", surname: "doe", age: 30};
*
* _.skip(user, ["name", "age"]) // => {surname: "doe"};
* _.skip(user, ["name", "email"]) // => {surname: "doe", age: 30};
* _.skipIn(user, ["name", "age"]) // => {surname: "doe"};
* _.skipIn(user, ["name", "email"]) // => {surname: "doe", age: 30};
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.skipKeys|skipKeys}, {@link module:lamb.skipIf|skipIf}
* @see {@link module:lamb.pick|pick}, {@link module:lamb.pickKeys|pickKeys},
* @see {@link module:lamb.skip|skip}, {@link module:lamb.skipIf|skipIf}
* @see {@link module:lamb.pickIn|pickIn}, {@link module:lamb.pick|pick},
* {@link module:lamb.pickIf|pickIf}
* @since 0.1.0
* @param {Object} source
* @param {String[]} blacklist
* @returns {Object}
*/
function skip (source, blacklist) {
function skipIn (source, blacklist) {
if (isNil(source)) {
throw _makeTypeErrorFor(source, "object");
}
Expand All @@ -6388,33 +6388,11 @@ function skip (source, blacklist) {
}

/**
* Builds a function expecting an object whose enumerable properties will be checked
* against the given predicate.<br/>
* The properties satisfying the predicate will be omitted in the resulting object.
* @example
* var user = {name: "john", surname: "doe", age: 30};
* var skipIfIstring = _.skipIf(_.isType("String"));
*
* skipIfIstring(user) // => {age: 30}
*
* @memberof module:lamb
* @category Object
* @function
* @see {@link module:lamb.skip|skip}, {@link module:lamb.skipKeys|skipKeys}
* @see {@link module:lamb.pick|pick}, {@link module:lamb.pickKeys|pickKeys},
* {@link module:lamb.pickIf|pickIf}
* @since 0.1.0
* @param {ObjectIteratorCallback} predicate
* @returns {Function}
*/
var skipIf = compose(pickIf, not);

/**
* A curried version of {@link module:lamb.skip|skip}, expecting a blacklist of keys to build
* A curried version of {@link module:lamb.skipIn|skipIn}, expecting a blacklist of keys to build
* a function waiting for the object to act upon.
* @example
* var user = {id: 1, name: "Jane", surname: "Doe", active: false};
* var getUserInfo = _.skipKeys(["name", "surname"]);
* var getUserInfo = _.skip(["name", "surname"]);
*
* getUserInfo(user) // => {id: 1, active: false}
*
Expand All @@ -6425,7 +6403,7 @@ var skipIf = compose(pickIf, not);
* {id: 3, name: "Mario", surname: "Rossi", active: true},
* {id: 4, name: "Paolo", surname: "Bianchi", active: false}
* ];
* var discard = _.compose(_.mapWith, _.skipKeys);
* var discard = _.compose(_.mapWith, _.skip);
* var discardNames = discard(["name", "surname"]);
*
* discardNames(users) // =>
Expand All @@ -6439,14 +6417,36 @@ var skipIf = compose(pickIf, not);
* @memberof module:lamb
* @category Object
* @function
* @see {@link module:lamb.skip|skip}, {@link module:lamb.skipIf|skipIf}
* @see {@link module:lamb.pick|pick}, {@link module:lamb.pickKeys|pickKeys},
* @see {@link module:lamb.skipIn|skipIn}, {@link module:lamb.skipIf|skipIf}
* @see {@link module:lamb.pickIn|pickIn}, {@link module:lamb.pick|pick},
* {@link module:lamb.pickIf|pickIf}
* @since 0.35.0
* @param {String[]} blacklist
* @returns {Function}
*/
var skipKeys = _curry2(skip, true);
var skip = _curry2(skipIn, true);

/**
* Builds a function expecting an object whose enumerable properties will be checked
* against the given predicate.<br/>
* The properties satisfying the predicate will be omitted in the resulting object.
* @example
* var user = {name: "john", surname: "doe", age: 30};
* var skipIfIstring = _.skipIf(_.isType("String"));
*
* skipIfIstring(user) // => {age: 30}
*
* @memberof module:lamb
* @category Object
* @function
* @see {@link module:lamb.skipIn|skipIn}, {@link module:lamb.skip|skip}
* @see {@link module:lamb.pickIn|pickIn}, {@link module:lamb.pick|pick},
* {@link module:lamb.pickIf|pickIf}
* @since 0.1.0
* @param {ObjectIteratorCallback} predicate
* @returns {Function}
*/
var skipIf = compose(pickIf, not);

/**
* Using the provided function to retrieve the keys of an object, builds
Expand Down Expand Up @@ -6975,4 +6975,4 @@ function isType (typeName) {
};
}

export { __, adapter, add, allOf, always, anyOf, append, appendTo, application, apply, applyTo, areSVZ, areSame, aritize, asPartial, binary, case_ as case, checker, clamp, clampWithin, collect, compose, condition, contains, count, countBy, curry, curryRight, curryable, curryableRight, debounce, deduct, difference, divide, divideBy, drop, dropFrom, dropLastWhile, dropWhile, enumerables, every, everyIn, filter, filterWith, find, findIndex, findIndexWhere, findLast, findLastIndex, findLastIndexWhere, findLastWhere, findWhere, flatMap, flatMapWith, flatten, flip, forEach, fromPairs, generate, generic, getArgAt, getAt, getIn, getIndex, getKey, getPath, getPathIn, group, groupBy, gt, gte, has, hasKey, hasKeyValue, hasOwn, hasOwnKey, hasPathValue, head, identity, index, indexBy, init, insert, insertAt, intersection, invoker, invokerOn, is, isFinite_ as isFinite, isGT, isGTE, isIn, isInstanceOf, isInteger, isLT, isLTE, isNil, isNull, isSVZ, isSafeInteger, isType, isUndefined, join, joinWith, keySatisfies, keys, last, list, lt, lte, make, map, mapArgs, mapValues, mapValuesWith, mapWith, merge, mergeOwn, modulo, multiply, multiplyBy, not, ownPairs, ownValues, padLeft, padRight, pairs, partial, partialRight, partition, partitionWith, pathExists, pathExistsIn, pathSatisfies, pick, pickIf, pickKeys, pipe, pluck, pluckKey, pull, pullFrom, randomInt, range, reduce, reduceRight, reduceRightWith, reduceWith, remainder, rename, renameKeys, renameWith, repeat, reverse, rotate, rotateBy, setAt, setIn, setIndex, setKey, setPath, setPathIn, shallowFlatten, skip, skipIf, skipKeys, slice, sliceAt, some, someIn, sort, sortWith, sortedInsert, sorter, sorterDesc, split, splitBy, subtract, sum, tail, take, takeFrom, takeLastWhile, takeWhile, tapArgs, tear, tearOwn, testWith, throttle, transpose, type, unary, union, unionBy, uniques, uniquesBy, unless, updateAt, updateIn, updateIndex, updateKey, updatePath, updatePathIn, validate, validateWith, values, when, zip, zipWithIndex };
export { __, adapter, add, allOf, always, anyOf, append, appendTo, application, apply, applyTo, areSVZ, areSame, aritize, asPartial, binary, case_ as case, checker, clamp, clampWithin, collect, compose, condition, contains, count, countBy, curry, curryRight, curryable, curryableRight, debounce, deduct, difference, divide, divideBy, drop, dropFrom, dropLastWhile, dropWhile, enumerables, every, everyIn, filter, filterWith, find, findIndex, findIndexWhere, findLast, findLastIndex, findLastIndexWhere, findLastWhere, findWhere, flatMap, flatMapWith, flatten, flip, forEach, fromPairs, generate, generic, getArgAt, getAt, getIn, getIndex, getKey, getPath, getPathIn, group, groupBy, gt, gte, has, hasKey, hasKeyValue, hasOwn, hasOwnKey, hasPathValue, head, identity, index, indexBy, init, insert, insertAt, intersection, invoker, invokerOn, is, isFinite_ as isFinite, isGT, isGTE, isIn, isInstanceOf, isInteger, isLT, isLTE, isNil, isNull, isSVZ, isSafeInteger, isType, isUndefined, join, joinWith, keySatisfies, keys, last, list, lt, lte, make, map, mapArgs, mapValues, mapValuesWith, mapWith, merge, mergeOwn, modulo, multiply, multiplyBy, not, ownPairs, ownValues, padLeft, padRight, pairs, partial, partialRight, partition, partitionWith, pathExists, pathExistsIn, pathSatisfies, pick, pickIf, pickIn, pipe, pluck, pluckKey, pull, pullFrom, randomInt, range, reduce, reduceRight, reduceRightWith, reduceWith, remainder, rename, renameKeys, renameWith, repeat, reverse, rotate, rotateBy, setAt, setIn, setIndex, setKey, setPath, setPathIn, shallowFlatten, skip, skipIf, skipIn, slice, sliceAt, some, someIn, sort, sortWith, sortedInsert, sorter, sorterDesc, split, splitBy, subtract, sum, tail, take, takeFrom, takeLastWhile, takeWhile, tapArgs, tear, tearOwn, testWith, throttle, transpose, type, unary, union, unionBy, uniques, uniquesBy, unless, updateAt, updateIn, updateIndex, updateKey, updatePath, updatePathIn, validate, validateWith, values, when, zip, zipWithIndex };
4 changes: 2 additions & 2 deletions dist/lamb.esm.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lamb.esm.min.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit cf45fe5

Please sign in to comment.