# espower-source

> Power Assert instrumentor from source to source, with source-map

Latest version **2.3.0** (published 2018-06-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install espower-source
pnpm add espower-source
yarn add espower-source
bun add espower-source
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.0 |
| Published | 2018-06-12 |
| First published | 2014-04-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.8.0 |
| Dependencies | 11 |
| Unpacked size | 21.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Takuto Wada |
| Maintainers | twada |
| Keywords | power-assert, assert, assertion, test, testing |

## Links

- npm: https://www.npmjs.com/package/espower-source
- Repository: https://github.com/power-assert-js/espower-source
- Issues: https://github.com/power-assert-js/espower-source/issues
- npm.io page: https://npm.io/package/espower-source

## Dependencies (11)

- [acorn](https://npm.io/package/acorn.md) ^5.0.0
- [xtend](https://npm.io/package/xtend.md) ^4.0.0
- [espower](https://npm.io/package/espower.md) ^2.1.1
- [escodegen](https://npm.io/package/escodegen.md) ^1.10.0
- [estraverse](https://npm.io/package/estraverse.md) ^4.0.0
- [empower-assert](https://npm.io/package/empower-assert.md) ^1.0.0
- [acorn-es7-plugin](https://npm.io/package/acorn-es7-plugin.md) ^1.0.10
- [path-is-absolute](https://npm.io/package/path-is-absolute.md) ^1.0.0
- [convert-source-map](https://npm.io/package/convert-source-map.md) ^1.1.1
- [multi-stage-sourcemap](https://npm.io/package/multi-stage-sourcemap.md) ^0.2.1
- [merge-estraverse-visitors](https://npm.io/package/merge-estraverse-visitors.md) ^1.0.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 2.3.0 (latest) — 2018-06-12
- 2.2.0 — 2017-05-04
- 2.1.0 — 2017-04-09
- 2.0.1 — 2017-02-13
- 2.0.0 — 2016-11-12
- 1.2.0 — 2016-10-25
- 1.1.0 — 2016-01-22
- 1.0.0 — 2015-08-08
- 0.10.0 — 2014-11-11
- 0.9.1 — 2014-09-14
- 0.9.0 — 2014-08-31
- 0.8.0 — 2014-08-12
- 0.7.3 — 2014-05-31
- 0.7.1 — 2014-05-19
- 0.7.0 — 2014-05-02
- … 4 more at https://npm.io/package/espower-source/versions

## README

espower-source
================================

[![Build Status][travis-image]][travis-url]
[![NPM package][npm-image]][npm-url]
[![Dependency Status][depstat-image]][depstat-url]
[![License][license-image]][license-url]


Power Assert instrumentor from code to code, with SourceMap.


DESCRIPTION
---------------------------------------
`espower-source` is a source code transformer that applies [espower](https://github.com/power-assert-js/espower) to target code.

`espower` manipulates assertion expression in the form of ECMAScript AST defined in [The ESTree Spec](https://github.com/estree/estree) (formerly known as [Mozilla SpiderMonkey Parser API](https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API)), to instrument power-assert feature into the code. SourceMap information is appended in SourceMap Comment syntax at the end of returned code.

Pull-requests, issue reports and patches are always welcomed. See [power-assert](https://github.com/power-assert-js/power-assert) project for more documentation.


CHANGELOG
---------------------------------------
See [CHANGELOG](https://github.com/power-assert-js/espower-source/blob/master/CHANGELOG.md)


API
---------------------------------------

### var modifiedCode = espowerSource(originalCode, [filepath], [options])

| return type |
|:------------|
| `string`    |

`espowerSource` function manipulates `originalCode` then returns (transformed) JavaScript code as string. SourceMap information is appended in SourceMap Comment syntax at the end of returned code.

#### originalCode

| type     | default value |
|:---------|:--------------|
| `string` | N/A           |

Original JavaScript source code that is a source of code transformation. If not specified, then `EspowerError` will be thrown.

#### filepath (optional but recommended)

| type     | default value |
|:---------|:--------------|
| `string` | N/A           |

Filepath of `originalCode`. espower-source stores filepath information for later reporting. If not specified, `options.path` will be used. If neither filepath nor options.path are not specified, espower-source transforms code as usual but SourceMap will not be generated and attached.

#### options (optional)

| type     | default value |
|:---------|:--------------|
| `object` | (return value of `espower.defaultOptions()` but with `destructive` option is `true`) |

Configuration options for `espower` module. If not passed, default options (Same as [espower.defaultOptions()](https://github.com/power-assert-js/espower#var-options--espowerdefaultoptions)) will be used, but `options.destructive` is set to `true`, and if `options.path` is falsy, `options.path` is set to value of `filepath` argument by espower-source module.


#### options.ecmaVersion

| type     | default value |
|:---------|:--------------|
| `number` | `2018`        |

The ECMAScript version to parse and analyze. Must be either 3, 5, 6 (2015), 2016, 2017, or 2018.


#### options.sourceType

| type     | default value |
|:---------|:--------------|
| `string` | `'module'`    |

The source type of the code. Must be either `"script"` or `"module"`.


INSTALL
---------------------------------------

### via npm

Install

    $ npm install --save-dev espower-source


OUR SUPPORT POLICY
---------------------------------------

We support Node under maintenance. In other words, we stop supporting old Node version when [their maintenance ends](https://github.com/nodejs/LTS).

This means that any other environment is not supported.

NOTE: If espower-source works in any of the unsupported environments, it is purely coincidental and has no bearing on future compatibility. Use at your own risk.


AUTHOR
---------------------------------------
* [Takuto Wada](https://github.com/twada)


CONTRIBUTORS
---------------------------------------
* [azu](https://github.com/azu)
* [James Talmage (jamestalmage)](https://github.com/jamestalmage)
* [Yoshiki Shibukawa (shibukawa)](https://github.com/shibukawa)
* [Yiyu He (dead-horse)](https://github.com/dead-horse)
* [Eward Song (shepherdwind)](https://github.com/shepherdwind)


LICENSE
---------------------------------------
Licensed under the [MIT](https://github.com/power-assert-js/espower-source/blob/master/MIT-LICENSE.txt) license.


[npm-url]: https://npmjs.org/package/espower-source
[npm-image]: https://badge.fury.io/js/espower-source.svg

[travis-url]: https://travis-ci.org/power-assert-js/espower-source
[travis-image]: https://secure.travis-ci.org/power-assert-js/espower-source.svg?branch=master

[depstat-url]: https://gemnasium.com/power-assert-js/espower-source
[depstat-image]: https://gemnasium.com/power-assert-js/espower-source.svg

[license-url]: https://github.com/power-assert-js/espower-source/blob/master/MIT-LICENSE.txt
[license-image]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat

---
_Source: https://npm.io/package/espower-source · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
