liuyanzhi08 / base2

Automatically exported from code.google.com/p/base2
0 stars 0 forks source link

Please add Array2.make #131

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Array2.make = function (x, n) {
  var xs = [];
  for (var i = 0; i < n; i++)
    xs.push(x);
  return xs;
}

I found this useful when making mocks that returned sample data.

Original issue reported on code.google.com by reti...@gmail.com on 16 Mar 2010 at 9:03

GoogleCodeExporter commented 8 years ago
Array2.make = function (x, n) {
  return new Array(n+1).join(x);
}

is shorter ;-)

Original comment by doek...@gmail.com on 17 Mar 2010 at 7:51

GoogleCodeExporter commented 8 years ago
I'm not sure that a make() function is crucial to the core and I don't want to 
add lots 
of infrequently used utility functions.

base2 is extendible as you have shown and you can add this function yourself.

Original comment by dean.edw...@gmail.com on 17 Mar 2010 at 10:05