Skip to content

Instantly share code, notes, and snippets.

View asosnovsky's full-sized avatar
🏠
Working from home

Ari Sosnovsky asosnovsky

🏠
Working from home
View GitHub Profile
@sorenlouv
sorenlouv / range.js
Created December 4, 2015 10:38
Optimized range function for angular
// Extended answer: http://stackoverflow.com/questions/11873570/angularjs-for-loop-with-numbers-ranges/17124017#17124017
// By caching the function result, it can become orders of magnitudes more efficient (depending on how big the range is)
// jsPerf: http://jsperf.com/memoizer-range/9
$scope.range = (function() {
var cache = {};
return function(min, max, step) {
var isCacheUseful = (max - min) > 70;
var cacheKey;