Skip to content

Commit fe853bb

Browse files
committed
Array.prototype.map polyfil+
used into cli/common.js:93
1 parent 5e2bd1d commit fe853bb

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/cli/wsh.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,39 @@ var wshapi = (function(){
7272
};
7373
}
7474

75+
//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
76+
if (!Array.prototype.map)
77+
{
78+
Array.prototype.map = function(fun /*, thisArg */ ) {
79+
"use strict";
80+
81+
if (this === void 0 || this === null) {
82+
throw new TypeError();
83+
}
84+
85+
var t = Object(this);
86+
var len = t.length >>> 0;
87+
if (typeof fun !== "function") {
88+
throw new TypeError();
89+
}
90+
91+
var res = new Array(len);
92+
var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
93+
for (var i = 0; i < len; i++) {
94+
// NOTE: Absolute correctness would demand Object.defineProperty
95+
// be used. But this method is fairly new, and failure is
96+
// possible only if Object.prototype or Array.prototype
97+
// has a property |i| (very unlikely), so use a less-correct
98+
// but more portable alternative.
99+
if (i in t) {
100+
res[i] = fun.call(thisArg, t[i], i, t);
101+
}
102+
}
103+
104+
return res;
105+
};
106+
}
107+
75108
function traverseDir(files, path) {
76109
var filename, folder = fso.GetFolder(path),
77110
subFlds, fc = new Enumerator(folder.files);

0 commit comments

Comments
 (0)