0.3.1 • Published 9 months ago

@criterium/js v0.3.1

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

@criterium/js

@criterium/js allow you to filter, sort and paginate JavaScript arrays using mongo-like syntax.

install

npm i @criterium/js

usage

import filter, { QueryValidationError } from '@criterium/js';

const list = [
  { created: new Date("2025-02-01"), title: 'will bitcoin continue to fall ?' },
  { created: new Date("2025-02-15"), title: 'can solana hold this time ?' },
  { created: new Date("2024-03-15"), title: 'solana vs bitcoin vs ethereum' },
];

const results = filter(list, {
  $and: [
    { created: { $gte: new Date("2025-01-01") } },
    { title: { $like: 'bitcoin.*' } },
  ],
  $sort: { created: -1 },
  $limit: 15
});

if (results instanceof QueryValidationError) throw results;
//or if (results instanceof Error) throw results;

console.log(results);
0.3.0

9 months ago

0.3.1

9 months ago

0.2.0

1 year ago

0.1.0

2 years ago

0.0.3

2 years ago

0.0.2

3 years ago

0.0.1

3 years ago