0.6.1 • Published 10 years ago

bijection v0.6.1

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

bijection

NPM version Build status Dependency Status

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

Install

$ npm install bijection --save

Usage

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

@paramdescription
f.domainThe input domain
f.codomainThe output domain
f.mappingDeclarative 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

@paramdescription
xThe input object to map onto codomain Y
@returndescription
yA particular image of codomain Y resulting from mapping an input x onto it

License

MIT

0.6.1

10 years ago

0.6.0

10 years ago

0.5.2

10 years ago

0.5.1

10 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago