# transform-dwayne-js-expressions

> The plugin is needed for transforming Dwayne javascript expressions.

Latest version **5.6.3** (published 2017-07-06) · 0 weekly downloads

## Install

```sh
npm install transform-dwayne-js-expressions
pnpm add transform-dwayne-js-expressions
yarn add transform-dwayne-js-expressions
bun add transform-dwayne-js-expressions
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.6.3 |
| Published | 2017-07-06 |
| First published | 2017-06-14 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 8 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | dwaynejf |

## Links

- npm: https://www.npmjs.com/package/transform-dwayne-js-expressions
- npm.io page: https://npm.io/package/transform-dwayne-js-expressions

## Dependencies (8)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [babylon](https://npm.io/package/babylon.md) ^6.16.1
- [source-map](https://npm.io/package/source-map.md) ^0.5.6
- [babel-types](https://npm.io/package/babel-types.md) ^6.23.0
- [babel-traverse](https://npm.io/package/babel-traverse.md) ^6.23.1
- [babel-generator](https://npm.io/package/babel-generator.md) ^6.23.0
- [sourcemap-codec](https://npm.io/package/sourcemap-codec.md) ^1.3.1
- [lines-and-columns](https://npm.io/package/lines-and-columns.md) ^1.1.6

## Recent versions

- 5.6.3 (latest) — 2017-07-06
- 5.6.2 — 2017-07-06
- 5.6.1 — 2017-06-27
- 5.6.0 — 2017-06-27
- 5.5.0 — 2017-06-21
- 5.4.2 — 2017-06-20
- 5.4.1 — 2017-06-19
- 5.4.0 — 2017-06-19
- 5.3.0 — 2017-06-19
- 5.2.2 — 2017-06-19
- 5.2.1 — 2017-06-18
- 5.2.0 — 2017-06-18
- 5.1.0 — 2017-06-17
- 5.0.2 — 2017-06-14
- 5.0.1 — 2017-06-14
- … 1 more at https://npm.io/package/transform-dwayne-js-expressions/versions

## README

## transform-dwayne-js-expressions

The plugin is needed for transforming Dwayne javascript expressions.

### Installation

```bash
npm install --save transform-dwayne-js-expressions
```

### Usage

```js
const transformDwayneJs = require('transform-dwayne-js-expressions');

const transformed = transformDwayneJs('Math.sin(a) + b', {
  filename: 'test.js',
  sourceMap: true,
  unscopables: ['Math']
});

// {
//   code: `function (_) {
//     return Math.sin(_.a) + _.b;
//   }`,
//   map: { ... },
//   vars: ['a', 'b']
// }
```

### API

```
transformDwayneJs(code: string, options?: {
  filename?: string = 'unknown',
  sourceMap?: boolean = true,
  unscopables?: string[] = ['require'],
  keepScope?: boolean = false,
  thisVarName?: string = '_this',
  useES6?: boolean = false
}): {
  code: string,
  map: SourceMap | null,
  vars: string[],
  generatedThisVar: boolean
}
```

* `options.filename` (default: `'unknown'`): filename for sourcemaps.
* `options.sourceMap` (default: `true`): if it's needed to produce
a sourcemap.
* `options.unscopables` (default: `['require']`): an array of the
vars that aren't meant to be in the block scope.
* `options.keepScope` (default: false): if it is needed to prefix
the variables with the scope var.
* `options.thisVarName` (default: `'_this'`): in the case when
`options.keepScope` is set to `true` all occurrences of `this` are
replaced with this value.
* `options.useES6` (default: `false`): if it is needed to use es6:
generating an arrow function instead of usual function and not
generating `options.keepScope` identifier. It's better to set this
option to `true` and leave transforming ES6 into ES5 to babel or
other similar tools.
* `options.startLine` (default: `1`): used for error messages.
* `options.startColumn` (default: `0`): used for error messages.
* `options.startPosition` (default: `0`): used for error messages.

Returns an object with the following properties:

* `code`: generated code.
* `map`: generated sourcemap.
* `vars`: used scope vars.
* `generatedThisVar`: whether `options.thisVarName` was generated or not.

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