(options = {})
| 93 | } |
| 94 | |
| 95 | async init(options = {}) { |
| 96 | if (options.dimension) { |
| 97 | this.dimension = options.dimension; |
| 98 | } |
| 99 | if (!this.dimension || this.dimension <= 0) { |
| 100 | throw new Error('Vector dimension must be provided.'); |
| 101 | } |
| 102 | this.metric = normalizeMetric(options.metric || this.metric); |
| 103 | this.normalizeVectors = options.normalize ?? this.normalizeVectors ?? (this.metric === 'cosine'); |
| 104 | if (!this.vectors || this.vectors.length !== this.capacity * this.dimension) { |
| 105 | this.vectors = new Float32Array(this.capacity * this.dimension); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | prepareItems(items) { |
| 110 | const prepared = []; |
nothing calls this directly
no test coverage detected