taxonify

Categorization helper library

Usage no npm install needed!

<script type="module">
  import taxonify from 'https://cdn.skypack.dev/taxonify';
</script>

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