array-sugar
Advanced tools
Comparing version
@@ -10,7 +10,14 @@ (function(arr) { | ||
* @param {Number} high | ||
* @returns {Array} | ||
* @returns {Array} including low and high | ||
*/ | ||
arr.range = function(low, high) { | ||
var r = []; | ||
var holder; | ||
if (isNumber(low) && (isNumber(high))) { | ||
if (low > high) { | ||
holder = low; | ||
low = high; | ||
high = holder; | ||
} | ||
while (high >= low) { | ||
@@ -20,2 +27,5 @@ r.push(low); | ||
} | ||
if (isNumber(holder)) { | ||
r.reverse(); | ||
} | ||
} | ||
@@ -22,0 +32,0 @@ return r; |
{ | ||
"name": "array-sugar", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"private": false, | ||
@@ -19,9 +19,16 @@ "author": "capaj <capajj@gmail.com>", | ||
"extend", | ||
"array.contains", | ||
"ecmascript", | ||
"array.prototype", | ||
"sugar", | ||
"syntactic sugar" | ||
], | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"nodeunit": "~0.9" | ||
"mocha": "^2.1.0", | ||
"chai": "^1.10.0" | ||
} | ||
} |
@@ -26,8 +26,9 @@ array-sugar | ||
Available through npm and bower, just require(or include in index.html) and you should be good to go. | ||
Available through npm and bower, just require(or include with regular script tag) and you should be good to go. | ||
npm install array-sugar | ||
bower install array-sugar | ||
jspm install npm:array-sugar | ||
Tests via nodeunit included. | ||
Then require('array-sugar'); and you're done. | ||
@@ -39,2 +40,5 @@ #known incompatibilities | ||
##Is it a good idea to extend array.prototype? | ||
If I am writing a web app, NOT a library/framework, I don't consider this a bad practice. I have quite few libraries and I do not use array-sugar in them even if It would be helpful most of the time. Users of these libraries would have their Array unexpectedly modified and we can't have that. But if you are building an end product used by end-user, I think it is quite allright to do that. | ||
Missing any sugar? Please do submit a pull or feature request. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
46111
16.18%19
11.76%363
1.68%43
10.26%2
100%