# psdad

> implementation of psdad data interop proposal

Latest version **0.4.0** (published 2019-06-08) · MIT license · 0 weekly downloads

## Install

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

## 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.4.0 |
| Published | 2019-06-08 |
| First published | 2018-12-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 57.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Sandro Hawke |
| Maintainers | sandhawke |
| Keywords | sandhawke |

## Links

- npm: https://www.npmjs.com/package/psdad
- Repository: https://github.com/sandhawke/psdad.js
- Homepage: https://github.com/sandhawke/psdad.js#readme
- Issues: https://github.com/sandhawke/psdad.js/issues
- npm.io page: https://npm.io/package/psdad

## Dependencies (8)

- [debug](https://npm.io/package/debug.md) ^4.1.0
- [yargs](https://npm.io/package/yargs.md) ^12.0.5
- [xregexp](https://npm.io/package/xregexp.md) ^4.2.0
- [completarr](https://npm.io/package/completarr.md) ^0.2.1
- [get-stream](https://npm.io/package/get-stream.md) ^4.1.0
- [into-stream](https://npm.io/package/into-stream.md) ^4.0.0
- [@sindresorhus/is](https://npm.io/package/@sindresorhus/is.md) ^0.14.0
- [js-longest-repeated-substring](https://npm.io/package/js-longest-repeated-substring.md) ^1.0.3

## Recent versions

- 0.4.0 (latest) — 2019-06-08
- 0.3.0 — 2018-12-31
- 0.2.0 — 2018-12-30
- 0.1.0 — 2018-12-30

## README

# psdad.js
[![NPM version][npm-image]][npm-url]

JavaScript implementation of [psdad](https://sandhawke.github.io/psdad/spec.html), for node.js or browsers

## Example

Example (in demo.js)

```js
const { mapper } = require('psdad')
const vocab = mapper()

class Circle { constructor (state) { Object.assign(this, state) } }
class Line   { constructor (state) { Object.assign(this, state) } }

vocab.add(Circle, 'There is a circle of radius [number radius] at position ([number x], [number y]).')
vocab.add(Line, 'There is a line from ([number x0], [number y0]) to ([number x1], [number y1]).')

const mydata =  [
  new Circle({radius: 1, x: 10, y: 20}),
  new Line({x0: 10, y0: 20, x1: 15, y1: 25}),
  new Circle({radius: 2, x: 15, y: 25}),
]

const str = vocab.stringify(mydata)
console.log(str)
/* =>
There is a circle of radius 1 at position (10, 20).

There is a line from (10, 20) to (15, 25).

There is a circle of radius 2 at position (15, 25).

*/

const mydata2 = vocab.parse(str)
console.log(mydata2)
/* =>
[ Circle { radius: 1, x: 10, y: 20 },
  Line { x0: 10, y0: 20, x1: 15, y1: 25 },
  Circle { radius: 2, x: 15, y: 25 } ]
*/
```

## Performance

Some quick tests show stringify() running about 1m objects per second,
and parse() running about about 150k objects per second.  That's not
as fast as the native JSON functions (maybe 50% of JSON on stringify
and 10% on parse), but it's still probably fast enough. The parsing is
all done with one compiled regexp. It will be interesting to see how
it's affect by having larger definitions and more classes.

[npm-image]: https://img.shields.io/npm/v/psdad.svg?style=flat-square
[npm-url]: https://npmjs.org/package/psdad

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