Skip to content

Commit db0dc00

Browse files
authored
Fix already defined error messages (laravel-mix#2988)
1 parent 9684f1a commit db0dc00

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/helpers.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,35 @@ global.tap = function (val, callback) {
1818
* @param {*} val
1919
* @param {Function} callback
2020
*/
21-
Object.defineProperty(Array.prototype, 'tap', {
22-
value: function (callback) {
23-
if (this.length) {
24-
callback(this);
25-
}
21+
if (!Array.prototype.hasOwnProperty('tap')) {
22+
Object.defineProperty(Array.prototype, 'tap', {
23+
value: function (callback) {
24+
if (this.length) {
25+
callback(this);
26+
}
2627

27-
return this;
28-
}
29-
});
28+
return this;
29+
}
30+
});
31+
}
3032

3133
/**
3234
* Add wrap to arrays.
3335
*
3436
* @param {*} val
3537
* @param {Function} callback
3638
*/
37-
Object.defineProperty(Array, 'wrap', {
38-
value(value) {
39-
if (Array.isArray(value)) {
40-
return value;
41-
}
39+
if (!Array.hasOwnProperty('wrap')) {
40+
Object.defineProperty(Array, 'wrap', {
41+
value(value) {
42+
if (Array.isArray(value)) {
43+
return value;
44+
}
4245

43-
return [value];
44-
}
45-
});
46+
return [value];
47+
}
48+
});
49+
}
4650

4751
/**
4852
* Flatten the given array.

0 commit comments

Comments
 (0)