0.1.1 • Published 3 years ago

boolean-type v0.1.1

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

boolean-type npm

Build Status Code Climate Test Coverage downloads license

The boolean type info object.

Usage

import { BooleanType } from 'boolean-type'

var b = new BooleanType('true', {
  boolNames: {
    false: ['false', 'no', 'wrong']
    true:  ['true', 'yes', 'ok']
  }
})
//or b= Bool.create('yes')
//or b= Bool.create('ok')
console.log(String(b))
//=true
console.log(b.isValid())
//=true
console.log(s.toJson()))
//="true"
console.log(s.toJson({withType:true})))
//='{"value":"true","name":"Boolean","boolNames":{"false":["false","no","wrong"],"true":["true","yes","ok"]}}'
n.assign('w')
//=TypeError: "w" is an invalid Boolean
n.assign('wrong')
//n.valueOf()=false

API

See abstract-type

TODO

License

MIT