Comparing version 0.3.0 to 0.3.1
@@ -17,3 +17,3 @@ /** | ||
module.exports = function (list, predicate) { | ||
if (list && list.length && !isFunction(list)) { | ||
if (list && 'length' in list && !isFunction(list)) { | ||
return findIndex(list, predicate); | ||
@@ -33,3 +33,3 @@ } | ||
function findIndex (list, predicate) { | ||
if (!list || !list.length) { | ||
if (!list || !('length' in list)) { | ||
throw new TypeError('list must be have length property'); | ||
@@ -36,0 +36,0 @@ } |
@@ -19,3 +19,3 @@ /** | ||
var val; | ||
if (exists(item && item.length) && !isFunction(item)) { | ||
if (exists(item && ('length' in item)) && !isFunction(item)) { | ||
val = item[item.length - 1]; | ||
@@ -22,0 +22,0 @@ } |
{ | ||
"name": "101", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "common javascript utils that can be required selectively that assume es5+", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
101 | ||
101 [![Build Status](https://travis-ci.org/tjmehta/101.svg?branch=master)](https://travis-ci.org/tjmehta/101) | ||
=== | ||
@@ -3,0 +3,0 @@ |
@@ -40,2 +40,7 @@ var Lab = require('lab'); | ||
}); | ||
it('should return -1 in an empty list', function (done) { | ||
var arr = []; | ||
expect(findIndex(arr, function (v) { return v === 1; })).to.equal(-1); | ||
done(); | ||
}); | ||
it('should get the index of an item in an array/string that passes a given function', function (done) { | ||
@@ -88,2 +93,2 @@ var arr = this.arr; | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44231
1287