Skip to content

Commit 9dbd74f

Browse files
committed
Wrap FFI in IIFE to avoid breaking bundling
See also: purescript#145 See also: purescript-contrib/purescript-avar#6
1 parent e710410 commit 9dbd74f

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/Data/Array.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,31 @@ exports.range = function (start) {
1818
};
1919
};
2020

21-
var replicate = function (count) {
22-
return function (value) {
23-
if (count < 1) {
24-
return [];
25-
}
26-
var result = new Array(count);
27-
return result.fill(value);
21+
// In browsers that have Array.prototype.fill we use it, as it's faster.
22+
exports.replicate = (function() {
23+
var replicate = function (count) {
24+
return function (value) {
25+
if (count < 1) {
26+
return [];
27+
}
28+
var result = new Array(count);
29+
return result.fill(value);
30+
};
2831
};
29-
};
3032

31-
var replicatePolyfill = function (count) {
32-
return function (value) {
33-
var result = [];
34-
var n = 0;
35-
for (var i = 0; i < count; i++) {
36-
result[n++] = value;
37-
}
38-
return result;
33+
var replicatePolyfill = function (count) {
34+
return function (value) {
35+
var result = [];
36+
var n = 0;
37+
for (var i = 0; i < count; i++) {
38+
result[n++] = value;
39+
}
40+
return result;
41+
};
3942
};
40-
};
4143

42-
// In browsers that have Array.prototype.fill we use it, as it's faster.
43-
exports.replicate = typeof Array.prototype.fill === "function" ? replicate : replicatePolyfill;
44+
return typeof Array.prototype.fill === "function" ? replicate : replicatePolyfill;
45+
})();
4446

4547
exports.fromFoldableImpl = (function () {
4648
function Cons(head, tail) {

0 commit comments

Comments
 (0)