jsexpr
Version:
String and JSON expression interpolator and evaluator. Interpolates or evaluates a string against a json object, or transforms an object into another based on a json template
24 lines (20 loc) • 677 B
JavaScript
const
expression = require("../../lib/expression"),
Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
var expr1 = expression.expr({time : "${client}/${address.host}:${address.port}", data : {request : {headers : "${headers}"}}});
// add tests
suite.
add('jsontokens', function() {
var entry = {client : "HOST001", address : {host : "localhost", port : 8080}, headers : "Content-Type: application/json"}
expr1(entry);
}).
on('cycle', function(event) {
console.log(String(event.target));
}).
on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').map('name'));
}).
run({
'async': true
});