unum-cloud / usearch

Fast Open-Source Search & Clustering engine × for Vectors & 🔜 Strings × in C++, C, Python, JavaScript, Rust, Java, Objective-C, Swift, C#, GoLang, and Wolfram 🔍
https://unum-cloud.github.io/usearch/
Apache License 2.0
2.28k stars 143 forks source link

Docs: Update JavaScript code example #478

Closed abetomo closed 3 months ago

abetomo commented 3 months ago

1. Add require('node:assert')

Fix the following error:

ReferenceError: assert is not defined

2. Change metric to l2sq

Fix the following error:

AssertionError [ERR_ASSERTION]: Expected values to be loosely deep-equal:

Float32Array(1) [
  -0.00017893314361572266
]

should loosely deep-equal

Float32Array(1) [
  0
]

Reference:. https://github.com/unum-cloud/usearch/blob/242be104de770c12ed1fc938215530b944000b42/javascript/usearch.test.js#L49-L61