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+ // TODO: Add polyfill for Array.from
2+
3+ if ( ! Array . prototype . includes ) {
4+ Array . prototype . includes = function ( searchElement , fromIndex ) {
5+ 'use strict' ;
6+ if ( ! this ) {
7+ throw new TypeError ( 'Array.prototype.includes called on null or undefined' ) ;
8+ }
9+
10+ return this . indexOf ( searchElement , fromIndex ) !== - 1 ;
11+ }
12+ }
13+
14+ if ( ! Array . prototype . every ) {
15+ Array . prototype . every = function ( func ) {
16+ 'use strict' ;
17+ let result = true ;
18+
19+ this . forEach ( ( item , index ) => {
20+ if ( ! result ) {
21+ return ;
22+ } else if ( ! func ( item , index , this ) ) {
23+ result = false ;
24+ }
25+ } ) ;
26+
27+ return result ;
28+ }
29+ }
30+
31+ if ( ! Array . prototype . some ) {
32+ Array . prototype . some = function ( func ) {
33+ 'use strict' ;
34+ let result = false ;
35+
36+ this . forEach ( ( item , index ) => {
37+ if ( result ) {
38+ return ;
39+ } else if ( func ( item , index , this ) ) {
40+ result = true ;
41+ }
42+ } ) ;
43+
44+ return result ;
45+ }
46+ }
47+
48+ export default Array ;
You can’t perform that action at this time.
0 commit comments