Skip to content

Commit

Permalink
version bump to 0.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ascartabelli committed Apr 5, 2016
1 parent f4880b4 commit 108c1f4
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 20 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Lamb it's also delivered on a CDN, courtesy of [npmcdn](https://npmcdn.com/):
The URL above will retrieve the latest version, but you can target a specific version too:

```html
<script src="https://npmcdn.com/lamb@0.18.0/dist/lamb.min.js"></script>
<script src="https://npmcdn.com/lamb@0.19.0/dist/lamb.min.js"></script>
```

## Semantic Versioning.
Expand Down Expand Up @@ -85,6 +85,10 @@ You can refer to the [changelog](#changelog) to see if your code is affected.

## <a name="changelog"></a> Changelog

- **v0.19.0 - *2016/04/05***
- **API change:**: renamed `getWithPath` to `getPathIn`
- Added `getPath` and `reverse`

- **v0.18.0 - *2016/04/01***
- **API change**: renamed `get` to `getIn`
- Added `setIn` and `setKey`
Expand Down
89 changes: 75 additions & 14 deletions dist/lamb.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.18.0
* @version 0.19.0
* @module lamb
* @license MIT
* @preserve
Expand All @@ -18,7 +18,7 @@
* @category Core
* @type String
*/
lamb._version = "0.18.0";
lamb._version = "0.19.0";

// alias used as a placeholder argument for partial application
var _ = lamb;
Expand Down Expand Up @@ -657,6 +657,7 @@
*
* @memberof module:lamb
* @category Array
* @see {@link module:lamb.groupBy|groupBy}
* @param {ArrayLike} arrayLike
* @param {ListIteratorCallback} iteratee
* @param {Object} [iterateeContext]
Expand All @@ -681,7 +682,7 @@
}

/**
* Using the provided iteratee, and its optional context, builds a [partial application]{@link module:lamb.partial}
* Using the provided iteratee, and its optional context, builds a partial application
* of {@link module:lamb.group|group} expecting the array-like object to act upon.
* @example
* var persons = [
Expand Down Expand Up @@ -710,6 +711,7 @@
*
* @memberof module:lamb
* @category Array
* @see {@link module:lamb.group|group}
* @param {ListIteratorCallback} iteratee
* @param {Object} [iterateeContext]
* @returns {Function}
Expand Down Expand Up @@ -977,6 +979,24 @@
return mapWith(getKey(key));
}

/**
* Reverses a copy of the given array-like object.
* @example
* var arr = [1, 2, 3];
*
* _.reverse(arr) // => [3, 2, 1];
*
* // `arr` still is [1, 2, 3]
*
* @memberof module:lamb
* @category Array
* @param {ArrayLike} arrayLike
* @returns {Array}
*/
function reverse (arrayLike) {
return slice(arrayLike).reverse();
}

/**
* Builds a function that creates a copy of an array-like object with the given
* index changed to the provided value.<br/>
Expand Down Expand Up @@ -1276,6 +1296,7 @@
lamb.partitionWith = partitionWith;
lamb.pluck = pluck;
lamb.pluckKey = pluckKey;
lamb.reverse = reverse;
lamb.setAt = setAt;
lamb.shallowFlatten = shallowFlatten;
lamb.tail = tail;
Expand Down Expand Up @@ -2705,15 +2726,16 @@
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.validate|validate}, {@link module:lamb.validateWith|validateWith}
* @param {Function} predicate - The predicate to test the object properties
* @param {String} message - The error message
* @param {String[]} keyPaths - The array of property names, or {@link module:lamb.getWithPath|paths}, to test.
* @param {String[]} keyPaths - The array of property names, or {@link module:lamb.getPathIn|paths}, to test.
* @param {String} [pathSeparator="."]
* @returns {Array<String, String[]>} An error in the form <code>["message", ["propertyA", "propertyB"]]</code> or an empty array.
*/
function checker (predicate, message, keyPaths, pathSeparator) {
return function (obj) {
var getValues = partial(getWithPath, obj, _, pathSeparator);
var getValues = partial(getPathIn, obj, _, pathSeparator);
return predicate.apply(obj, keyPaths.map(getValues)) ? [] : [message, keyPaths];
};
}
Expand Down Expand Up @@ -2780,7 +2802,8 @@
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.getKey|getKey}, {@link module:lamb.getWithPath|getWithPath}
* @see {@link module:lamb.getKey|getKey}
* @see {@link module:lamb.getPath|getPath}, {@link module:lamb.getPathIn|getPathIn}
* @param {Object} obj
* @param {String} key
* @returns {*}
Expand All @@ -2802,13 +2825,45 @@
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.getIn|getIn}, {@link module:lamb.getWithPath|getWithPath}
* @see {@link module:lamb.getIn|getIn}
* @see {@link module:lamb.getPath|getPath}, {@link module:lamb.getPathIn|getPathIn}
* @function
* @param {String} key
* @returns {Function}
*/
var getKey = _curry(getIn, 2, true);

/**
* Builds a partial application of {@link module:lamb.getPathIn|getPathIn} with the given
* path and separator, expecting the object to act upon.
* @example
* var user = {
* name: "John",
* surname: "Doe",
* login: {
* "user.name": "jdoe",
* password: "abc123"
* }
* };
*
* var getPwd = _.getPath("login.password");
* var getUsername = _.getPath("login/user.name", "/");
*
* getPwd(user) // => "abc123";
* getUsername(user) // => "jdoe"
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.getPathIn|getPathIn}
* @see {@link module:lamb.getIn|getIn}, {@link module:lamb.getKey|getKey}
* @param {String} path
* @param {String} [separator="."]
* @returns {Function}
*/
function getPath (path, separator) {
return partial(getPathIn, _, path, separator);
}

/**
* Gets a nested property value from an object using the given path.<br/>
* The path is a string with property names separated by dots by default, but
Expand All @@ -2824,22 +2879,23 @@
* };
*
* // same as _.getIn if no path is involved
* _.getWithPath(user, "name") // => "John"
* _.getPathIn(user, "name") // => "John"
*
* _.getWithPath(user, "login.password") // => "abc123";
* _.getWithPath(user, "login/user.name", "/") // => "jdoe"
* _.getWithPath(user, "name.foo") // => undefined
* _.getWithPath(user, "name.foo.bar") // => throws a TypeError
* _.getPathIn(user, "login.password") // => "abc123";
* _.getPathIn(user, "login/user.name", "/") // => "jdoe"
* _.getPathIn(user, "name.foo") // => undefined
* _.getPathIn(user, "name.foo.bar") // => throws a TypeError
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.getPath|getPath}
* @see {@link module:lamb.getIn|getIn}, {@link module:lamb.getKey|getKey}
* @param {Object|ArrayLike} obj
* @param {String} path
* @param {String} [separator="."]
* @returns {*}
*/
function getWithPath (obj, path, separator) {
function getPathIn (obj, path, separator) {
return path.split(separator || ".").reduce(getIn, obj);
}

Expand Down Expand Up @@ -3318,6 +3374,8 @@
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.validateWith|validateWith}
* @see {@link module:lamb.checker|checker}
* @param {Object} obj
* @param {Function[]} checkers
* @returns {Array<Array<String, String[]>>} An array of errors in the form returned by {@link module:lamb.checker|checker}, or an empty array.
Expand Down Expand Up @@ -3351,6 +3409,8 @@
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.validate|validate}
* @see {@link module:lamb.checker|checker}
* @function
* @param {Function[]} checkers
* @returns {Function}
Expand Down Expand Up @@ -3378,7 +3438,8 @@
lamb.fromPairs = fromPairs;
lamb.getIn = getIn;
lamb.getKey = getKey;
lamb.getWithPath = getWithPath;
lamb.getPath = getPath;
lamb.getPathIn = getPathIn;
lamb.has = has;
lamb.hasKey = hasKey;
lamb.hasKeyValue = hasKeyValue;
Expand Down
4 changes: 2 additions & 2 deletions dist/lamb.min.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"coveralls": "gulp coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
},
"tonicExample": "var _ = require('lamb');",
"version": "0.18.0",
"version": "0.19.0",
"devDependencies": {
"coveralls": "^2.11.8",
"gulp": "^3.9.1",
Expand Down
4 changes: 3 additions & 1 deletion src/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ function getAt (index) {
*
* @memberof module:lamb
* @category Array
* @see {@link module:lamb.groupBy|groupBy}
* @param {ArrayLike} arrayLike
* @param {ListIteratorCallback} iteratee
* @param {Object} [iterateeContext]
Expand All @@ -386,7 +387,7 @@ function group (arrayLike, iteratee, iterateeContext) {
}

/**
* Using the provided iteratee, and its optional context, builds a [partial application]{@link module:lamb.partial}
* Using the provided iteratee, and its optional context, builds a partial application
* of {@link module:lamb.group|group} expecting the array-like object to act upon.
* @example
* var persons = [
Expand Down Expand Up @@ -415,6 +416,7 @@ function group (arrayLike, iteratee, iterateeContext) {
*
* @memberof module:lamb
* @category Array
* @see {@link module:lamb.group|group}
* @param {ListIteratorCallback} iteratee
* @param {Object} [iterateeContext]
* @returns {Function}
Expand Down
5 changes: 5 additions & 0 deletions src/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ var _valuesFrom = _curry(function (getKeys, obj) {
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.validate|validate}, {@link module:lamb.validateWith|validateWith}
* @param {Function} predicate - The predicate to test the object properties
* @param {String} message - The error message
* @param {String[]} keyPaths - The array of property names, or {@link module:lamb.getPathIn|paths}, to test.
Expand Down Expand Up @@ -723,6 +724,8 @@ var tearOwn = _tearFrom(Object.keys);
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.validateWith|validateWith}
* @see {@link module:lamb.checker|checker}
* @param {Object} obj
* @param {Function[]} checkers
* @returns {Array<Array<String, String[]>>} An array of errors in the form returned by {@link module:lamb.checker|checker}, or an empty array.
Expand Down Expand Up @@ -756,6 +759,8 @@ function validate (obj, checkers) {
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.validate|validate}
* @see {@link module:lamb.checker|checker}
* @function
* @param {Function[]} checkers
* @returns {Function}
Expand Down

0 comments on commit 108c1f4

Please sign in to comment.