Socket
Socket
Sign inDemoInstall

bijection

Package Overview
Dependencies
3
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bijection

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


Version published
Weekly downloads
9
decreased by-30.77%
Maintainers
1
Install size
1.13 MB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 28 Mar 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc