Transform startsWith into raw char code tests
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
.npmignore
README.md
package-lock.json
package.json

README.md

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