Skip to content
Conan edited this page Mar 29, 2023 · 14 revisions

match-iz 🔥 docs

import { match, when, otherwise } from 'match-iz'

Scroll down for:

Pages in this documentation:

Pattern-helper Cheatsheets

Follow the links in the headers for example usage.

Core Pattern-helpers

import { gt, lt, startsWith, ...etc } from 'match-iz'
Numbers Strings Strings/Arrays Arrays Truthiness Primitives Negation Combinators
gt(n) startsWith('s') includes(o) some(...) empty isArray not(...) allOf(...)
lt(n) endsWith('s') - every(...) falsy isDate - anyOf(...)
gte(n) - - - defined isFunction - firstOf(...)
lte(n) - - - truthy isNumber - lastOf(...)
inRange(x,y) - - - eq(obj) isPojo - includedIn(...)
- - - - deepEq(obj) isRegExp - hasOwn(...)
- - - - - isString - isStrictly
- - - - - instanceOf - -

Date Pattern-helpers

import { isHour, isDay, isTime, ...etc } from 'match-iz/dates'
import { isHour, isDay, isTime, ...etc } from 'match-iz/dates/utc'
Time Days of the week Weeks of the month Months Years
isHour(0..23) isDay(-31..31) nthSun(-5..5) isMonth(1..12) isYear(n)
isMinute(0..59) isDayOfWeek(0..6) nthMon(-5..5) - isWeekNumber(1..52)
isSecond(0..59) - nthTue(-5..5) isJan isLeapYear
- isSun nthWed(-5..5) isFeb -
isAM isMon nthThu(-5..5) isMar -
isPM isTue nthFri(-5..5) isApr -
isMorning isWed nthSat(-5..5) isMay -
isAfternoon isThu - isJun -
isEvening isFri - isJul -
- isSat - isAug -
isBefore(date) - - isSep -
isAfter(date) - - isOct -
- - - isNov -
inThePast(n,timeFrame) - - isDec -
inTheNext(n,timeFrame) - - - -
inTheFuture(n,timeFrame) - - - -
- - - - -
isTime(ms) - - - -
- - - - -
inDay/s(Date) - - - -
inMonth/s(Date) - - - -
inYear/s(Date) - - - -

Installation / Imports

$ pnpm i match-iz
// ESM
import { match, when, otherwise, ...core lib } from 'match-iz'
import { isAM, isPM, ...date pattern-helpers } from 'match-iz/dates'
import { isTime, ...UTC date pattern-helpers } from 'match-iz/dates/utc'

// CJS
const { match, when, otherwise, ...core lib } = require('match-iz')
const { isAM, isPM, ...date pattern-helpers } = require('match-iz/dates')
const { isTime, ...UTC date pattern-helpers } = require('match-iz/dates/utc')

Browser/UMD:

<script src="https://unpkg.com/match-iz/dist/match-iz.browser.js"></script>
<script>
  const { match, when, otherwise, ...core lib } = matchiz
  const { isAM, isPM, ...date pattern-helpers } = matchiz
  const { isTime, ...UTC date pattern-helpers } = matchiz.utc
</script>