# hasten

> Evaluate JS statically and dynamically

Latest version **0.0.2** (published 2016-12-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install hasten
pnpm add hasten
yarn add hasten
bun add hasten
```

## Health

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

Positive: no vulnerabilities.

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

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2016-12-18 |
| First published | 2016-12-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Youri Daamen |
| Maintainers | vigour-io |
| Keywords | static, eval, ast, source, traversal |

## Links

- npm: https://www.npmjs.com/package/hasten
- Repository: https://github.com/vigour-io/hasten
- Homepage: https://github.com/vigour-io/hasten#readme
- Issues: https://github.com/vigour-io/hasten/issues
- npm.io page: https://npm.io/package/hasten

## Dependencies (3)

- [falafel](https://npm.io/package/falafel.md) ^2.0.0
- [static-eval](https://npm.io/package/static-eval.md) github:vigour-io/static-eval
- [javascript-stringify](https://npm.io/package/javascript-stringify.md) ^1.5.0

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2016-12-18

## README

# hasten
Evaluate JS statically and dynamically. Hasten resolves all it can statically and asks for your input when it can't.

## api
Give it input and it will give you output:

```js
const output = hasten(src)
```

Give it variables and it will use those while resolving stuff:

```js
const output = hasten(src, {
  foo: 'baz'
})
```

Give it a callback and it will call it when it cant resolve something. Now you can return something to help **hasten** resolve:

```js
const output = hasten(src, {
  foo: 'baz'
}, (astNode, missingAstNode) => {
  if (astNode.type === 'ifStatement' && missingAstNode.name === 'device') {
    return 'phone'
  }
})
```

## example
Input:

```js
const obj = {}
obj.foo = 'bar'
if (obj.foo === 'bar') {
  console.log('success!')
}
if (/Macintosh/.test(window.navigator.userAgent)) {
  console.log('hipster!')
}
if (unknownThing === 'superman') {
  console.log('superman!')
}
```

Do something like:

```js
const output = hasten(src, {
  window: {
    navigator: {
      userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"
    }
  }
}, (astNode, missingAstNode) => {
  if (missingAstNode.name === 'unknownThing') {
    return 'bird'
  }
}
```

Output:

```js
const obj = {}
obj.foo = 'bar'
if (true) {
  console.log('success!')
}
if (true) {
  console.log('hipster!')
}
if (false) {
  console.log('superman!')
}
```

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