Js数组查找工具函数——ShapeFilter

Js工具库之Shape-filter
类似效果就像Mybatis-plus里的QueryWrapper
Github:github.com/ame-yu/shape-filter

主要目的

简化对象数组的查询
Object based array filter

Install

npm i shape-filter

QuickStart

import sf from "shape-filter"

let arr = [
    {id:1, name:"Jackel", email:"[email protected]"},
    {id:2, name:"Mira", email:"[email protected]"},
    {id:3, name:"Ela", email:"[email protected]"},
    //...
]

let list = sf(arr)
//查询所有gmail邮箱的用户 Get user list that using gmail
list.match({email:"@gmail.com"})//[{id:3, name:"ela",...
//精确搜索 Accurate search
list.match({name:"ira",email:"@gmail.com"})//[]
list.match({name:"blue com"})//[{id:2, name:"Mira"...
//结合搜索 Combine search
sf(arr,{combine:["name","email"]}).match("blue")//[{id:2, name:"Mira"...
//如果不定义结合的字段将默认结合所有数字和字符串 If you not define combine field,Default will combine all number and string
list.match("jackel")//[{id:1, name:"Jackel"...

限制 limit

过滤对象必须是个对象数组
source must be a object array

使用场景

大量数据离线查找
Deal with a massive of data, quick search.

默认配置

大小写敏感 开
多单词查询逻辑 与
参数对象属性逻辑 与

预计开发功能

有什么需求请留个言或Issue,如果已有类似的库请告知
If you have any suggestions please leave a issue.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章