is-recoverable-error
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i is-recoverable-error

Weekly Downloads

31,395

Version

1.0.3

License

MIT

Unpacked Size

5.74 kB

Total Files

6

Last publish

Collaborators

  • lerouxb
  • mabaasit
  • satyasinha
  • alena.khineika
  • mcasimir
  • rhysm
  • addaleax
  • gribnoysup
  • lrlna