# @refabric/extend

> Framework to create extensible classes that behave like middleware holders and event emitters.

Latest version **1.1.4** (published 2021-11-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install @refabric/extend
pnpm add @refabric/extend
yarn add @refabric/extend
bun add @refabric/extend
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2021-11-11 |
| First published | 2021-11-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | popon |

## Links

- npm: https://www.npmjs.com/package/@refabric/extend
- npm.io page: https://npm.io/package/@refabric/extend

## Dependencies (2)

- [async](https://npm.io/package/async.md) ^3.2.1
- [@types/async](https://npm.io/package/@types/async.md) ^3.2.8

## Recent versions

- 1.1.4 (latest) — 2021-11-11

## README

# Refabric Extend

Framework to create extensible classes that behave like middleware holders and event emitters.

# Get Started

Install `extend`.

```sh
npm install @refabric/extend
```

Extend the extensible class.

```javascript
import { Extensible } from '@refabric/extend';
import assert from 'assert';

class Counter extends Extensible {
  async count(context) {
    await this.processExtensions(context);
  }
}

const counter = new Counter();
counter.extend((ctx) => ctx.count++);
counter.extend((ctx) => ctx.count *= 2);

const ctx = {
  count: 1,
};

counter.count(ctx).then(() => {
  assert(ctx.count === 4);
});
```

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