https://github.com/mybigday/react-native-hnswlib
Hnswlib binding for React Native (WIP)
https://github.com/mybigday/react-native-hnswlib
Last synced: 29 days ago
JSON representation
Hnswlib binding for React Native (WIP)
- Host: GitHub
- URL: https://github.com/mybigday/react-native-hnswlib
- Owner: mybigday
- License: mit
- Created: 2024-05-13T14:52:11.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-13T17:23:55.000Z (about 1 year ago)
- Last Synced: 2025-05-01T08:05:39.116Z (about 1 month ago)
- Language: C++
- Homepage:
- Size: 1.44 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# react-native-hnswlib
Hnswlib for React Native
## Installation
```sh
npm install react-native-hnswlib
```## Usage
```js
import { HierarchicalNSW } from 'react-native-hnswlib';const numDimensions = 8; // the length of data point vector that will be indexed.
const maxElements = 10; // the maximum number of data points.const index = new HierarchicalNSW('l2', numDimensions);
index.initIndex(maxElements);// inserting data points to index.
for (let i = 0; i < maxElements; i++) {
const point = new Array(numDimensions);
for (let j = 0; j < numDimensions; j++) point[j] = Math.random();
index.addPoint(point, i);
}// preparing query data points.
const query = new Array(numDimensions);
for (let j = 0; j < numDimensions; j++) query[j] = Math.random();// searching k-nearest neighbor data points.
const numNeighbors = 3;
const result = index.searchKnn(query, numNeighbors);
```## Contributing
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
## License
MIT
---
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
---
Built and maintained by BRICKS.