is-recoverable-error

isRecoverableError from Node.js' REPL

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
is-recoverable-error
1.0.3a year ago4 years agoMinified + gzip package size for is-recoverable-error in KB

Readme

is-recoverable-error
isRecoverableError function from Node.js REPL
Usage
var isRecoverableError = require('is-recoverable-error')
var repl = require('repl')
var vm = require('vm')

function myEval (input, context, filename, callback) {
  var result
  try {
    result = vm.runInThisContext(input)
  } catch (e) {
    if (isRecoverableError(input)) {
      return callback(new repl.Recoverable(e))
    }
  }
  callback(null, result)
}

API

isRecoverableError(input)

Where input is a string. Returns a boolean.
isRecoverableError('function x () {') // returns true
isRecoverableErorr('<cat>') // returns false
Installation
npm install -S is-recoverable-error
License
MIT