# lift-result

> lift functions so they can handle Results as if they were plain values

Latest version **0.1.5** (published 2014-04-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install lift-result
pnpm add lift-result
yarn add lift-result
bun add lift-result
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2014-04-12 |
| First published | 2013-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Jake Rosoman |
| Maintainers | jkroso |
| Keywords | result, promise, decorate, function |

## Links

- npm: https://www.npmjs.com/package/lift-result
- Repository: https://github.com/jkroso/lift-result
- Issues: https://github.com/jkroso/lift-result/issues
- npm.io page: https://npm.io/package/lift-result

## Dependencies (1)

- [result](https://npm.io/package/result.md) ~1.0.2

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 0.1.5 (latest) — 2014-04-12
- 0.1.4 — 2014-02-16
- 0.1.3 — 2013-11-21
- 0.1.2 — 2013-11-20
- 0.1.1 — 2013-09-06
- 0.1.0 — 2013-09-02

## README

# lift-result

  lift functions so they can handle [results](//github.com/jkroso/result) as if they were plain values.

## Installation

With your favourite package manager:

- [packin](//github.com/jkroso/packin): `packin add lift-result`
- [component](//github.com/component/component#installing-packages): `component install jkroso/lift-result`
- [npm](//npmjs.org/doc/cli/npm-install.html): `npm install lift-result`

then in your app:

```js
var lift = require('lift-result')
var liftCPS = require('lift-result/cps')
var apply = require('lift-result/apply')
var sexpr = require('lift-result/sexpr')
```

## API

### lift(fn)

  decorate `fn` so it can receive promises as arguments. Return
  values will be unboxed wherever possible however errors will
  be caught and boxed with a promise since this means you don't
  have to handle sync and async errors separately.

```js
var Result = require('result')
var add = lift(function(a, b){ return a + b })
add(1, 2) // => 3
add(Result.wrap(1), 2) // => 3
var one = new Result
var answer = add(one, 2) // => new Result
one.write(1)
answer.value // => 3
```

### cps(fn)

  decorate a node function so it can receive Results as arguments and will return a result rather than take a callback as its last argument.

```js
var fs = require('fs')
var readFile = liftCPS(fs.readFile)
readFile('Readme.md').read(function(buf){
  buf // => fs.readFileSync('Readme.md')
})
```

### apply(..., fn)

  apply arguments to the last argument

```js
apply(Result.wrap(1), 2, Array) // => [1, 2]
```

### sexpr(fn, ...)

  apply rest of args to `fn`

```js
sexpr(Array, Result.wrap(1), 2) // => [1, 2]
```

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