Skip to content

Commit

Permalink
version bump to 0.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ascartabelli committed Mar 29, 2016
1 parent 7e43473 commit 0517e84
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 13 deletions.
7 changes: 6 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.16.0/dist/lamb.min.js"></script>
<script src="https://npmcdn.com/lamb@0.17.0/dist/lamb.min.js"></script>
```

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

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

- **v0.17.0 - *2016/03/29***
- **Minor API change (shouldn't affect anyone):** changed integer conversions in `isIn`, `transpose` and currying functions
- **API change**: `getAt` no longer accepts strings as indexes
- Added `getArgAt` and `setAt`

- **v0.16.0 - *2016/03/23***
- **Fully compatible with versions down to 0.15.x**
- Added `init`, `tail`, `getAt`, `head`, `last`
Expand Down
89 changes: 81 additions & 8 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.16.0
* @version 0.17.0
* @module lamb
* @license MIT
* @preserve
Expand All @@ -18,7 +18,7 @@
* @category Core
* @type String
*/
lamb._version = "0.16.0";
lamb._version = "0.17.0";

// alias used as a placeholder argument for partial application
var _ = lamb;
Expand Down Expand Up @@ -578,7 +578,7 @@
/**
* 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,
* If the index isn't supplied, or if its value isn't an integer within the array-like bounds,
* the function will return <code>undefined</code>.
* @example
* var getFifthElement = _.getAt(4);
Expand All @@ -600,7 +600,7 @@
*/
function getAt (index) {
return function (arrayLike) {
return arrayLike[index < 0 ? index + arrayLike.length : index];
return Math.floor(index) === index ? arrayLike[index < 0 ? index + arrayLike.length : index] : void 0;
};
}

Expand Down Expand Up @@ -663,7 +663,7 @@
* @returns {Object}
*/
function group (arrayLike, iteratee, iterateeContext) {
var result = {};
var result = {};
var len = arrayLike.length;

for (var i = 0, element; i < len; i++) {
Expand Down Expand Up @@ -799,7 +799,7 @@
function isIn (arrayLike, value, fromIndex) {
var result = false;

for (var i = fromIndex | 0, len = arrayLike.length; i < len; i++) {
for (var i = fromIndex >>> 0, len = arrayLike.length; i < len; i++) {
if (isSVZ(value, arrayLike[i])) {
result = true;
break;
Expand Down Expand Up @@ -870,6 +870,7 @@
*
* @memberof module:lamb
* @category Array
* @see {@link module:lamb.partitionWith|partitionWith}
* @param {ArrayLike} arrayLike
* @param {ListIteratorCallback} predicate
* @param {Object} [predicateContext]
Expand Down Expand Up @@ -911,6 +912,7 @@
*
* @memberof module:lamb
* @category Array
* @see {@link module:lamb.partition|partition}
* @param {ListIteratorCallback} predicate
* @param {Object} [predicateContext]
* @returns {Function}
Expand Down Expand Up @@ -941,6 +943,7 @@
*
* @memberof module:lamb
* @category Array
* @see {@link module:lamb.pluckKey|pluckKey}
* @param {ArrayLike} arrayLike
* @param {String} key
* @returns {Array}
Expand All @@ -965,6 +968,7 @@
*
* @memberof module:lamb
* @category Array
* @see {@link module:lamb.pluck|pluck}
* @function
* @param {String} key
* @returns {Function}
Expand All @@ -973,6 +977,42 @@
return mapWith(getKey(key));
}

/**
* Builds a function that creates a copy of an array-like object with the given
* index changed to the provided value.<br/>
* If the index is not an integer or if it's out of bounds, the function
* will return a copy of the original array.<br/>
* Negative indexes are allowed.
* @example
* var arr = [1, 2, 3, 4, 5];
*
* _.setAt(2, 99)(arr) // => [1, 2, 99, 4, 5]
* arr // => [1, 2, 3, 4, 5]
*
* _.setAt(10, 99)(arr) // => [1, 2, 3, 4, 5] (not a reference to `arr`)
*
* @example <caption>Using negative indexes</caption>
* _.setAt(-1, 99)(arr) // => [1, 2, 3, 4, 99]
*
* @memberof module:lamb
* @category Array
* @param {Number} index
* @param {*} value
* @returns {Function}
*/
function setAt (index, value) {
return function (arrayLike) {
var result = slice(arrayLike);
var len = arrayLike.length;

if (clamp(index, -len, len - 1) === Math.floor(index)) {
result[index + (index < 0 ? len : 0)] = value;
}

return result;
};
}

/**
* Flattens the "first level" of an array.<br/>
* See also {@link module:lamb.flatten|flatten}.
Expand Down Expand Up @@ -1103,7 +1143,7 @@
*/
function transpose (arrayLike) {
var result = [];
var minLen = apply(Math.min, pluck(arrayLike, "length")) | 0;
var minLen = apply(Math.min, pluck(arrayLike, "length")) >>> 0;
var len = arrayLike.length;

for (var i = 0, j; i < minLen; i++) {
Expand Down Expand Up @@ -1236,6 +1276,7 @@
lamb.partitionWith = partitionWith;
lamb.pluck = pluck;
lamb.pluckKey = pluckKey;
lamb.setAt = setAt;
lamb.shallowFlatten = shallowFlatten;
lamb.tail = tail;
lamb.take = take;
Expand Down Expand Up @@ -1558,7 +1599,7 @@
return a.length ? [a[0]] : [];
};

if ((arity | 0) !== arity) {
if ((arity >>> 0) !== arity) {
arity = fn.length;
}

Expand Down Expand Up @@ -1787,6 +1828,31 @@
};
}

/**
* Builds a function that returns the argument received at the given index.<br/>
* As with {@link module:lamb.getAt|getAt} negative indexes are allowed.<br/>
* The resulting function will return <code>undefined</code> if no arguments are
* passed or if the index is out of bounds.
* @example
* var getFirstArg = getArgAt(0);
* var getLastArg = getArgAt(-1);
*
* getFirstArg(1, 2, 3) // => 1
* getLastArg(1, 2, 3) // => 3
*
* getArgAt()(1, 2, 3) // => undefined
* getArgAt(6)(1, 2, 3) // => undefined
* getArgAt(1)() // => undefined
*
* @memberof module:lamb
* @category Function
* @param {Number} index
* @returns {Function}
*/
function getArgAt (index) {
return compose(getAt(index), list);
}

/**
* Accepts an object and builds a function expecting a method name, and optionally arguments, to call on such object.
* Like {@link module:lamb.invoker|invoker}, if no method with the given name is found the function will return <code>undefined</code>.
Expand Down Expand Up @@ -2010,6 +2076,7 @@
lamb.curryableRight = curryableRight;
lamb.debounce = debounce;
lamb.flip = flip;
lamb.getArgAt = getArgAt;
lamb.invokerOn = invokerOn;
lamb.invoker = invoker;
lamb.mapArgs = mapArgs;
Expand Down Expand Up @@ -2082,6 +2149,7 @@
*
* @memberof module:lamb
* @category Logic
* @see {@link module:lamb.anyOf|anyOf}
* @param {...Function} predicate
* @returns {Function}
*/
Expand Down Expand Up @@ -2112,6 +2180,7 @@
*
* @memberof module:lamb
* @category Logic
* @see {@link module:lamb.allOf|allOf}
* @param {...Function} predicate
* @returns {Function}
*/
Expand Down Expand Up @@ -3040,6 +3109,7 @@
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.pickIf|pickIf}
* @param {Object} source
* @param {String[]} whitelist
* @returns {Object}
Expand Down Expand Up @@ -3067,6 +3137,7 @@
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.pick|pick}
* @param {ObjectIteratorCallback} predicate
* @param {Object} [predicateContext]
* @returns {Function}
Expand Down Expand Up @@ -3095,6 +3166,7 @@
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.skipIf|skipIf}
* @param {Object} source
* @param {String[]} blacklist
* @returns {Object}
Expand Down Expand Up @@ -3122,6 +3194,7 @@
*
* @memberof module:lamb
* @category Object
* @see {@link module:lamb.skip|skip}
* @param {ObjectIteratorCallback} predicate
* @param {Object} [predicateContext]
* @returns {Function}
Expand Down
Loading

0 comments on commit 0517e84

Please sign in to comment.