# @straw-hat/chainable-config

> Allow you to create Chainable configurations

Latest version **0.9.1** (published 2022-03-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @straw-hat/chainable-config
pnpm add @straw-hat/chainable-config
yarn add @straw-hat/chainable-config
bun add @straw-hat/chainable-config
```

## Health

**Score 35/100 (D)** — status: abandoned.

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

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.9.1 |
| Published | 2022-03-15 |
| First published | 2020-11-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 43.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 9 |
| Maintainers | ubi |
| Keywords | webpack-chain, jest-chain, config, chainable, straw-hat-team |

## Links

- npm: https://www.npmjs.com/package/@straw-hat/chainable-config
- Repository: https://github.com/straw-hat-team/javascript-monorepo
- npm.io page: https://npm.io/package/@straw-hat/chainable-config

## Dependencies (3)

- [deepmerge](https://npm.io/package/deepmerge.md) ^4.2.2
- [is-mergeable-object](https://npm.io/package/is-mergeable-object.md) ^1.1.1
- [javascript-stringify](https://npm.io/package/javascript-stringify.md) ^2.1.0

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.9.1 (latest) — 2022-03-15
- 0.9.0 — 2020-12-21
- 0.8.0 — 2020-12-21
- 0.7.1 — 2020-11-25
- 0.7.0 — 2020-11-25
- 0.6.0 — 2020-11-25
- 0.5.0 — 2020-11-25
- 0.4.0 — 2020-11-25
- 0.3.0 — 2020-11-25
- 0.2.0 — 2020-11-25
- 0.1.0 — 2020-11-03
- 0.0.1 — 2020-11-03

## README

# @straw-hat/chainable-config

Use a chaining API to generate and simplify the modification of configurations.

## Usage

- [Reference guides](./docs/reference/index.html) Please use `yarn docs:reference`
  to generate the reference docs.

```typescript
import { ChainedMap, OrderableChainedMap, ChainedSet } from '@straw-hat/chainable-config';

const chainedMap = new ChainedMap();

// ..or

export class DevServer<P> extends ChainedMap<P> {
  bonjour(value: boolean) {
    return this.set('bonjour', value);
  }
}

class Resolve<P> extends ChainedMap<P> {
  constructor(parent: P) {
    super(parent);
    this.set(
      'extensions',
      new OrderableChainedMap(this, {
        // Its allows you to return the configuration as an array rather than an
        // object
        asArray: true,
        // Its allows you to return undefined in case there is not values set
        emptyAsUndefined: true,
      })
    );
  }
}

class WebpackChain extends ChainedMap {
  // your own methods here..
  constructor() {
    super(undefined);
    this.set('devServer', new DevServer(this));
    this.set('resolve', new Resolve(this));
  }

  get devServer(): DevServer<WebpackChain> {
    return this.get('devServer');
  }

  bail(value: boolean) {
    return this.set('bail', value);
  }
}

const myConfig = new WebpackChain();

myConfig.bail(true).devServer.bonjour(true);

// Return the config
myConfig.toConfig();
// {
//   bail: true,
//   devServer: {
//     bonjour: true
//   }
// }
```

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