# main-function

> A simple wrapper that handles error and return code.

Latest version **0.1.7** (published 2023-10-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install main-function
pnpm add main-function
yarn add main-function
bun add main-function
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.7 |
| Published | 2023-10-03 |
| First published | 2019-03-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | vilicvane |
| Maintainers | vilic |

## Links

- npm: https://www.npmjs.com/package/main-function
- Repository: https://github.com/vilic/main-function
- Homepage: https://github.com/vilic/main-function#readme
- Issues: https://github.com/vilic/main-function/issues
- npm.io page: https://npm.io/package/main-function

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) ^2.6.2
- [extendable-error](https://npm.io/package/extendable-error.md) ^0.1.7

## Recent versions

- 0.1.7 (latest) — 2023-10-03
- 0.1.6 — 2023-05-17
- 0.1.5 — 2023-05-17
- 0.1.4 — 2021-09-29
- 0.1.3 — 2021-09-29
- 0.1.2 — 2019-03-10
- 0.1.1 — 2019-03-10
- 0.1.0 — 2019-03-10
- 0.0.0 — 2019-03-10

## README

[![NPM Package](https://badge.fury.io/js/main-function.svg)](https://www.npmjs.com/package/main-function)
[![Build Status](https://travis-ci.org/vilic/main-function.svg?branch=master)](https://travis-ci.org/vilic/main-function)

# Main Function

A simple wrapper that handles error and return code.

## Install

```sh
yarn add main-function
```

## Usage

```ts
import main, {ProgramError} from 'main-function';

main(async (args: string[]) => {
  // Throw an `ProgramError` to exit:
  throw new ProgramError(0, 'Some friendly error message');

  // Or throw a normal error (will print error stack and exit with code `1`):
  throw new Error():

  // Optional return statement for exit code:
  return 0;
});
```

## License

MIT License.

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