hqcmt
v1.0.3
Published
A JavaScript package for handling datasets with indexing and retrieval functionalities.
Downloads
3
Maintainers
Readme
hqcmt
HQCMT is a JavaScript library designed for efficient dataset indexing and retrieval. It allows users to create an index based on a specified key or default values, enabling quick access to data.
Installation
To install the package, use npm:
npm install hqcmtUsage
Importing the Library
You can import the library in your TypeScript or JavaScript project as follows:
import { HQCMT } from 'hqcmt';Creating an Instance
To create an instance of the HQCMT class, simply do:
const hqcmt = new HQCMT();Adding a Dataset
You can add a dataset in JSON or object format. If no key is provided, the package will use a default index (like the 2nd or 3rd element) to create indexing.
// Ingest data (CSV file path, array of objects, or object/dict)
await hqcmt.ingestData(data, { dimensions: 15, key: 'id' });
Retrieving Data
To retrieve data by passing the index key, use the retrieveData method:
// Retrieve data by key
const results = hqcmt.retrieveData({ key: '12345', exactMatch: true });
console.log(results);API
ingestData(data, options)
data: string (CSV file path), array, object, or Mapoptions:dimensions(optional): number of dimensionskey(optional): key for hashmap grouping
retrieveData(options)
options:key: key to retrieve dataexactMatch(optional, defaulttrue): exact or partial match
Default Indexing
If no key is specified, the package will create an index for each element of the object:
hqcmt.addDataset(dataset); // Default indexing
const defaultResult = hqcmt.retrieveData(1); // Retrieves the first object
console.log(defaultResult); // Output: { id: 1, name: 'Alice', age: 30 }License
This project is licensed under the MIT License. See the LICENSE file for details.
