open-index/open-npm huggingface dataset:
npm package: @mightylittle/event-emitter
Description: Simple event-emitter implementation.
Author: John Newton
Latest version: 0.2.0

# @mighty-little/event-emitter

> Simple event-emitter implementation

## Usage

Example:

```typescript
type Foo = {
  foo: string;
}

const emitter = new EventEmitter();

const onFooHandler = (data?: Foo) => console.log("'on' triggered", data);

emitter.once<Foo>("foo", (data?: Foo) => console.log("'once' triggered", data));
emitter.on<Foo>("foo", onFooHandler);
emitter.emit<Foo>("foo", {foo: "bar"});
emitter.emit<Foo>("foo", {foo: "baaz"});
emitter.off<Foo>("foo", onFooHandler);
emitter.emit<Foo>("foo", {foo: "quux"});

// Output:
// 'once' triggered { foo: 'bar' }
// 'on' triggered { foo: 'bar' }
// 'on' triggered { foo: 'baaz' }
```

## Installation

```sh
npm install
```

## Development

Build:

```sh
npm run build
```

Run tests:

```sh
npm run test
```

Build docs:

```sh
npm run typedoc
```

## Author

* John Newton

## Copyright

* John Newton

## License

Apache-2.0
npm package: @mightylittle/router
Description: Simple, regex-based URL dispatcher
Author: John Newton
Latest version: 0.2.0

# @mightylittle/router

> Simple regex-based URL dispatcher for browser apps

This router is suitable for running in the main window or in a web worker.

There is no built-in integration with pushState or any other DOM API, so
you are expected to write your own code to call the dispatch method. See
the demo subdirectory for an example SPA.

## Usage

JavaScript example:

```javascript
const router = new Router({
  notFound: () => {
    console.log("404");
  },
  routes: {
    "/": () => {
      console.log("base route");
    },
    "/widgets/:widget": (context) => {
      console.log("widgetId", context.binding.widget); // => xyz
      console.log("url", context.url); // => http://www.example.net/widgets/xyz?hello=world
      console.log("data", context.data); // => {foo: "bar"}
    }
  }
});

router.dispatch(new URL("http://www.example.net/widgets/xyz?hello=world"), {foo: "bar"});
```

## Installation

```sh
npm install
```

## Development

Build:

```sh
npm run build
```

Run tests:

```sh
npm run test
```

Build docs:

```sh
npm run typedoc
```

## Author

* John Newton

## Copyright

* John Newton

## License

Apache-2.0
npm package: @mightylittle/transaction-log
Description: In-memory, non-threadsafe replayable logs.
Author: John Newton
Latest version: 0.3.0

# @mightylittle/transaction-log

The package defines two exported classes:

* MemorySimpleTransactionLog
* MemoryBatchedTransactionLog

## Usage

### MemorySimpleTransactionLog

JavaScript example:

```javascript
import { MemorySimpleTransactionLog } from "@mightylittle/transaction-log";

async function start () {
  const log = new MemorySimpleTransactionLog();
  await log.open();
  await log.append("foo");
  await log.append("bar");
  await log.countTransactions(); // => 2
  await log.replay((data) => console.log("data", data));
  await console.log("transactions", await log.getSeqRangeTransactions(1, 2)); // returns the first and second entries
  await log.close();
  await log.clear();
}
```

### MemoryBatchedTransactionLog

JavaScript example:

```javascript
import { MemoryBatchedTransactionLog } from "@mightylittle/transaction-log";

async function start () {
  const log = new MemoryBatchedTransactionLog();
  await log.open();
  log.append("foo");
  log.append("bar");
  await log.commit();
  await log.countTransactions(); // => 2
  await log.countCommits(); // => 1
  await log.replay((data) => console.log("data", data), true);
  await console.log("transactions", await log.getSeqRangeTransactions(1, 2)); // prints the first and second entries
  await console.log("commits", await log.getSeqRangeCommits(1)); // prints the first and any later commits
  await log.close();
  await log.clear();
}
```

## Installation

```sh
npm install
```

## Development

Build:

```sh
npm run build
```

Run tests:

```sh
npm run test
```

Generate documentation:

```sh
npm run typedoc
```

## Author

* John Newton

## Copyright

* John Newton

## License

Apache-2.0
npm package: @mightylittle/transaction-log-idb
Description: Replayable logs using IndexedDB.
Author: John Newton
Latest version: 0.2.0

# @mightylittle/transaction-log-idb

> Replayable logs using IndexedDB

The package defines two exported classes:

* IDBSimpleTransactionLog
* IDBBatchedTransactionLog

## Usage

### IDBSimpleTransactionLog

JavaScript example:

```javascript
import { IDBSimpleTransactionLog } from "@mightylittle/transaction-log-idb";

async function start () {
  const log = new IDBSimpleTransactionLog();
  await log.open();
  await log.append("foo");
  await log.append("bar");
  await log.countTransactions(); // => 2
  await log.replay((data) => console.log("data", data));
  await console.log("transactions", await log.getSeqRangeTransactions(1, 2)); // returns the first and second entries
  await log.close();
  await log.clear();
}
```

### IDBBatchedTransactionLog

JavaScript example:

```javascript
import { IDBBatchedTransactionLog } from "@mightylittle/transaction-log-idb";

async function start () {
  const log = new IDBBatchedTransactionLog();
  await log.open();
  log.append("foo");
  log.append("bar");
  await log.commit();
  await log.countTransactions(); // => 2
  await log.countCommits(); // => 1
  await log.replay((data) => console.log("data", data), true);
  await console.log("transactions", await log.getSeqRangeTransactions(1, 2)); // prints the first and second entries
  await console.log("commits", await log.getSeqRangeCommits(1)); // prints the first and any later commits
  await log.close();
  await log.clear();
}
```

## Installation

```sh
npm install
```

## Development

Build:

```sh
npm run build
```

Run tests:

```sh
npm run test
```

NOTE: the mocha tests run in-browser, where IndexedDB is supported.

Generate documentation:

```sh
npm run typedoc
```

## Dependencies

* [idb](https://www.npmjs.com/package/idb)

## Author

* John Newton

## Copyright

* John Newton

## License

Apache-2.0