# @openovate/jsm

> JavaScript Modules that Work in Node, and Browser

Latest version **0.0.19** (published 2019-10-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @openovate/jsm
pnpm add @openovate/jsm
yarn add @openovate/jsm
bun add @openovate/jsm
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.19 |
| Published | 2019-10-21 |
| First published | 2019-09-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 65.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Christian Blanquera |
| Maintainers | cblanquera |

## Links

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

## Recent versions

- 0.0.19 (latest) — 2019-10-21
- 0.0.18 — 2019-10-15
- 0.0.17 — 2019-10-14
- 0.0.16 — 2019-10-11
- 0.0.15 — 2019-10-11
- 0.0.14 — 2019-10-02
- 0.0.13 — 2019-09-30
- 0.0.12 — 2019-09-19
- 0.0.11 — 2019-09-19
- 0.0.10 — 2019-09-18
- 0.0.9 — 2019-09-18
- 0.0.8 — 2019-09-18
- 0.0.7 — 2019-09-18
- 0.0.6 — 2019-09-17
- 0.0.5 — 2019-09-17
- … 3 more at https://npm.io/package/@openovate/jsm/versions

## README

# jsm

JavaScript Modules that Work in Node, and Browser

## Install

```bash
$ npm i @openovate/jsm
```

## EventEmitter Usage

```js
const { EventEmitter } = require('@openovate/jsm')

const emitter = new EventEmitter;

emitter.on('trigger something', async x => {
  console.log('something triggered', x + 1)
})

emitter.on(/trigger (something)/, async x => {
  await Helper.sleep(2000)
  console.log('(something) triggered', x + 2)
}, 2)

await emitter.emit('trigger something', 1)
```

## Exception Usage

```js
const { Exception } = require('@openovate/jsm')

throw Exception.for('Something %s is %s', 'good', 'bad')
```

## Registry Usage

```js
const { Registry } = require('@openovate/jsm')

const registry = Registry.load()

registry.set('foo', 'bar', 'zoo')
registry.set('foo', 'zoo', ['foo', 'bar', 'zoo'])

console.log(registry.has('foo', 'bar'))
console.log(registry.has('bar', 'foo'))
console.log(registry.get('foo', 'zoo', 1))

registry.remove('foo', 'bar')

console.log(registry.has('foo', 'bar'))
console.log(registry.has('foo', 'zoo'))
```

## TaskQueue Usage

```js
const { TaskQueue } = require('@openovate/jsm')

const queue = new TaskQueue;

queue.push(async x => {
  console.log(x + 1)
})

queue.shift(async x => {
  await Helper.sleep(2000)
  console.log(x + 2)
})

queue.add(async x => {
  console.log(x + 3)
}, 10)

await queue.run(1)
```

## Reflection Usage

```js
class Foo {
  foo(x, y, z) {
    return x + y + z;
  }
}

const foo = new Foo;
const names = reflect(foo.foo).getArgumentNames(); //--> x, y, z

const descriptors1 = reflect(Foo1).getDescriptors(); //--> {foo: {...}}
const descriptors2 = reflect(foo).getDescriptors(); //--> {foo: {...}}

const methods1 = reflect(Foo1).getMethods(); //--> {foo: function}
const methods2 = reflect(foo).getMethods(); //--> {foo: function}
```

## traits Usage

```js
const { traits } = require('@openovate/jsm')

class Bar {
  bar() {}
}

class Zoo {
  zoo() {}
}

class Foo2 extends traits(Bar, Zoo) {
  foo() {}
}

const foo = new Foo2

foo.foo()
foo.bar()
foo.zoo()
```

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