Skip to content

Commit

Permalink
docs(home): better features section
Browse files Browse the repository at this point in the history
  • Loading branch information
ChronicStone committed Jul 19, 2024
1 parent 711a7fd commit 6d1cafc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
24 changes: 18 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,30 @@ hero:
link: https://github.com/ChronicStone/array-ql

features:
- title: Type-Safe Querying
details: Enjoy 100% type-safe query configurations with keys inferred from your dataset, enhancing developer experience and reducing errors.
icon: "🛡️"
- title: Powerful Pagination
details: Easily paginate through large datasets with built-in support
details: Effortlessly navigate through large datasets with built-in, performant pagination support.
icon: "📄"
- title: Full-Text Search
details: Perform comprehensive searches across multiple fields in your data
icon: "🔎"
- title: Advanced Filtering
details: Apply complex filters with various match modes for precise data retrieval
details: Apply complex, multi-level filters with various match modes for precise and flexible data retrieval.
icon: "🧭"
- title: Full-Text Search
details: Perform lightning-fast, comprehensive searches across multiple fields in your data.
icon: "🔎"
- title: Zero Dependencies
details: Benefit from a lightweight, bloat-free library that won't burden your project with unnecessary code.
icon: "🪶"
- title: Flexible Sorting
details: Order results based on any field, with support for ascending and descending orders
details: Order results based on multiple fields, with support for custom sorting logic and directional control.
icon: "🔢"
- title: Optimized Performance
details: Process millions of rows in milliseconds, with speed that scales for even the largest datasets.
icon: ""
- title: Intuitive API
details: Enjoy a clean, elegant API that makes complex data operations simple and readable.
icon: "🧩"

footer:
message: "Licensed under the MIT License. Created by [Your Name]. Extensible and customizable for developers."
Expand Down
7 changes: 2 additions & 5 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ export function query<T extends GenericObject, P extends QueryParams<T>>(
data: T[],
params: P,
): QueryResult<T, P> {
let result: Iterable<T> = lazyQuery(data, params)

if (params.sort)
result = lazySortedQuery(result, params.sort)

let result = lazyQuery(data, params)
result = lazySortedQuery(result, params.sort)
return paginateQuery(Array.from(result), params)
}

Expand Down
9 changes: 6 additions & 3 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ for (const fixture of fixtures) {
describe('performance check', () => {
// VAL BETWEEN 1 & 100
const getValue = () => Math.floor(Math.random() * 100)
const startItems = performance.now()
const items = Array.from({ length: 1000000 }, (_, i) => ({
id: i,
name: `Item ${i}`,
Expand All @@ -49,7 +50,9 @@ describe('performance check', () => {
address: { city: 'New York', country: 'USA' },
age: Math.floor(Math.random() * 100),
}))
it('query 1M rows - paginate + sort + search + filter in less than 500ms', () => {
const endItems = performance.now()
it('query 1M rows - paginate + sort + search + filter in less than 30ms', () => {
console.info('Time taken to generate 1M items:', endItems - startItems)
const start = performance.now()
query(items, {
limit: 100,
Expand All @@ -65,7 +68,7 @@ describe('performance check', () => {
})

const end = performance.now()
console.info('Time taken:', end - start)
expect(end - start).toBeLessThan(500)
console.info('Time taken to query 1M items:', end - start)
expect(end - start).toBeLessThan(30)

Check failure on line 72 in test/index.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

test/index.test.ts > performance check > query 1M rows - paginate + sort + search + filter in less than 30ms

AssertionError: expected 37.77829899999779 to be less than 30 ❯ test/index.test.ts:72:25

Check failure on line 72 in test/index.test.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest)

test/index.test.ts > performance check > query 1M rows - paginate + sort + search + filter in less than 30ms

AssertionError: expected 45.78489999996964 to be less than 30 ❯ test/index.test.ts:72:25
})
})

0 comments on commit 6d1cafc

Please sign in to comment.