patternMatching
- node.js, browserify
npm install pattern-matching --save
- requirejs
bower install pattern-matching --save
Небольшая библиотека придуманная для верификации аргументов переданных в функцию.
Умеет различать следующие типы:
-
string
-'blah'
,''
-
notEmptyString
-'blah'
-
number
-1
,0.1
-
integer
-1
-
boolean
-true
,false
-
object
-{}
,new Object()
-
notEmptyObject
-{ field: 1 }
-
date
-new Date()
-
regExp
-new RegExp()
-
error
-new Error()
-
array
-[]
,new Array()
-
function
-new Function()
,function() {}
-
primitive
-null
,1
,'blah'
,false
,undefined
,Infinity
-
notEmpty
-[1]
,{ test: 1 }
,'1'
,1
,true
,Infinity
-
*
- any value
Использование:
var patternMatching = ; console; console; console;
Добавление своего правила:
patternMatching { return value === value;}; console;