# @leismore/jsonify_function

> Convert a JavaScript function into a stringified JSON string.

Latest version **3.0.2** (published 2022-03-02) · AGPL-3.0-only license · 0 weekly downloads

## Install

```sh
npm install @leismore/jsonify_function
pnpm add @leismore/jsonify_function
yarn add @leismore/jsonify_function
bun add @leismore/jsonify_function
```

## 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 | 3.0.2 |
| Published | 2022-03-02 |
| First published | 2019-07-01 |
| Weekly downloads | 0 |
| License | AGPL-3.0-only |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 36.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kyle Chine |
| Maintainers | kyle.chine.leismore |
| Keywords | NodeJS, JavaScript, TypeScript, CouchDB, JSON, Stringify, JavaScript Function |

## Links

- npm: https://www.npmjs.com/package/@leismore/jsonify_function
- Repository: https://github.com/leismore/jsonify_function
- Homepage: https://github.com/leismore/jsonify_function#readme
- Issues: https://github.com/leismore/jsonify_function/issues
- npm.io page: https://npm.io/package/@leismore/jsonify_function

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 3.0.2 (latest) — 2022-03-02
- 3.0.1 — 2021-06-17
- 3.0.0 — 2021-03-02
- 2.0.1 — 2019-10-24
- 2.0.0 — 2019-10-24
- 1.0.0 — 2019-07-01

## README

# jsonify_function

Convert a JavaScript function into a stringified JSON string.

# Donation

Buy me a coffee via [![PayPal Donation](https://www.paypalobjects.com/en_AU/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=SPPJPYRY4D6WC&item_name=Give+people+an+option+to+support+my+open+source+software.&currency_code=AUD&source=url)

# Motivation

[CouchDB](http://couchdb.apache.org) design document architecture requires that all database handlers (JavaScript functions) are stored in a JSON structure. Functions in the JSON structure must be presented as escaped stringified strings. Similar as this:

```
{
  "updatefun": "function test(a)\n{\n  console.log('test');\n}"
}
```

[CouchDB](http://couchdb.apache.org) itself does not provide a tool for convert JavaScript functions to the JSON structure. So I wrote this simple command-line converter.

# Installation

`npm install @leismore/jsonify_function`

# Test

`npm test`

# Usage

```typescript
import {jsonify_function} from '@leismore/jsonify_function';

// Define your function here
function test()
{
  console.log('test');
}

// Output
console.log( jsonify_function(test) );
```

# License

GNU Affero General Public License v3.0

# Authors

[Kyle Chine](https://www.kylechine.name) (Initial Author)

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