Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-array-includes

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-array-includes

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

  • 2.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20K
increased by27.03%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 27 Jan 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc