-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02402b9
commit b655566
Showing
1 changed file
with
5 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ npm install flast | |
``` | ||
|
||
### Clone The Repo | ||
Requires Node 16 or newer. | ||
Requires Node 18 or newer. | ||
```bash | ||
git clone [email protected]:PerimeterX/flast.git | ||
cd flast | ||
|
@@ -165,7 +165,7 @@ const tree = [ | |
### flAST | ||
|
||
```javascript | ||
const {generateFlatAST, generateCode} = require('flast'); | ||
import {generateFlatAST, generateCode} from 'flast'; | ||
const ast = generateFlatAST(`console.log('flAST')`); | ||
const reconstructedCode = generateCode(ast[0]); // rebuild from root node | ||
``` | ||
|
@@ -197,7 +197,7 @@ const generateCodeDefaultOptions = { | |
### Arborist | ||
|
||
```javascript | ||
const {generateFlatAST, generateCode, Arborist} = require('flast'); | ||
import {generateFlatAST, generateCode, Arborist} from 'flast'; | ||
const ast = generateFlatAST(`console.log('Hello' + ' ' + 'there!');`); | ||
const replacements = { | ||
'Hello': 'General', | ||
|
@@ -213,8 +213,8 @@ ast.filter(n => n.type === 'Literal' && replacements[n.value]).forEach(n => arbo | |
const numberOfChangesMade = arborist.applyChanges(); | ||
console.log(generateCode(arborist.ast[0])); // console.log('General' + ' ' + 'Kenobi'); | ||
``` | ||
The Arborist can be called with an extra argument - logFunc - which can be used to log | ||
inside the arborist. | ||
The Arborist can be called with an extra argument - logFunc - which can be used to override the log | ||
function inside the arborist. | ||
|
||
## How to Contribute | ||
To contribute to this project see our [contribution guide](CONTRIBUTING.md) |