@rheactorjs/value-objects

10.1.0 • Public • Published

value-objects

npm version Build Status Greenkeeper badge js-standard-style semantic-release Test Coverage Code Climate

A collection of value objects

Common API

ValueType()

This method exposes a tcomb type validation base on instanceof or the name of the type and it's properties.

Note that instanceof can't be used always because having this check will return false, because the application using the value-objects package will create an instance that Node.js thinks to be from a different location that the one referenced in this package's uri.js

# app.js
const URIValue = require('value-objects/uri')
let u = new URIValue(…)
URIValue.Type(u) // will fail

# uri.js
URIValue.Type = t.irreducible('URIValue', (x) => x instanceof URIValue)

.equals()

You can compare two value objects with the .equals() method:

const ex = new URIValue('https://example.com') 
ex.equals(new URIValue('https://example.com')) // -> true
ex.equals(new URIValue('https://acme.com'))    // -> false

.is()

You can check if a given value is of this value object:

const ex = new URIValue('https://example.com') 
URIValue.is(ex)    // -> true
DomainValue.is(ex) // -> false

Readme

Keywords

none

Package Sidebar

Install

npm i @rheactorjs/value-objects

Weekly Downloads

0

Version

10.1.0

License

MIT

Unpacked Size

58.1 kB

Total Files

26

Last publish

Collaborators

  • coderbyheart