Socket
Socket
Sign inDemoInstall

babel-plugin-array-includes

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-plugin-array-includes

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


Version published
Maintainers
1
Install size
5.24 kB
Created

Readme

Source

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

.babelrc

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

Via CLI

$ babel --plugins array-includes script.js

Via Node API

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

Keywords

FAQs

Last updated on 27 Jan 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc