Skip to content

xtuc/babel-plugin-optimize-starts-with

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 

babel-plugin-optimize-starts-with

Transform startsWith into raw char code tests

Example

In

if ('test'.startsWith('te')) {
  // true
}

Out

if ('test'.charCodeAt(0) === 116&& 'test'.charCodeAt(1) === 101) {
  // true
}

Installation

npm install --save-dev babel-plugin-optimize-starts-with

Usage

Via .babelrc (Recommended)

.babelrc

{
      "plugins": ["optimize-starts-with"]
}

Via CLI

babel --plugins optimize-starts-with script.js

Via Node API

require("babel-core").transform("code", {
      plugins: ["optimize-starts-with"]
});

About

Transform startsWith into raw char code tests

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published