# returnjs

> wraps functions and checks their return type

Latest version **0.0.8** (published 2018-01-29) · MIT license · 0 weekly downloads

## Install

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

## 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.0.8 |
| Published | 2018-01-29 |
| First published | 2018-01-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | gear4 |
| Maintainers | gear4 |
| Keywords | return, wrap, function |

## Links

- npm: https://www.npmjs.com/package/returnjs
- Repository: https://github.com/gear4s/Return.JS
- Homepage: https://raw.githubusercontent.com/gear4s/Return.JS/master/README
- Issues: https://github.com/gear4s/Return.JS/issues
- npm.io page: https://npm.io/package/returnjs

## Recent versions

- 0.0.8 (latest) — 2018-01-29
- 0.0.7 — 2018-01-29
- 0.0.6 — 2018-01-29
- 0.0.5 — 2018-01-29
- 0.0.4 — 2018-01-29
- 0.0.3 — 2018-01-29
- 0.0.2 — 2018-01-29
- 0.0.1 — 2018-01-29

## README

# Return.JS

## What is it?
A library for Node.JS that wraps functions and compares their return types to pre-defined expected returned types

## Why did you make it?
I do drunk programming a lot. It helps me a lot. /shrug

## How can I use it?
### It's simple:

First require the module:
```js
const {Return} = require("returnjs")
```

Second, define a function with some sort of return:
```js
const func = function(hi) {
  console.log(hi)
  return hi ? {} : []
}
```

Third. instantiate an object:
```js
const returnFunc = new Return(func)
```

Now comes the fun part. You can easily declare which sort of return types you want. In our case, we want array and object.


### There are three ways you can do this:

The first way:
```js
returnFunc.array
returnFunc.object
const caller = returnFunc.done
```
Which basically says that returnFunc can return either an array or object. `.done` gets an anonymous function which calls the main function

The second way:
```js
const caller = returnFunc.array.or.object.done
```
Basically, it's chained commands, saying that it can be either array or object, and to return a wrapper once it's done.

The third way is the way I prefer most, using it directly:
```js
const returnFunc = new Return(function func(hi) {
  console.log(hi)
  return hi ? {} : []
}).array.or.object.done
```
This is everything above combined.


# Disclaimer:
This entire module is drunk-code, made to make drunk programmer's lives easier

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