File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ // ES5 Polyfills
2+ // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
3+ if ( ! Array . prototype . map ) {
4+ Array . prototype . map = function ( callback , thisArg ) {
5+ var O = Object ( this ) ;
6+ var len = O . length >>> 0 ;
7+ var T ;
8+ if ( arguments . length > 1 ) {
9+ T = thisArg ;
10+ }
11+
12+ var A = new Array ( len ) ;
13+ var k = 0 ;
14+
15+ while ( k < len ) {
16+ var kValue , mappedValue ;
17+ if ( k in O ) {
18+ kValue = O [ k ] ;
19+ mappedValue = callback . call ( T , kValue , k , O ) ;
20+ A [ k ] = mappedValue ;
21+ }
22+ k ++ ;
23+ }
24+
25+ return A ;
26+ } ;
27+ }
28+
29+ // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
30+ if ( ! Array . prototype . filter ) {
31+ Array . prototype . filter = function ( callback /*, thisArg*/ ) {
32+ var t = Object ( this ) ;
33+ var len = t . length >>> 0 ;
34+
35+ var res = [ ] ;
36+ var thisArg = arguments . length >= 2 ? arguments [ 1 ] : void 0 ;
37+ for ( var i = 0 ; i < len ; i ++ ) {
38+ if ( i in t ) {
39+ var val = t [ i ] ;
40+ if ( callback . call ( thisArg , val , i , t ) ) {
41+ res . push ( val ) ;
42+ }
43+ }
44+ }
45+
46+ return res ;
47+ } ;
48+ }
You can’t perform that action at this time.
0 commit comments