0.2.1 • Published 3 years ago
number-type v0.2.1
number-type
The number type.
Usage
import { NumberType, Type } from 'number-type'
const Number = Type.get('number')
const Int = Type.get('int')
class PositiveInt extends Int {
static min = 0
}
var n = new PositiveInt(123)
console.log(1 + n)
//=124
console.log(n.isValid())
//=true
console.log(n.toJson()))
//='123'
console.log(n.toJson({withType:true})))
//='{"value":123,"name":"Int","min":0}'
console.log(PositiveInt.isValid(-1))
//=false
n.assign(-1)
//=TypeError: "-1" is an invalid Int
console.log(n.assign(2)+0)
//=2
API
See abstract-type
TODO
License
MIT
2.0.0-alpha.0
3 years ago
2.0.0-alpha.2
3 years ago
0.2.1
8 years ago
0.2.0
9 years ago
0.1.1
9 years ago
0.1.0
9 years ago
0.0.1
9 years ago