babel-plugin-array-includes
Replaces `arr.includes(val)' with `arr.indexOf(val) >= 0`.
Last updated 4 years ago by schtoeffel .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-plugin-array-includes 
SYNC missed versions from official npm registry.

babel-plugin-array-includes

Replaces arr.includes(val) with arr.indexOf(val) >= 0.

Thanks to @sebmck for the help.

Example

In

[1, 2, 3, 5, 8, 13].includes(4);

Out

"use strict";

[1, 2, 3, 5, 8, 13].indexOf(4) >= 0;

Pitfalls

This doesn't work:

In

function foo(arr) {
  return arr.includes('foo');
}

Out

function foo(arr) {
  return arr.includes('foo'); // still includes
}

Installation

$ npm install babel-plugin-array-includes

Usage

Via .babelrc (Recommended)

.babelrc

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

Via CLI

$ babel --plugins array-includes script.js

Via Node API

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

Current Tags

  • 2.0.3                                ...           latest (4 years ago)

6 Versions

  • 2.0.3                                ...           4 years ago
  • 2.0.2                                ...           4 years ago
  • 2.0.1                                ...           4 years ago
  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 5
This Week 29
This Month 502
Last Day 24
Last Week 142
Last Month 474
Dependencies (0)
None
Dev Dependencies (5)
Dependents (88)

Copyright 2014 - 2016 © taobao.org |