Skip to content

Dafrok/safe-match

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

safe-match

Description

Prevent match API from the result of null.

Install

$ npm i safe-match

API

  • match
  • init
  • reset

Usage

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

About

Prevent match API from the result of null

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages