# multimix

> Objects with auto-generated property chains

Latest version **6.0.0** (published 2022-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install multimix
pnpm add multimix
yarn add multimix
bun add multimix
```

## 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 | 6.0.0 |
| Published | 2022-08-28 |
| First published | 2016-08-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 42 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | loveencounterflow |
| Maintainers | loveencounterflow |
| Keywords | multimix, hedges, properties |

## Links

- npm: https://www.npmjs.com/package/multimix
- Repository: https://github.com/loveencounterflow/multimix
- Issues: https://github.com/loveencounterflow/multimix/issues
- npm.io page: https://npm.io/package/multimix

## Dependencies (2)

- [guy](https://npm.io/package/guy.md) 11.8.0
- [intertype](https://npm.io/package/intertype.md) ^10.1.0

## Recent versions

- 6.0.0 (latest) — 2022-08-28
- 5.0.0 — 2020-12-04
- 4.1.0 — 2020-06-23
- 4.0.0 — 2020-05-23
- 3.0.1 — 2020-05-22
- 3.0.0 — 2020-05-22
- 2.2.1 — 2020-04-26
- 2.2.0 — 2020-03-25
- 2.1.6 — 2020-02-18
- 2.1.5 — 2020-02-18
- 2.1.4 — 2020-02-10
- 2.1.3 — 2020-02-06
- 2.1.2 — 2020-02-06
- 2.1.1 — 2019-11-13
- 2.1.0 — 2019-10-19
- … 6 more at https://npm.io/package/multimix/versions

## README

# MultiMix

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [MultiMix](#multimix)
  - [To Do](#to-do)
  - [Is Done](#is-done)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->



![](https://raw.githubusercontent.com/loveencounterflow/multimix/master/artwork/multimix.png)

# MultiMix

* Objects with auto-generated property chains

* class `Hedge`
  * purpose: enable turning property access to function calls
    * propoerties may be predefined
    * or auto-generated, either
      * as plain objects
      * or by calling a custom factory function
    * example:

      ```coffee
      handler = ( hedges, a, b, c ) ->
        log hedges, [ a, b, c, ]
        return null
      h = new Hedge { handler, }
      h.foo
      # [ 'foo',  ]
      ```

* since hubs and properties are proxies, can do things on property access, no call needed, so both `d.foo`
  and `d.foo 42` can potentially do things



* `cfg`:

  * `cfg.handler`: mandatory property; function to be called on prop access, call, or both
    * `d = new Multimix { handler, }` returns the handler wrapped into a proxy
    * the `Multimix` instance is accessible as `d[Multimix.symbol]`. `Multimix.symbol` is a private symbol
      and thus guaranteed not to overwrite or shadow an existing property
    * existing properties of `handler` will be returned
    * non-existant properties of `handler` will be auto-generated on first access; these will be functions
      that, when called with any number of arguments `f P...`, will in turn call `handler props, P...`
    * `handler` will be called in the context of `hub` where given; otherwise, its context will be the
      `Multimix` instance.

  * `hub`: optional reference / base object (re 'hub': as if props were spokes)

  * `cfg.create`:
    * `true` (default): missing props will be auto-generated as functions that call `handler` in the context
      of `cfg.hub` where given (or else the `Multimix` instance)
    * `false`: no missing props will be generated
    * a function: to be called as `create key, target` when a new property is first accessed; this function
      may or may not create a new property as seen fit. The MultiMix proxy will, at any rate, return
      `target[ key ]` which may or may not be `undefined`.

  * `cfg.strict`: (default `false`) if set to `true`, trying to access an unset property will cause an
    error. This setting is only valid when used in conjunction with `create: false`.

  * `cfg.oneshot`: (default `false`) if set to `true`, trying to re-assign any value to an existing property
    will cause an error

  * `cfg.deletion`: (default `true`) if set to `false`, trying to delete any property will cause an error

  * `cfg.hide`: (default `true`) if set to `true`, will make auto-generated properties non-enumerable so
    they don't show up in console output

## To Do

* **[–]** documentation

## Is Done

* **[+]** `cfg.strict`
* **[+]** `cfg.oneshot`
* **[+]** `cfg.deletion`

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