xushengfeng / match

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

match

简介(introduction)

简单的模式匹配

安装(installation)

npm i ppmatch
import * as match from ppmatch

const arr = [1, 2, 3, 4, '5']
console.log(
    arr.map(
        a => match(a,
            (v = 1) => 'one',
            (v = 2) => 'two',
            (v = 3) => 'three',
            _ => `other${_}`
        )
    )
)
// ['one', 'two', 'three', 'other4', 'other5']

About

License:Apache License 2.0


Languages

Language:TypeScript 52.0%Language:HTML 29.1%Language:JavaScript 18.9%