eval
Alias for
eval
global.
Installation
$ npm install utils-eval
Usage
var evil = ;
evil( str )
Alias for eval
global.
var val = ;// returns 120
Notes
- A reference to
eval
is treated differently by the compiler. For example, when evaluating code containing block-scoped declarations (e.g.,let
,const
,function
,class
), the compiler may throw anerror
complaining that block-scoped declarations are not yet supported outside ofstrict mode
. One possible workaround is to include"use strict";
in the evaluated code, as done in the example below.
Examples
var evil = ;{var name;var str;name = ctor 1 ;name = name + 'DataArray';str = '';str += '(function create(){';str += '"use strict";';str += 'class '+name+' extends '+ctor+'{';str += 'constructor(x){';str += 'super(x);';str += '}';str += '}';str += 'return '+name+';';str += '})();';return str;}var ctors ='Int8Array''Uint8Array''Uint8ClampedArray''Int16Array''Uint16Array''Int32Array''Uint32Array''Float32Array''Float64Array''Array';var fcn;for var i = 0; i < ctorslength; i++fcn = ;console;
To run the example code from the top-level application directory,
$ node ./examples/index.js
CLI
Installation
To use the module as a general utility, install the module globally
$ npm install -g utils-eval
Usage
Usage: jseval [options] codeOptions:-h, --help Print this message.-V, --version Print the package version.
Examples
$ jseval '5*4*3*2*1'# => 120
Tests
Unit
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ make view-cov
Browser Support
This repository uses Testling for browser testing. To run the tests in a (headless) local web browser, execute the following command in the top-level application directory:
$ make test-browsers
To view the tests in a local web browser,
$ make view-browser-tests
License
Copyright
Copyright © 2015. Athan Reines.