File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,22 @@ lib.identity = function(d) { return d; };
135135// minor convenience helper
136136lib . noop = function ( ) { } ;
137137
138+ /*
139+ * simpleMap: alternative to Array.map that only
140+ * passes on the element and up to 2 extra args you
141+ * provide (but not the array index or the whole array)
142+ *
143+ * array: the array to map it to
144+ * func: the function to apply
145+ * x1, x2: optional extra args
146+ */
147+ lib . simpleMap = function ( array , func , x1 , x2 ) {
148+ var len = array . length ,
149+ out = new Array ( len ) ;
150+ for ( var i = 0 ; i < len ; i ++ ) out [ i ] = func ( array [ i ] , x1 , x2 ) ;
151+ return out ;
152+ } ;
153+
138154// random string generator
139155lib . randstr = function randstr ( existing , bits , base ) {
140156 /*
You can’t perform that action at this time.
0 commit comments