1.0.3 • Published 2 years ago

@alu0101056944/ast-types-marcos-barrios-lorenzo-alu0101056944 v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

spread

Transpile a javascript source code file into another without spread operators that is compatible with ECMAScript 5.

const spread = [1];
const a = [2, 3, ...spread, 4];
const a = [2, 3, 1, 4]  <=  RESULT

const spread = [true, 'algo', 9, 13, 15, 34, 29, 36]
const a = [2, 3, ...spread, 4]
const a = [2, 3, true, 'algo', 9, 13, 15, 34, 29, 36, 4]  <=  RESULT

const algo = []
const a = [-11, ...algo, 8, 9, 112];
const a = [-11, 8, 9, 112]  <=  RESULT

Installation

To install execute the following command:

npm i

Usage as executable:

Execute the program with the following command.

node bin/spread.js <input.js> -o <output>

where:

  • input.js is the path to the original javascript source code to transpile into another source code
  • output is the path of the file where save the transpiled source code; the constant folded one.

Usage from code:

import {replaceSpreadAsParameter} from 'spread';
// Call the function

Examples

src/input.js

const a = [2, 3, ...spread, 4];
const spread = [1];

Execute:

node bin/spread.js src/input.js -o src/output.js

Transpiled code:

src/output.js

const a = [2, 3, 1, 4];
const spread = [1];

Author

alu0101056944

marcos.barrios.15@ull.edu.es

Marcos Jesús Barrios Lorenzo

Tests

To run the tests execute the following command:

npm test