# bijection

> Node.js utility for mapping the properties of two Objects between each other

Latest version **0.6.1** (published 2015-03-28) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.1 |
| Published | 2015-03-28 |
| First published | 2014-08-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Travis Webb |
| Maintainers | tjwebb |
| Keywords | orm, schema, mapping, json, transform, translate, mapObject, waterline, sails, morph, congruence, lodash, bijection, bijective |

## Links

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

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^3.4
- [congruence](https://npm.io/package/congruence.md) ^1.6

## Recent versions

- 0.6.1 (latest) — 2015-03-28
- 0.6.0 — 2015-03-28
- 0.5.2 — 2015-02-22
- 0.5.1 — 2015-02-22
- 0.0.3 — 2014-08-23
- 0.0.2 — 2014-08-23
- 0.0.1 — 2014-08-23
- 0.0.0 — 2014-08-22

## README

bijection
=====================

[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Dependency Status][daviddm-image]][daviddm-url]

Map an input Object `x` to an output Object `y` via a bijective function `f`, i.e. `f: X -> Y`

## Install
```sh
$ npm install bijection --save
```

## Usage
```js
var Bijection = require('bijection');
var LegacyAccount = {
  identity: 'crmacct',
  attributes: {
    crmacct_id: 'integer',
    crmacct_name: 'string'
  }
};
var Account = {
  identity: 'Account',
  attributes: {
    id: 'integer',
    sobriquet: 'string',
  }
};
var AccountBijection = new Bijection({
  domain: Account,
  codomain: [ LegacyAccount ],
  mapping: {
    id: 'crmacct_id',
    sobriquet: 'crmacct_name'
  }
});
var tjwebbLegacyAccount = AccountBijection.map({ id: 1, sobriquet: 'tjwebb' });
/**
 * tjwebbLegacyAccount = {
 *   crmacct_id: 1,
 *   crmacct_name: 'tjwebb'
 * };
 */
```

## API

#### `new Bijection(f)`
Create a new bijection between two domains

| @param | description
|:--|:--|
| `f.domain` | The input domain
| `f.codomain` | The output domain
| `f.mapping` | Declarative object that indicates the mapping from `X -> Y`

#### `.map(x)`
Map an input Object `x` to an output Object `y` via a bijective function `f`, i.e. `f: X -> Y`

| @param | description
|:--|:--|
| `x` | The input object to map onto codomain `Y`
| **@return** | **description**
| `y` | A particular image of codomain `Y` resulting from mapping an input `x` onto it

## License
MIT

[npm-image]: https://img.shields.io/npm/v/bijection.svg?style=flat-square
[npm-url]: https://npmjs.org/package/bijection
[travis-image]: https://img.shields.io/travis/tjwebb/bijection.svg?style=flat-square
[travis-url]: https://travis-ci.org/tjwebb/bijection
[daviddm-image]: http://img.shields.io/david/tjwebb/bijection.svg?style=flat-square
[daviddm-url]: https://david-dm.org/tjwebb/bijection

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