Skip to content

Commit 1c1ff5c

Browse files
committed
Fix default object changing
1 parent fba6161 commit 1c1ff5c

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

lib/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const RANGE_REGEXP = /^[^-\d]*(-?\d+(\.\d+)?)?[^-\d]*-[^-\d]*(-?\d+(\.\d+)?)?[^-
1212
const TOKENIZER = new RegExp(` *(${NEGATED_PREFIX})? *(\\${GROUP_START})| *(${NEGATED_PREFIX} +)?(?:((?:\\\\.|[^ ${GROUP_START}${GROUP_END}\\\\${REGEX_CHAR}${RANGE_CHAR}${TOKEN_SEPARATOR}])+) *([${REGEX_CHAR}${RANGE_CHAR}]?${TOKEN_SEPARATOR}))? *("((?:\\\\.|[^"\\\\])+)"|(?:\\\\.|[^ ${GROUP_START}${GROUP_END}\\\\])+)? *(and|or|\\${GROUP_END}|$)`, 'g')
1313
const TOKEN = { GROUP_NEGATED: 1, GROUP_START: 2, NEGATED: 3, KEY: 4, TYPE: 5, VALUE: 6, QUOTED_VALUE: 7, OPERATOR: 8 }
1414
const UNKNOWN = -1
15-
const EMPTY_OBJ: any = {}
1615
const EMPTY_STR = ''
1716
const STRING = 'string'
1817
const NUMBER = 'number'
@@ -121,7 +120,7 @@ class SearchEngine {
121120
* @param options - Search options
122121
* @returns Array of matched objects
123122
*/
124-
static search<T extends Record<string, any>>(objList: T[], queryStr: string, options: SearchOptions = EMPTY_OBJ): T[] {
123+
static search<T extends Record<string, any>>(objList: T[], queryStr: string, options: SearchOptions = {}): T[] {
125124
if (!objList) { return [] }
126125
if (!queryStr || queryStr.trim() === EMPTY_STR) { return objList.slice() }
127126
options.allowNumericString === void 0 && (options.allowNumericString = true)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ecromaneli/search-engine",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"description": "A powerful object search engine with advanced query syntax",
55
"main": "dist/npm/index.min.js",
66
"files": [ "dist/npm/index.min.*", "dist/npm/index.d.*", "LICENSE" ],

0 commit comments

Comments
 (0)