taxonify
v2.2.0
Published
Categorization helper library
Downloads
22
Maintainers
Readme
taxonify
Categorize your stuff
Quick start
You need some categories, define them like this:
function relationships (define) {
define('automobile', ['car', 'truck'])
define('car', ['camry', 'accord'])
define('truck', ['ridgeline', 'tacoma'])
define('honda', ['accord', 'ridgeline'])
define('toyota', ['camry', 'tacoma'])
}
Now hand the relationships
function to taxonify
import { taxonify } from 'taxonify'
const { createVerifier, brand } = taxonify(relationships)
Make a verifier function (or two)
const isTruck = createVerifier('truck')
const isHonda = createVerifier('honda')
Brand an object with one of your categories
const myAccord = brand({ color: red, sunroof: true }, 'accord')
And you're ready to verify your object
isTruck(myAccord) // false
isHonda(myAccord) // true