1 | /**
|
2 | * espower - Power Assert feature instrumentor based on the ECMAScript AST.
|
3 | *
|
4 | * https://github.com/power-assert-js/espower
|
5 | *
|
6 | * Copyright (c) 2013-2016 Takuto Wada
|
7 | * Licensed under the MIT license.
|
8 | * https://github.com/power-assert-js/espower/blob/master/MIT-LICENSE.txt
|
9 | */
|
10 | ;
|
11 |
|
12 | var defaultOptions = require('./lib/default-options');
|
13 | var Instrumentor = require('./lib/instrumentor');
|
14 | var extend = require('xtend');
|
15 |
|
16 | /**
|
17 | * Instrument power assert feature into code. ECMAScript AST in, ECMAScript AST out.
|
18 | * @param {object} originalAst JavaScript ECMAScript JS AST to instrument (directly modified if destructive option is truthy)
|
19 | * @param {object} options Instrumentation options.
|
20 | * @returns {object} instrumented AST
|
21 | * @throws {EspowerError} if `originalAst` is already instrumented
|
22 | * @throws {EspowerError} if `originalAst` does not contain location information
|
23 | * @throws {EspowerError} if `options` is not valid
|
24 | */
|
25 | function espower (originalAst, options) {
|
26 | var instrumentor = new Instrumentor(extend(defaultOptions(), options));
|
27 | return instrumentor.instrument(originalAst);
|
28 | }
|
29 |
|
30 | espower.defaultOptions = defaultOptions;
|
31 | espower.Instrumentor = Instrumentor;
|
32 | espower.AssertionVisitor = require('./lib/assertion-visitor');
|
33 | espower.EspowerError = require('./lib/espower-error');
|
34 | module.exports = espower;
|