@marcoappio/marco-config 8.0.0 → 8.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,3 @@
1
+ /** An empty result means there are no searchable words, not an unfiltered search. */
1
2
  export declare const processSearchTerm: (term: string) => string[];
2
3
  //# sourceMappingURL=processSearchTerm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"processSearchTerm.d.ts","sourceRoot":"","sources":["../../../../src/utils/threads/processSearchTerm/processSearchTerm.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB,SAAU,MAAM,KAAG,MAAM,EAkBtD,CAAA"}
1
+ {"version":3,"file":"processSearchTerm.d.ts","sourceRoot":"","sources":["../../../../src/utils/threads/processSearchTerm/processSearchTerm.ts"],"names":[],"mappings":"AAOA,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,SAAU,MAAM,KAAG,MAAM,EAetD,CAAA"}
@@ -1,17 +1,18 @@
1
1
  import { stemmer } from '@orama/stemmers/english';
2
2
  import { stopwords } from '@orama/stopwords/english';
3
3
  const STOP_WORDS_SET = new Set(stopwords);
4
+ const MIN_WORD_LENGTH = 3;
5
+ const MAX_WORD_LENGTH = 30;
6
+ /** An empty result means there are no searchable words, not an unfiltered search. */
4
7
  export const processSearchTerm = (term) => {
5
- const sanitizedTerm = term.trim().toLowerCase();
6
- const tokens = sanitizedTerm.split(/\s+/).filter(Boolean);
8
+ const tokens = term.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? [];
7
9
  const wordSet = new Set();
8
10
  for (const token of tokens) {
9
- if (STOP_WORDS_SET.has(token)) {
10
- continue;
11
- }
12
- const stemmed = stemmer(token);
13
- if (stemmed.length > 0) {
14
- wordSet.add(stemmed);
11
+ if (token.length >= MIN_WORD_LENGTH && token.length < MAX_WORD_LENGTH && !STOP_WORDS_SET.has(token)) {
12
+ const stemmed = stemmer(token);
13
+ if (stemmed.length >= MIN_WORD_LENGTH && stemmed.length < MAX_WORD_LENGTH) {
14
+ wordSet.add(stemmed);
15
+ }
15
16
  }
16
17
  }
17
18
  return Array.from(wordSet);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marcoappio/marco-config",
3
- "version": "8.0.0",
3
+ "version": "8.0.1",
4
4
  "author": "team@marcoapp.io",
5
5
  "main": "dist/index.js",
6
6
  "repository": "git@github.com:marcoappio/marco-config.git",