open-index/open-npm huggingface dataset:
npm package: @soundtype/commander
Description: A type-safe wrapper around [commander.js](https://github.com/tj/commander.js) with excellent type inference.
Latest version: 0.2.0

# `@soundtype/commander`

A type-safe wrapper around [commander.js](https://github.com/tj/commander.js) with excellent type inference.

## Usage

```ts
import { program } from '@soundtype/commander';

const myProgram = program('my-app', '1.0.0')
  .option({
    name: 'bool',
    description: 'this is a boolean',
    default: false,
  })
  .option({
    name: 'num',
    description: 'this is a number',
    default: undefined,
    parse: str => {
      const value = parseInt(str, 10);
      if (Number.isNaN(value)) throw new Error('This is not an int');
      return value;
    },
  })
  .variadic({ name: 'positional', required: true })
  .build();

// result type is `{ num?: number, bool: boolean, positional: string[] }`
const result = myProgram.parse(process.argv);
```

## Local Development

This project was bootstrapped with [TSDX](https://github.com/jaredpalmer/tsdx).

Below is a list of commands you will probably find useful.

### `npm start` or `yarn start`

Runs the project in development/watch mode. Your project will be rebuilt upon changes. TSDX has a special logger for you convenience. Error messages are pretty printed and formatted for compatibility VS Code's Problems tab.

<img src="https://user-images.githubusercontent.com/4060187/52168303-574d3a00-26f6-11e9-9f3b-71dbec9ebfcb.gif" width="600" />

Your library will be rebuilt if you make edits.

### `npm run build` or `yarn build`

Bundles the package to the `dist` folder.
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).

<img src="https://user-images.githubusercontent.com/4060187/52168322-a98e5b00-26f6-11e9-8cf6-222d716b75ef.gif" width="600" />

### `npm test` or `yarn test`

Runs the test watcher (Jest) in an interactive mode.
By default, runs tests related to files changed since the last commit.
npm package: @soundtype/eventemitter
Description: A typesafe event emitter for TypeScript
Latest version: 0.1.0

# `@soundtype/eventemitter`

A typesafe event emitter for TypeScript

## Usage

```ts
import { EventEmitter } from '@soundtype/eventemitter';

const ee = new EventEmitter<{ someString: string; someNumber: number }>();

ee.emit('someString', 'string'); // autocompletes `someString`, and ensures the value is a string
ee.emit('someNumber', 42); // autocompletes `someNumber`, and ensures the value is a number

ee.emit('problem', 'will fail'); // <- this will fail in compile time (no such event name 'problem')
ee.emit('someString', {}); // <- this will fail in compile time (expected string)
ee.emit('someNumber', {}); // <- this will fail in compile time (expected string)

(async () => {
  const someString = await ee.waitFor('someString'); // you can get one with a Promise API. Types are inferred based on the event name

  ee.once('someString', value => {
    // you can run things only once, without a Promise API
    // types are inferred correctly based on the event name
  });

  const unsubscribe = ee.addListener('someString', value => {
    // you can add listeners for events
    // types are inferred correctly based on the event name
  });

  unsubscribe(); // you can easily unsubscribe by using the return value
})();
```

## Local Development

This project was bootstrapped with [TSDX](https://github.com/jaredpalmer/tsdx).

Below is a list of commands you will probably find useful.

### `npm start` or `yarn start`

Runs the project in development/watch mode. Your project will be rebuilt upon changes. TSDX has a special logger for you convenience. Error messages are pretty printed and formatted for compatibility VS Code's Problems tab.

<img src="https://user-images.githubusercontent.com/4060187/52168303-574d3a00-26f6-11e9-9f3b-71dbec9ebfcb.gif" width="600" />

Your library will be rebuilt if you make edits.

### `npm run build` or `yarn build`

Bundles the package to the `dist` folder.
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).

<img src="https://user-images.githubusercontent.com/4060187/52168322-a98e5b00-26f6-11e9-8cf6-222d716b75ef.gif" width="600" />

### `npm test` or `yarn test`

Runs the test watcher (Jest) in an interactive mode.
By default, runs tests related to files changed since the last commit.