npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

kreepo

v0.9.7

Published

NodeJS implementation of Repository pattern

Readme

kreepo

NodeJS implementation of Repository pattern

Insallation

npm install --save kreepo@latest

Usage

To use your first Repository just import module and call a factory method.

const kreepo = require('kreepo');

// create new repository
const dummyRepository = kreepo.createRepository();

All methods are thenable (return Promises), while construction process is synchronious.

const dummyRepository = kreepo.createRepository();

dummyRepository.set('key', 'value')
  .then(() => dummyRepository.get('key'))
  .then((result) => console.log(result));

Datasources

Repository pattern requires some kind of adapters for each data-layer platform to allow unified interface. Datasource classes implement those adapters.

Datasources are classes that incapsulate logic of direct data-layer communiation.

Many of general purpose datasources are provided with kreepo package.

// access datasource classes within a kreepo facade
const { InMemoryDatasource, JsonDatasource } = kreepo.datasource;

// create a Datasource that stores data in RAM
const ramDatasource = new InMemoryDatasource();

// create a Datasource that stores data in a JSON file
const jsonDatasource = new JsonDatasource('/tmp/test.json');

// create a Repository that access both Datasorses
const repository = bytebroket.createRepository({
  datasource: [ramDatasource, jsonDatasource],
});

API Reference

Repository

get(id)

Get an entity from a Repository.

@param {any} id -- identifier of entity to get

@return {Promise} -- resolves with a requested entity or null

Performs lookup over registered Datasources with respect ro readPriority of those.

Attempts to read data from a Datasource with a maximum readPriority.

Value is mapped with emtityFactory if the one is specified in constructor.

set(id, value)

Save entity within a Repository.

@param {any} id -- identifier of entity to save @param {any} value -- value to be saved

@return {Promise} -- resolves with an identifier of saved entity or null if entity wasn't saved

Saves data to every WRITE_ALWAYS Datasource

Saves data to a single WRITE_FIRST Datasource with a maximum writePriority property

Skips NO_WRITE datasource

Saves data to cache instead of triggering Datasource directly when SYNC_ON_REQUEST or SYNC_ON_TIMEOUT sync strategy chosen.

delete(id)

Delete entity from a Repository.

@param {any} id -- identifier of entity to remove

@return {Promise} -- resolves with true if removal operation was performed and false if it wasn't

Removes data from each datasource except those that marked as NO_WRITE.

Saves data to cache instead of triggering Datasource directly when SYNC_ON_REQUEST or SYNC_ON_TIMEOUT sync strategy chosen.

getall()

List all keys that available all over the Datasources

@return {Promise} -- resolves with list of available keys

find(selector)

Search througth available keys using regular expression

@param {RegExp} selector -- regular xepression to test keys

@return {Promise} -- resolves with list of matching keys

mget(ids)

Get multiple entities from a Repository.

@param {Array} ids -- list of entity identifiers

@return {Promise} -- resolves with key-value mapping of ids to entities

Performs lookup over registered Datasources with respect ro readPriority of those.

Attempts to read data from a Datasource with a maximum readPriority.

Value is mapped with emtityFactory if the one is specified in constructor.

mset(payload)

Save multiple entities within a Repository.

@param {Object<id => value>} payload -- represents values that should be saved under id

@return {Promise} -- resolves with list of seted ids

Mitigates #set logic fluently

Use #set method directly if datasource have no #mset implemented

mdelete(ids)

Delete multiple entities from a Repository.

@param {Array} ids -- list of entity identifiers

@return {Promise} -- resolves with key-value mapping with id's and true, if value was removed

Removes data from each datasource except those that marked as NO_WRITE.

Saves data to cache instead of triggering Datasource directly when SYNC_ON_REQUEST or SYNC_ON_TIMEOUT sync strategy chosen.

sync()

TBD