babel-plugin-array-includes
Replaces `arr.includes(val)' with `arr.indexOf(val) >= 0`.
Last updated 9 years ago by schtoeffel .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm 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 (9 years ago)

6 Versions

  • 2.0.3                                ...           9 years ago
  • 2.0.2                                ...           9 years ago
  • 2.0.1                                ...           9 years ago
  • 1.1.1                                ...           9 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (5)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |