babel-plugin-transform-array-prototype-includes
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

babel-plugin-transform-array-prototype-includes

Transforms arr.includes(value) to ES5 without a polyfill

Inspired by babel-plugin-array-includes.

Example

In

[1, 2, 3].includes(1);
[1, 2, 3]['includes'](1);
arr.includes(1);
arr['includes'](1);

Out

[1, 2, 3].indexOf(1) !== -1;
[1, 2, 3].indexOf(1) !== -1;
(function (o, a0) { return Array.isArray(o) ? o.indexOf(a0) !== -1 : o.includes(a0); })(arr, 1);
(function (o, a0) { return Array.isArray(o) ? o.indexOf(a0) !== -1 : o.includes(a0); })(arr, 1);

Installation

$ npm install babel-plugin-transform-array-prototype-includes

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["transform-array-prototype-includes"]
}

Via CLI

$ babel --plugins transform-array-prototype-includes script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["transform-array-prototype-includes"]
});

Package Sidebar

Install

npm i babel-plugin-transform-array-prototype-includes

Weekly Downloads

7

Version

1.2.1

License

MIT

Unpacked Size

8.01 kB

Total Files

5

Last publish

Collaborators

  • mhassan1