1. babel-plugin-array-includes
Replaces `arr.includes(val)' with `arr.indexOf(val) >= 0`.
babel-plugin-array-includes
Package: babel-plugin-array-includes
Created by: stoeffel
Last modified: Mon, 13 Jun 2022 04:00:31 GMT
Version: 2.0.3
License: MIT
Downloads: 41,737
Repository: https://github.com/stoeffel/babel-plugin-array-includes

Install

npm install babel-plugin-array-includes
yarn add babel-plugin-array-includes

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"]
});

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin