File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,17 @@ exports.range = function (start) {
1616 } ;
1717} ;
1818
19- exports . replicate = function ( count ) {
19+ var replicate = function ( count ) {
20+ return function ( value ) {
21+ if ( count < 1 ) {
22+ return [ ] ;
23+ }
24+ var result = new Array ( count ) ;
25+ return result . fill ( value ) ;
26+ } ;
27+ } ;
28+
29+ var replicatePolyfill = function ( count ) {
2030 return function ( value ) {
2131 var result = [ ] ;
2232 var n = 0 ;
@@ -27,6 +37,11 @@ exports.replicate = function (count) {
2737 } ;
2838} ;
2939
40+ // In browsers that have Array.prototype.fill we use it, as it's faster.
41+ exports . replicate = typeof Array . prototype . fill === "function" ?
42+ replicate :
43+ replicatePolyfill ;
44+
3045exports . fromFoldableImpl = ( function ( ) {
3146 // jshint maxparams: 2
3247 function Cons ( head , tail ) {
You can’t perform that action at this time.
0 commit comments