Prevent match API from the result of null.
$ npm i safe-match
- match
- init
- reset
var safeMatch = require('safe-match').match
safeMatch('foo', /bar/) // => 0
var safeMatchInit = require('safe-match').init
var safeMatchReset = require('safe-match').reset
safeMatchInit()
'foo'.safeMatch(/bar/) // => 0
safeMatchReset()
'foo'.safeMatch(/bar/) // => null
safeMatchInit({
name: 'match'
})
'foo'.match(/bar/) // => 0
safeMatchReset()
'foo'.match(/bar/) // => null
safeMatchInit({
noConflict: true
})
'foo'.safeMatch(/bar/, true) // => 0
'foo'.safeMatch(/bar/) // => null
safeMatchReset()
'foo'.match(/bar/, true) // => null