提交 183e5921 编写于 作者: M Matt Zabriskie

Merge pull request #91 from instagibb/master

Fixing isArrayLike to allow length as a param. Added test
......@@ -130,6 +130,16 @@ function trim(str) {
return str.replace(/^\s*/, '').replace(/\s*$/, '');
}
/**
* Determine if a value is an Arguments object
*
* @param {Object} val The value to test
* @returns {boolean} True if value is an Arguments object, otherwise false
*/
function isArguments(val) {
return toString.call(val) === '[object Arguments]';
}
/**
* Iterate over an Array or an Object invoking a function for each item.
*
......@@ -149,7 +159,7 @@ function forEach(obj, fn) {
}
// Check if obj is array-like
var isArrayLike = isArray(obj) || (typeof obj === 'object' && !isNaN(obj.length));
var isArrayLike = isArray(obj) || isArguments(obj);
// Force an array if not already something iterable
if (typeof obj !== 'object' && !isArrayLike) {
......
......@@ -44,5 +44,13 @@ describe('helpers::buildUrl', function () {
bar: 'baz'
})).toEqual('/foo?foo=bar&bar=baz');
});
it('should support "length" parameter', function () {
expect(buildUrl('/foo', {
query: 'bar',
start: 0,
length: 5
})).toEqual('/foo?query=bar&start=0&length=5');
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册