Skip to content

Commit

Permalink
version bump to 0.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ascartabelli committed Mar 23, 2016
1 parent 332886f commit 923013e
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 15 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.15.2/dist/lamb.min.js"></script>
<script src="https://npmcdn.com/lamb@0.16.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.16.0 - *2016/03/23***
- **Fully compatible with versions down to 0.15.x**
- Added `init`, `tail`, `getAt`, `head`, `last`

- **v0.15.3 - *2016/03/21***
- **Fully compatible with versions down to 0.15.x**
- Updated `generic` function and removed unused Function.prototype caching
Expand Down
140 changes: 130 additions & 10 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.15.3
* @version 0.16.0
* @module lamb
* @license MIT
* @preserve
Expand All @@ -18,7 +18,7 @@
* @category Core
* @type String
*/
lamb._version = "0.15.3";
lamb._version = "0.16.0";

// alias used as a placeholder argument for partial application
var _ = lamb;
Expand Down Expand Up @@ -374,6 +374,9 @@
* @memberof module:lamb
* @category Array
* @function
* @see {@link module:lamb.dropN|dropN}
* @see {@link module:lamb.take|take}, {@link module:lamb.takeN|takeN}
* @see {@link module:lamb.takeWhile|takeWhile}, {@link module:lamb.dropWhile|dropWhile}
* @param {ArrayLike} arrayLike
* @param {Number} n
* @returns {Array}
Expand All @@ -392,6 +395,9 @@
* @memberof module:lamb
* @category Array
* @function
* @see {@link module:lamb.drop|drop}
* @see {@link module:lamb.take|take}, {@link module:lamb.takeN|takeN}
* @see {@link module:lamb.takeWhile|takeWhile}, {@link module:lamb.dropWhile|dropWhile}
* @param {Number} n
* @returns {Function}
*/
Expand All @@ -408,6 +414,9 @@
*
* @memberof module:lamb
* @category Array
* @see {@link module:lamb.takeWhile|takeWhile}
* @see {@link module:lamb.drop|drop}, {@link module:lamb.dropN|dropN}
* @see {@link module:lamb.take|take}, {@link module:lamb.takeN|takeN}
* @param {ListIteratorCallback} predicate
* @param {Object} [predicateContext]
* @returns {Function}
Expand Down Expand Up @@ -566,6 +575,35 @@
return _flatten(array, []);
}

/**
* Retrieves the element at the given index in an array-like object.<br/>
* Like {@link module:lamb.slice|slice} the index can be negative.<br/>
* If the index isn't supplied, or if its value it's out of the array-like bounds,
* the function will return <code>undefined</code>.
* @example
* var getFifthElement = _.getAt(4);
*
* getFifthElement([1, 2, 3, 4, 5]) // => 5
* getFifthElement("foo bar") // => "b"
* getFifthElement([]) // => undefined
* getFifthElement("foo") // => undefined
*
* @example <caption>Using negative indexes</caption>
* _.getAt(-2)([1, 2, 3]) // => 2
* _.getAt(-3)("foo") // => "f"
*
* @memberof module:lamb
* @category Array
* @see {@link module:lamb.head|head} and {@link module:lamb.last|last} for common use cases shortcuts.
* @param {Number} index
* @returns {Function}
*/
function getAt (index) {
return function (arrayLike) {
return arrayLike[index < 0 ? index + arrayLike.length : index];
};
}

/**
* Transforms an array-like object into a lookup table using the provided iteratee as a grouping
* criterion to generate keys and values.
Expand Down Expand Up @@ -680,6 +718,40 @@
return partial(group, _, iteratee, iterateeContext);
}

/**
* Retrieves the first element of an array-like object.<br/>
* Just a common use case of {@link module:lamb.getAt|getAt} exposed for convenience.
* @example
* _.head([1, 2, 3]) // => 1
* _.head("hello") // => "h"
* _.head([]) // => undefined
*
* @memberof module:lamb
* @category Array
* @function
* @see {@link module:lamb.last|last}
* @param {ArrayLike} arrayLike
* @returns {*}
*/
var head = getAt(0);

/**
* Returns a copy of the given array-like object without the last element.
* @example
* _.init([1, 2, 3, 4]) // => [1, 2, 3]
* _.init([1]) // => []
* _.init([]) // => []
*
* @memberOf module:lamb
* @category Array
* @function
* @see {@link module:lamb.tail|tail}
* @see {@link module:lamb.head|head}, {@link module:lamb.last|last}
* @param {ArrayLike} arrayLike
* @returns {Array}
*/
var init = partial(slice, _, 0, -1);

/**
* Returns an array of every item present in all given arrays.<br/>
* Note that since version <code>0.13.0</code> this function uses the ["SameValueZero" comparison]{@link module:lamb.isSVZ|isSVZ}.
Expand Down Expand Up @@ -737,6 +809,23 @@
return result;
}

/**
* Retrieves the last element of an array-like object.<br/>
* Just a common use case of {@link module:lamb.getAt|getAt} exposed for convenience.
* @example
* _.last([1, 2, 3]) // => 3
* _.last("hello") // => "o"
* _.last([]) // => undefined
*
* @memberof module:lamb
* @category Array
* @function
* @see {@link module:lamb.head|head}
* @param {ArrayLike} arrayLike
* @returns {*}
*/
var last = getAt(-1);

/**
* Generates an array with the values passed as arguments.
* @example
Expand Down Expand Up @@ -902,6 +991,23 @@
return _arrayProto.concat.apply([], array);
}

/**
* Returns a copy of the given array-like object without the first element.
* @example
* _.tail([1, 2, 3, 4]) // => [2, 3, 4]
* _.tail([1]) // => []
* _.tail([]) // => []
*
* @memberOf module:lamb
* @category Array
* @function
* @see {@link module:lamb.init|init}
* @see {@link module:lamb.head|head}, {@link module:lamb.last|last}
* @param {ArrayLike} arrayLike
* @returns {Array}
*/
var tail = partial(slice, _, 1, void 0);

/**
* Retrieves the first <code>n</code> elements from an array or array-like object.
* Note that, being this a partial application of {@link module:lamb.slice|slice},
Expand All @@ -916,6 +1022,9 @@
* @memberof module:lamb
* @category Array
* @function
* @see {@link module:lamb.takeN|takeN}
* @see {@link module:lamb.drop|drop}, {@link module:lamb.dropN|dropN}
* @see {@link module:lamb.takeWhile|takeWhile}, {@link module:lamb.dropWhile|dropWhile}
* @param {ArrayLike} arrayLike
* @param {Number} n
* @returns {Array}
Expand All @@ -934,6 +1043,9 @@
* @memberof module:lamb
* @category Array
* @function
* @see {@link module:lamb.take|take}
* @see {@link module:lamb.drop|drop}, {@link module:lamb.dropN|dropN}
* @see {@link module:lamb.takeWhile|takeWhile}, {@link module:lamb.dropWhile|dropWhile}
* @param {Number} n
* @returns {Function}
*/
Expand All @@ -950,6 +1062,9 @@
*
* @memberof module:lamb
* @category Array
* @see {@link module:lamb.dropWhile|dropWhile}
* @see {@link module:lamb.take|take}, {@link module:lamb.takeN|takeN}
* @see {@link module:lamb.drop|drop}, {@link module:lamb.dropN|dropN}
* @param {ListIteratorCallback} predicate
* @param {Object} predicateContext
* @returns {Function}
Expand Down Expand Up @@ -1107,17 +1222,22 @@
lamb.flatMap = flatMap;
lamb.flatMapWith = flatMapWith;
lamb.flatten = flatten;
lamb.getAt = getAt;
lamb.group = group;
lamb.groupBy = groupBy;
lamb.head = head;
lamb.init = init;
lamb.intersection = intersection;
lamb.isIn = isIn;
lamb.last = last;
lamb.list = list;
lamb.mapWith = mapWith;
lamb.partition = partition;
lamb.partitionWith = partitionWith;
lamb.pluck = pluck;
lamb.pluckKey = pluckKey;
lamb.shallowFlatten = shallowFlatten;
lamb.tail = tail;
lamb.take = take;
lamb.takeN = takeN;
lamb.takeWhile = takeWhile;
Expand Down Expand Up @@ -1256,10 +1376,8 @@
*
* @memberof module:lamb
* @category Array
* @see {@link module:lamb.sort|sort}
* @see {@link module:lamb.sorter|sorter}
* @see {@link module:lamb.sorterDesc|sorterDesc}
* @see {@link module:lamb.sortWith|sortWith}
* @see {@link module:lamb.sort|sort}, {@link module:lamb.sortWith|sortWith}
* @see {@link module:lamb.sorter|sorter}, {@link module:lamb.sorterDesc|sorterDesc}
* @param {Array} array
* @param {*} element
* @param {...(Sorter|Function)} [sorter={@link module:lamb.sorter|sorter()}] - The sorting criteria used to sort the array.
Expand Down Expand Up @@ -1327,6 +1445,8 @@
*
* @memberof module:lamb
* @category Array
* @see {@link module:lamb.sortWith|sortWith}
* @see {@link module:lamb.sorter|sorter}, {@link module:lamb.sorterDesc|sorterDesc}
* @param {ArrayLike} arrayLike
* @param {...(Sorter|Function)} [sorter={@link module:lamb.sorter|sorter()}]
* @returns {Array}
Expand Down Expand Up @@ -1361,9 +1481,8 @@
* @category Array
* @function
* @see {@link module:lamb.insert|insert}
* @see {@link module:lamb.sort|sort}
* @see {@link module:lamb.sort|sort}, {@link module:lamb.sortWith|sortWith}
* @see {@link module:lamb.sorterDesc|sorterDesc}
* @see {@link module:lamb.sortWith|sortWith}
* @param {Function} [reader={@link module:lamb.identity|identity}] A function meant to generate a simple value from a complex one. The function should evaluate the array element and supply the value to be passed to the comparer.
* @param {Function} [comparer] An optional custom comparer function.
* @returns {Sorter}
Expand All @@ -1378,9 +1497,8 @@
* @category Array
* @function
* @see {@link module:lamb.insert|insert}
* @see {@link module:lamb.sort|sort}
* @see {@link module:lamb.sort|sort}, {@link module:lamb.sortWith|sortWith}
* @see {@link module:lamb.sorter|sorter}
* @see {@link module:lamb.sortWith|sortWith}
* @param {Function} [reader={@link module:lamb.identity|identity}] A function meant to generate a simple value from a complex one. The function should evaluate the array element and supply the value to be passed to the comparer.
* @param {Function} [comparer] An optional custom comparer function.
* @returns {Sorter}
Expand All @@ -1403,6 +1521,8 @@
*
* @memberof module:lamb
* @category Array
* @see {@link module:lamb.sort|sort}
* @see {@link module:lamb.sorter|sorter}, {@link module:lamb.sorterDesc|sorterDesc}
* @param {...(Sorter|Function)} [sorter={@link module:lamb.sorter|sorter()}]
* @returns {Function}
*/
Expand Down
Loading

0 comments on commit 923013e

Please sign in to comment.