Skip to content
Conan Theobald edited this page Apr 26, 2022 · 14 revisions

match-iz 🔥 docs

Scroll down for:

Check the sidebar for everything else.

Pattern-helper Cheatsheets

Follow the links in the headers for example usage.

Core Pattern-helpers

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) - - - - isPojo - includedIn(...)
- - - - - isRegExp - hasOwn(...)
- - - - - isString - -
- - - - - instanceOf - -

Date Pattern-helpers

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) - - - -

Installation / Imports

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

// CJS
const { match, when, otherwise, ...core lib } = require('match-iz')
const { isAM, isSat, ...date pattern-helpers } = require('match-iz/dates')
const { isAM, isSat, ...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, isSat, ...date pattern-helpers } = matchiz
  const { isAM, isSat, ...UTC date pattern-helpers } = matchiz.utc
</script>
Clone this wiki locally