@marcoappio/marco-config 2.0.466 → 2.0.468
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.
- package/dist/utils/threads/index.d.ts +4 -0
- package/dist/utils/threads/index.d.ts.map +1 -0
- package/dist/utils/threads/index.js +4 -0
- package/dist/utils/threads/processSearchTerm/index.d.ts +2 -0
- package/dist/utils/threads/processSearchTerm/index.d.ts.map +1 -0
- package/dist/utils/threads/processSearchTerm/index.js +1 -0
- package/dist/utils/threads/processSearchTerm/processSearchTerm.d.ts +2 -0
- package/dist/utils/threads/processSearchTerm/processSearchTerm.d.ts.map +1 -0
- package/dist/utils/threads/processSearchTerm/processSearchTerm.js +18 -0
- package/dist/utils/threads/processSearchTerm/processSearchTerm.test.d.ts +2 -0
- package/dist/utils/threads/processSearchTerm/processSearchTerm.test.d.ts.map +1 -0
- package/dist/utils/threads/processSearchTerm/processSearchTerm.test.js +38 -0
- package/dist/zero/index.d.ts +964 -0
- package/dist/zero/index.d.ts.map +1 -1
- package/dist/zero/index.js +2 -1
- package/dist/zero/queries/getThreadList.d.ts +968 -0
- package/dist/zero/queries/getThreadList.d.ts.map +1 -0
- package/dist/zero/queries/getThreadList.js +59 -0
- package/dist/zero/queries/getThreads.d.ts.map +1 -1
- package/dist/zero/queries/getThreads.js +2 -2
- package/dist/zero/queries/index.d.ts +1 -0
- package/dist/zero/queries/index.d.ts.map +1 -1
- package/dist/zero/queries/index.js +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/threads/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;CAExB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/threads/processSearchTerm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { processSearchTerm } from './processSearchTerm';
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { stemmer } from '@orama/stemmers/english';
|
|
2
|
+
import { stopwords } from '@orama/stopwords/english';
|
|
3
|
+
const STOP_WORDS_SET = new Set(stopwords);
|
|
4
|
+
export const processSearchTerm = (term) => {
|
|
5
|
+
const sanitizedTerm = term.trim().toLowerCase();
|
|
6
|
+
const tokens = sanitizedTerm.split(/\s+/).filter(Boolean);
|
|
7
|
+
const wordSet = new Set();
|
|
8
|
+
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);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return Array.from(wordSet);
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processSearchTerm.test.d.ts","sourceRoot":"","sources":["../../../../src/utils/threads/processSearchTerm/processSearchTerm.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
import { processSearchTerm } from './processSearchTerm';
|
|
3
|
+
describe('processSearchTerm', () => {
|
|
4
|
+
const testCases = [
|
|
5
|
+
{ description: 'stems word to root form', expected: ['run'], input: 'running' },
|
|
6
|
+
{ description: 'stems -ing suffix', expected: ['jump'], input: 'jumping' },
|
|
7
|
+
{ description: 'stems plural', expected: ['cat'], input: 'cats' },
|
|
8
|
+
{ description: 'removes single stopword', expected: [], input: 'the' },
|
|
9
|
+
{ description: 'removes article stopword', expected: [], input: 'an' },
|
|
10
|
+
{ description: 'removes verb stopword', expected: [], input: 'is' },
|
|
11
|
+
{ description: 'removes stopwords from phrase', expected: ['quick', 'fox'], input: 'the quick fox' },
|
|
12
|
+
{ description: 'handles empty string', expected: [], input: '' },
|
|
13
|
+
{ description: 'handles whitespace only', expected: [], input: ' ' },
|
|
14
|
+
{ description: 'handles tabs and newlines', expected: [], input: '\t\n' },
|
|
15
|
+
{ description: 'returns empty for only stopwords', expected: [], input: 'the an' },
|
|
16
|
+
{ description: 'returns empty for multiple stopwords', expected: [], input: 'is are was were' },
|
|
17
|
+
{ description: 'deduplicates same-root words', expected: ['run'], input: 'run running runs' },
|
|
18
|
+
{ description: 'deduplicates stemmed variants', expected: ['happi'], input: 'happy happiness' },
|
|
19
|
+
{ description: 'normalizes uppercase', expected: ['hello'], input: 'HELLO' },
|
|
20
|
+
{ description: 'normalizes mixed case', expected: ['hello', 'world'], input: 'HeLLo WoRLd' },
|
|
21
|
+
{ description: 'handles extra spaces', expected: ['hello', 'world'], input: ' hello world ' },
|
|
22
|
+
{ description: 'handles mixed whitespace', expected: ['hello', 'world'], input: 'hello\t\nworld' },
|
|
23
|
+
{ description: 'preserves order of first occurrence', expected: ['world', 'hello'], input: 'world hello' },
|
|
24
|
+
{
|
|
25
|
+
description: 'handles mixed stopwords and content',
|
|
26
|
+
expected: ['meet', 'import'],
|
|
27
|
+
input: 'the meeting is important',
|
|
28
|
+
},
|
|
29
|
+
{ description: 'stems and filters mixed phrase', expected: ['import', 'messag'], input: 'an important message' },
|
|
30
|
+
{ description: 'passes through numbers unchanged', expected: ['123', 'test'], input: '123 test' },
|
|
31
|
+
{ description: 'passes through special characters unchanged', expected: ['@user', '#tag'], input: '@user #tag' },
|
|
32
|
+
];
|
|
33
|
+
for (const { input, expected, description } of testCases) {
|
|
34
|
+
it(`should ${description}`, () => {
|
|
35
|
+
expect(processSearchTerm(input)).toEqual(expected);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|