@orama/orama
Advanced tools
Comparing version 1.0.0-beta.1 to 1.0.0-beta.2
@@ -1,6 +0,6 @@ | ||
import { Document, Schema, SimpleComponents } from '../types.js'; | ||
import { Document, ElapsedTime, Schema, SimpleComponents } from '../types.js'; | ||
export { getDocumentProperties } from '../utils.js'; | ||
export declare function formatElapsedTime(n: bigint): bigint; | ||
export declare function formatElapsedTime(n: bigint): ElapsedTime; | ||
export declare function getDocumentIndexId(doc: Document): string; | ||
export declare function validateSchema<S extends Schema = Schema>(doc: Document, schema: S): boolean; | ||
export declare function getDefaultComponents(): SimpleComponents; |
import { createError } from '../errors.js'; | ||
import { getDocumentProperties, uniqueId } from '../utils.js'; | ||
import { getDocumentProperties, uniqueId, formatNanoseconds } from '../utils.js'; | ||
export { getDocumentProperties } from '../utils.js'; | ||
export function formatElapsedTime(n) { | ||
return n; | ||
return { | ||
raw: Number(n), | ||
formatted: formatNanoseconds(n) | ||
}; | ||
} | ||
@@ -7,0 +10,0 @@ export function getDocumentIndexId(doc) { |
@@ -173,2 +173,6 @@ export type Nullable<T> = T | null; | ||
}; | ||
export type ElapsedTime = { | ||
raw: number; | ||
formatted: string; | ||
}; | ||
export type Results = { | ||
@@ -186,3 +190,3 @@ /** | ||
*/ | ||
elapsed: bigint | string; | ||
elapsed: ElapsedTime; | ||
/** | ||
@@ -240,3 +244,3 @@ * The facets results. | ||
getDocumentProperties(doc: Document, paths: string[]): SyncOrAsyncValue<Record<string, string | number | boolean>>; | ||
formatElapsedTime(number: bigint): SyncOrAsyncValue<bigint> | SyncOrAsyncValue<string>; | ||
formatElapsedTime(number: bigint): SyncOrAsyncValue<number | string | object | ElapsedTime>; | ||
} | ||
@@ -243,0 +247,0 @@ export interface SimpleOrArrayCallbackComponents { |
{ | ||
"name": "@orama/orama", | ||
"version": "1.0.0-beta.1", | ||
"version": "1.0.0-beta.2", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "Next generation full-text search engine, written in TypeScript", |
@@ -105,3 +105,6 @@ ![Orama. Search, everywhere.](https://github.com/oramasearch/orama/blob/main/misc/oramasearch.gif?raw=true) | ||
{ | ||
elapsed: 184541n, // Elapsed time in nanoseconds | ||
elapsed: { | ||
raw: 184541, | ||
formatted: '184μs', | ||
}, | ||
hits: [ | ||
@@ -142,3 +145,6 @@ { | ||
{ | ||
elapsed: 172166n, | ||
elapsed: { | ||
raw: 172166, | ||
formatted: '172μs', | ||
}, | ||
hits: [ | ||
@@ -164,17 +170,2 @@ { | ||
Orama exposes a built-in `formatNanoseconds` function to format the elapsed time | ||
in a human-readable format: | ||
```js | ||
import { formatNanoseconds } from '@orama/orama' | ||
const searchResult = await search(db, { | ||
term: 'if', | ||
properties: '*', | ||
}) | ||
console.log(`Search took ${formatNanoseconds(searchResult.elapsed)}`) | ||
// Search took 164μs | ||
``` | ||
### Using with CommonJS | ||
@@ -181,0 +172,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1616538
64354
297