$ gnpm install babel-plugin-array-includes
Replaces
arr.includes(val)
witharr.indexOf(val) >= 0
.
Thanks to @sebmck for the help.
In
[1, 2, 3, 5, 8, 13].includes(4);
Out
"use strict";
[1, 2, 3, 5, 8, 13].indexOf(4) >= 0;
This doesn't work:
In
function foo(arr) {
return arr.includes('foo');
}
Out
function foo(arr) {
return arr.includes('foo'); // still includes
}
$ npm install babel-plugin-array-includes
.babelrc
(Recommended).babelrc
{
"plugins": ["array-includes"]
}
$ babel --plugins array-includes script.js
require("babel-core").transform("code", {
plugins: ["array-includes"]
});
Copyright 2013 - present © cnpmjs.org | Home |