Serialize
Serializes an input value for dynamic code evaluation.
Installation
$ npm install eval-serialize
Usage
var serialize = ;
serialize( value )
Serializes an input value for dynamic code evaluation.
var str = ;// returns '5'str = ;// returns '"beep"'str = ;// returns 'new Uint16Array([0,0,0,0])'
Note: the following input value types are not currently supported...
- native
functions
Map
Set
Examples
var serialize = ;console;// returns '5'console;// returns '"beep"'console;// returns 'null'console;// returns 'undefined'console;// returns 'true'console;// returns 'false'console;// returns 'NaN'console;// returns 'Number.POSITIVE_INFINITY'console;// returns 'Number.NEGATIVE_INFINITY'console;// returns '[1,2,3]'console;// returns '{\"beep\":\"boop\"}'console;// returns 'new Buffer("YmVlcA==","base64")'console;// returns 'new Int32Array([1,2,3,4])'console;// returns 'new Date(<timestamp>)'console;// returns 'function add( a, b ) {\n\treturn a + b;\n}'
To run the example code from the top-level application directory,
$ node ./examples/index.js
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
License
Copyright
Copyright © 2015. Athan Reines.