3.0.0 • Published 6 years ago

the-interpreter v3.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

the-interpreter

Build Status npm Version JS Standard

Text interpreter

Installation

$ npm install the-interpreter --save

Usage

'use strict'

const {TheInterpreter} = require('the-interpreter')
const {EOL} = require('os')

async function tryExample () {

  const interpreter = new TheInterpreter(
    // Register processor. This function called on each letter
    (processed, context) => {
      if (context.hits(EOL)) {
        processed.lines.push(context.readLine())
      }
      return processed // Return result for next processing
    }
  )

  const src = `
#!/usr/bin/env 

// This is some declare
const obj01 = {p1: 1, p2: 2}
  
  `

  // Apply processed
  const processed = interpreter.process(
    src, // Source string or generator
    {lines: []}, // Initial value
  )

  console.log(processed)

}

tryExample().catch((err) => console.error(err))

API Guide

License

This software is released under the MIT License.

Links

3.0.0

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago