@yoch/frozenminisearch 1.1.0 → 1.2.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.
@@ -113,7 +113,7 @@ type SearchOptionsWithDefaults = SearchOptions & {
113
113
  bm25: BM25Params;
114
114
  };
115
115
  /**
116
- * Configuration options passed to the {@link MiniSearch} constructor.
116
+ * Configuration options compatible with the MiniSearch constructor.
117
117
  *
118
118
  * @typeParam T The type of documents being indexed.
119
119
  */
@@ -134,7 +134,7 @@ type Options<T = any> = {
134
134
  processTerm?: (term: string, fieldName?: string) => string | string[] | null | undefined | false;
135
135
  /** Function called to log messages from the library. */
136
136
  logger?: (level: LogLevel, message: string, code?: string) => void;
137
- /** Auto-vacuum behaviour after {@link MiniSearch.discard}; defaults to `true`. */
137
+ /** Auto-vacuum behaviour after MiniSearch `discard`; defaults to `true`. */
138
138
  autoVacuum?: boolean | AutoVacuumOptions;
139
139
  /** Default search options. */
140
140
  searchOptions?: SearchOptions;
@@ -158,6 +158,20 @@ type OptionsWithDefaults<T = any> = Options<T> & {
158
158
  searchOptions: SearchOptionsWithDefaults;
159
159
  autoSuggestOptions: SearchOptions;
160
160
  };
161
+ /** Compression codec selection for frozen binary snapshots. */
162
+ type BinaryCompression = 'auto' | 'raw' | 'zstd' | 'zlib';
163
+ /** Options for `saveBinarySync()` / `saveBinaryAsync()`. */
164
+ type SaveBinaryOptions = {
165
+ /**
166
+ * Compression codec for the payload.
167
+ * - `auto`: one pass; payloads under 64 B stay raw; otherwise zstd when available
168
+ * (else zlib on Node < 22.15), kept only when strictly smaller than raw
169
+ * - `raw`: never compress
170
+ * - `zstd`: always zstd-compress, even when larger than raw; requires Node 22.15+ to write
171
+ * - `zlib`: always deflate, even when larger than raw; readable on Node 20+
172
+ */
173
+ compression?: BinaryCompression;
174
+ };
161
175
  /**
162
176
  * A search-completion suggestion.
163
177
  */
@@ -586,6 +600,7 @@ declare class FrozenMiniSearch<T = any> {
586
600
  private readonly _fieldTermFlyweight;
587
601
  private readonly _aggregateContext;
588
602
  private readonly _queryEngineParams;
603
+ private readonly _hasStoredFields;
589
604
  constructor(params: FrozenAssembleParams<T>);
590
605
  static readonly wildcard: typeof WILDCARD_QUERY;
591
606
  get documentCount(): number;
@@ -596,12 +611,12 @@ declare class FrozenMiniSearch<T = any> {
596
611
  search(query: Query, searchOptions?: SearchOptions): SearchResult[];
597
612
  autoSuggest(queryString: string, options?: SearchOptions): Suggestion[];
598
613
  /** Serialize this index as a frozen binary snapshot (synchronous). */
599
- saveBinarySync(): Buffer;
600
- /** Non-blocking zstd compression; same output as {@link saveBinarySync}. */
601
- saveBinaryAsync(): Promise<Buffer>;
614
+ saveBinarySync(saveOptions?: SaveBinaryOptions): Buffer;
615
+ /** Non-blocking snapshot serialization with the selected compression codec. */
616
+ saveBinaryAsync(saveOptions?: SaveBinaryOptions): Promise<Buffer>;
602
617
  /** Load a frozen binary snapshot. */
603
618
  static loadBinarySync<T>(buffer: Buffer, options?: Options<T>): FrozenMiniSearch<T>;
604
- /** Load a frozen binary snapshot with streaming zstd decompression (bounded memory). */
619
+ /** Load a frozen binary snapshot with streaming decompression when needed (bounded memory). */
605
620
  static loadBinaryAsync<T>(buffer: Buffer, options?: Options<T>): Promise<FrozenMiniSearch<T>>;
606
621
  private static fromBinarySnapshot;
607
622
  /** Build a read-only index in one pass from documents. */
@@ -643,4 +658,4 @@ declare class FrozenMiniSearch<T = any> {
643
658
  }
644
659
 
645
660
  export { AND, AND_NOT, FrozenIndexBuilder, FrozenMiniSearch, OR, assembleFrozen, buildFrozenFromDocuments, createFrozenIndexBuilder, FrozenMiniSearch as default, freezeFrozenIndexBuilder, frozenMemoryBreakdown };
646
- export type { BM25Params, CombinationOperator, FrozenAssembleParams, FrozenIndexBuilderHints, FrozenMemoryBreakdown, LogLevel, LowercaseCombinationOperator, MatchInfo, MiniSearchSnapshot, Options, Query, QueryCombination, SearchOptions, SearchResult, SerializedIndexEntry, Suggestion, Wildcard };
661
+ export type { BM25Params, BinaryCompression, CombinationOperator, FrozenAssembleParams, FrozenIndexBuilderHints, FrozenMemoryBreakdown, LogLevel, LowercaseCombinationOperator, MatchInfo, MiniSearchSnapshot, Options, Query, QueryCombination, SaveBinaryOptions, SearchOptions, SearchResult, SerializedIndexEntry, Suggestion, Wildcard };