1.0.4 • Published 1 year ago

babel-plugin-inline-all-functions v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

babel-plugin-inline-all-functions

NPM Version

NAME

babel-plugin-inline-all-functions - a Babel plugin to inline one-liner arrow functions

INSTALLATION

$ npm install babel-plugin-inline-all-functions

SYNOPSIS

$ cat test.js

const square = number => number ** 2;

console.log(square(4) + square(8));

$ babel --plugins inline-all-functions test.js

console.log(4 ** 2 + 4 ** 2);

DESCRIPTION

This is a Babel plugin which inlines calls to one-liner arrow functions (these are arrow functions defined using an expression following the arrow, without a return keyword).

I started by forking the inline-functions Babel plugin from @chocolateboy on GitHub then ended up re-writing most of the transformation to serve my goals as a Javascript teacher.

OPTIONS

The original plugin by @chocolateboy had a number of options which I had removed. My rewrite does not support any options.

USAGE

.babelrc

$ cat .babelrc

{
    "plugins": ["inline-all-functions"]
}

CLI

$ babel --plugins inline-all-functions script.js

API

require('@babel/core').transform(code, {
    plugins: ['inline-all-functions']
})

DEVELOPMENT

NPM Scripts

The following NPM scripts are available:

  • doctoc - generate the TOC (table of contents) in the README
  • test - run the test suite

COMPATIBILITY

SEE ALSO

VERSION

1.0.4

AUTHOR

COPYRIGHT AND LICENSE

Copyright © 2016-2020 by Emile Cantin.

This is free software; you can redistribute it and/or modify it under the terms of the ISC License.