Socket
Book a DemoInstallSign in
Socket

array-fuzzy-match

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-fuzzy-match

array fuzzy match

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
352
-10.66%
Maintainers
1
Weekly downloads
 
Created
Source

array fuzzy match

npm i array-fuzzy-match
import isMatch from 'array-fuzzy-match'

test('should return true if matches words', t => {
  const arr = ['zhong', 'guo', 'zhong', 'che']
  t.true(isMatch(arr, 'zhong'))
  t.true(isMatch(arr, 'guo'))
  t.true(isMatch(arr, 'zhongg'))
  t.true(isMatch(arr, 'guozhong'))
})

test('should return true if matches words case-insensitive', t => {
  const arr = ['zhong', 'guo', 'zhong', 'che']
  t.true(isMatch(arr, 'Zhong'))
  t.true(isMatch(arr, 'GUO'))
  t.true(isMatch(arr, 'ZHONGG'))
  t.true(isMatch(arr, 'guoZhong'))
})

test('should matches first letter of each word from beginning', t => {
  const arr = ['zhong', 'guo', 'zhong', 'che']
  t.true(isMatch(arr, 'ZG'))
  t.true(isMatch(arr, 'ZGZC'))
  t.false(isMatch(arr, 'GZ'))
})

test('should match from the beginning', t => {
  const arr = ['zhong', 'guo', 'zhong', 'che']
  const config = { wordFromStart: true }
  t.true(isMatch(arr, 'zhong', config))
  t.false(isMatch(arr, 'guo', config))
  t.true(isMatch(arr, 'zhongg', config))
  t.false(isMatch(arr, 'guozhong', config))
})

test('should matches first letter of each word', t => {
  const arr = ['zhong', 'guo', 'zhong', 'che']
  const config = { letterFromStart: false }
  t.true(isMatch(arr, 'ZG', config))
  t.true(isMatch(arr, 'ZGZC', config))
  t.true(isMatch(arr, 'GZ', config))
})

Keywords

fuzzy

FAQs

Package last updated on 02 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.