cry-search 1.0.3 → 1.0.4
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/CLAUDE.md +6 -0
- package/dist/index.cjs +2 -0
- package/dist/index.js +2 -0
- package/dist/string.cjs +2 -0
- package/dist/string.js +2 -0
- package/dist/utils/preprocessString.d.ts +6 -2
- package/dist/utils/preprocessString.d.ts.map +1 -1
- package/package.json +1 -1
package/CLAUDE.md
CHANGED
|
@@ -62,6 +62,12 @@ The numeric implementation uses a global token registry (`src/utils/tokenRegistr
|
|
|
62
62
|
4. eg "abc 0.3x" -> "abc .3x"
|
|
63
63
|
5. eg "007" -> "7"
|
|
64
64
|
6. multiple periods stay as-is: "1.2.3" -> "1.2.3"
|
|
65
|
+
1b. strip decimal period from pure standalone numbers (digits on both sides of period)
|
|
66
|
+
1. eg "abc 11.22 x" -> "abc 1122 x"
|
|
67
|
+
2. eg "abc 12,3 x" -> "abc 123 x" (after comma->period, then strip)
|
|
68
|
+
3. mixed tokens with letters are NOT stripped: ".5kg" -> ".5kg", "12.3x" -> "12.3x"
|
|
69
|
+
4. standalone decimals without leading digits are NOT stripped: ".3" -> ".3"
|
|
70
|
+
5. multiple periods are NOT stripped: "1.2.3" -> "1.2.3"
|
|
65
71
|
2. we remove spaces in pattern digits - digits
|
|
66
72
|
1. eg. "12 - 25" => "12-25"
|
|
67
73
|
3. we insert spaces between starting letters and digits (only at letter-to-digit boundaries)
|
package/dist/index.cjs
CHANGED
|
@@ -199,6 +199,7 @@ var RE_LEADING_ZEROS = /\b0+(\d)/g;
|
|
|
199
199
|
var RE_DECIMAL_COMMA = /(\d),(\d)/g;
|
|
200
200
|
var RE_STANDALONE_COMMA = /(?<!\d),(\d)/g;
|
|
201
201
|
var RE_ZERO_DECIMAL = /\b0+\./g;
|
|
202
|
+
var RE_PURE_DECIMAL = /(?<![a-zA-Z\d.])(\d+)\.(\d+)(?![a-zA-Z.\d])/g;
|
|
202
203
|
var RE_DIGIT_DASH = /(\d)\s*-\s*(\d)/g;
|
|
203
204
|
var RE_LETTERS_DIGITS = /(^|\s)([a-zA-Z]+)(\d+)(?=\s|$)/g;
|
|
204
205
|
var RE_DIGITS_LETTERS = /(^|\s)(\d+)([a-zA-Z]+)(?=\s|$)/g;
|
|
@@ -208,6 +209,7 @@ function preprocessString(input) {
|
|
|
208
209
|
result = result.replace(RE_DECIMAL_COMMA, "$1.$2");
|
|
209
210
|
result = result.replace(RE_STANDALONE_COMMA, ".$1");
|
|
210
211
|
result = result.replace(RE_ZERO_DECIMAL, ".");
|
|
212
|
+
result = result.replace(RE_PURE_DECIMAL, "$1$2");
|
|
211
213
|
result = result.replace(RE_DIGIT_DASH, "$1-$2");
|
|
212
214
|
result = result.replace(RE_LETTERS_DIGITS, "$1$2 $3");
|
|
213
215
|
result = result.replace(RE_DIGITS_LETTERS, "$1$2 $3");
|
package/dist/index.js
CHANGED
|
@@ -114,6 +114,7 @@ var RE_LEADING_ZEROS = /\b0+(\d)/g;
|
|
|
114
114
|
var RE_DECIMAL_COMMA = /(\d),(\d)/g;
|
|
115
115
|
var RE_STANDALONE_COMMA = /(?<!\d),(\d)/g;
|
|
116
116
|
var RE_ZERO_DECIMAL = /\b0+\./g;
|
|
117
|
+
var RE_PURE_DECIMAL = /(?<![a-zA-Z\d.])(\d+)\.(\d+)(?![a-zA-Z.\d])/g;
|
|
117
118
|
var RE_DIGIT_DASH = /(\d)\s*-\s*(\d)/g;
|
|
118
119
|
var RE_LETTERS_DIGITS = /(^|\s)([a-zA-Z]+)(\d+)(?=\s|$)/g;
|
|
119
120
|
var RE_DIGITS_LETTERS = /(^|\s)(\d+)([a-zA-Z]+)(?=\s|$)/g;
|
|
@@ -123,6 +124,7 @@ function preprocessString(input) {
|
|
|
123
124
|
result = result.replace(RE_DECIMAL_COMMA, "$1.$2");
|
|
124
125
|
result = result.replace(RE_STANDALONE_COMMA, ".$1");
|
|
125
126
|
result = result.replace(RE_ZERO_DECIMAL, ".");
|
|
127
|
+
result = result.replace(RE_PURE_DECIMAL, "$1$2");
|
|
126
128
|
result = result.replace(RE_DIGIT_DASH, "$1-$2");
|
|
127
129
|
result = result.replace(RE_LETTERS_DIGITS, "$1$2 $3");
|
|
128
130
|
result = result.replace(RE_DIGITS_LETTERS, "$1$2 $3");
|
package/dist/string.cjs
CHANGED
|
@@ -167,6 +167,7 @@ var RE_LEADING_ZEROS = /\b0+(\d)/g;
|
|
|
167
167
|
var RE_DECIMAL_COMMA = /(\d),(\d)/g;
|
|
168
168
|
var RE_STANDALONE_COMMA = /(?<!\d),(\d)/g;
|
|
169
169
|
var RE_ZERO_DECIMAL = /\b0+\./g;
|
|
170
|
+
var RE_PURE_DECIMAL = /(?<![a-zA-Z\d.])(\d+)\.(\d+)(?![a-zA-Z.\d])/g;
|
|
170
171
|
var RE_DIGIT_DASH = /(\d)\s*-\s*(\d)/g;
|
|
171
172
|
var RE_LETTERS_DIGITS = /(^|\s)([a-zA-Z]+)(\d+)(?=\s|$)/g;
|
|
172
173
|
var RE_DIGITS_LETTERS = /(^|\s)(\d+)([a-zA-Z]+)(?=\s|$)/g;
|
|
@@ -176,6 +177,7 @@ function preprocessString(input) {
|
|
|
176
177
|
result = result.replace(RE_DECIMAL_COMMA, "$1.$2");
|
|
177
178
|
result = result.replace(RE_STANDALONE_COMMA, ".$1");
|
|
178
179
|
result = result.replace(RE_ZERO_DECIMAL, ".");
|
|
180
|
+
result = result.replace(RE_PURE_DECIMAL, "$1$2");
|
|
179
181
|
result = result.replace(RE_DIGIT_DASH, "$1-$2");
|
|
180
182
|
result = result.replace(RE_LETTERS_DIGITS, "$1$2 $3");
|
|
181
183
|
result = result.replace(RE_DIGITS_LETTERS, "$1$2 $3");
|
package/dist/string.js
CHANGED
|
@@ -97,6 +97,7 @@ var RE_LEADING_ZEROS = /\b0+(\d)/g;
|
|
|
97
97
|
var RE_DECIMAL_COMMA = /(\d),(\d)/g;
|
|
98
98
|
var RE_STANDALONE_COMMA = /(?<!\d),(\d)/g;
|
|
99
99
|
var RE_ZERO_DECIMAL = /\b0+\./g;
|
|
100
|
+
var RE_PURE_DECIMAL = /(?<![a-zA-Z\d.])(\d+)\.(\d+)(?![a-zA-Z.\d])/g;
|
|
100
101
|
var RE_DIGIT_DASH = /(\d)\s*-\s*(\d)/g;
|
|
101
102
|
var RE_LETTERS_DIGITS = /(^|\s)([a-zA-Z]+)(\d+)(?=\s|$)/g;
|
|
102
103
|
var RE_DIGITS_LETTERS = /(^|\s)(\d+)([a-zA-Z]+)(?=\s|$)/g;
|
|
@@ -106,6 +107,7 @@ function preprocessString(input) {
|
|
|
106
107
|
result = result.replace(RE_DECIMAL_COMMA, "$1.$2");
|
|
107
108
|
result = result.replace(RE_STANDALONE_COMMA, ".$1");
|
|
108
109
|
result = result.replace(RE_ZERO_DECIMAL, ".");
|
|
110
|
+
result = result.replace(RE_PURE_DECIMAL, "$1$2");
|
|
109
111
|
result = result.replace(RE_DIGIT_DASH, "$1-$2");
|
|
110
112
|
result = result.replace(RE_LETTERS_DIGITS, "$1$2 $3");
|
|
111
113
|
result = result.replace(RE_DIGITS_LETTERS, "$1$2 $3");
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Preprocesses a string for search by normalizing number formats and splitting mixed alphanumeric tokens.
|
|
3
3
|
*
|
|
4
4
|
* Processing steps:
|
|
5
|
-
* 1. Replaces decimal commas with periods (e.g., "12,3" → "12.3")
|
|
6
|
-
* 2.
|
|
5
|
+
* 1. Replaces decimal commas with periods, drops leading zeros (e.g., "12,3" → "12.3", "007" → "7")
|
|
6
|
+
* 2. Strips decimal period from pure standalone numbers (e.g., "11.22" → "1122", ".3" → "3")
|
|
7
|
+
* Does NOT strip from mixed tokens (".5kg") or multi-period tokens ("1.2.3")
|
|
7
8
|
* 3. Removes spaces in digit-dash-digit patterns (e.g., "12 - 25" → "12-25")
|
|
8
9
|
* 4. Inserts spaces at letter-to-digit boundaries (e.g., "SI123" → "SI 123", "123SI" → "123 SI")
|
|
9
10
|
*
|
|
@@ -15,6 +16,9 @@
|
|
|
15
16
|
* preprocessString('SI123 Čokolada 0,5kg')
|
|
16
17
|
* // Returns: 'SI 123 Čokolada .5kg'
|
|
17
18
|
*
|
|
19
|
+
* preprocessString('abc 11.22 def')
|
|
20
|
+
* // Returns: 'abc 1122 def'
|
|
21
|
+
*
|
|
18
22
|
* preprocessString('007')
|
|
19
23
|
* // Returns: '7'
|
|
20
24
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preprocessString.d.ts","sourceRoot":"","sources":["../../src/utils/preprocessString.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"preprocessString.d.ts","sourceRoot":"","sources":["../../src/utils/preprocessString.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAyBtD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cry-search",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "A fast, memory-efficient search library for large datasets with support for tokenized matching, linked collections, and per-field match modes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|