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 🙏

© 2024 – Pkg Stats / Ryan Hefner

jonathan

v1.1.0

Published

DEPRECATED! An in-memory cache for Node

Downloads

15

Readme

DEPRECATED

This was the first npm module that I published since returning to web development. It was mainly an experiment with TDD in Node.js, and in retrospect, it isn't that great; the worst offender is that it uses setInterval to remove items from the cache, rather than simply attaching a timestamp to cache items, when stored, for later comparison.

The module will still be available, and I might consider unpublishing it (GASP) if I can confirm that it is no longer being downloaded. In the meantime, you should migrate to stale-lru-cache; it's ridiculously fast.

Jonathan Build status

(npm)

An in-memory cache for Node.js

Installation

Jonathan can be installed into your project via npm:

npm install jonathan --save

Basic usage

'use strict';

var http = require('http');
var jonathan = require('jonathan');
var server;

server = http.createServer(function (req, res) {
	jonathan.add('name', 'James');
	res.writeHead(200, { 'Content-Type': 'text/plain' });
	res.end('The name stored in Jonathan is: ' + jonathan.get('name'));
});

server.listen(3000);
console.log('Listening on port 3000');

APIs

Number.prototype polyfills

As of version 1.0.9, this module attaches a set of properties to Number's prototype so that you can write durations more fluently, such as:

jonathan.add('key', 'value', (2).weeks);
jonathan.add('key2', ['one', 'two'], (5).months);
jonathan.add('key3', { name: 'Bob' }, (50).seconds);

These properties simply multiply the Number object on which you've called the method by a predefined amount of milliseconds.

Here are all of the attached projects:

  • Number.prototype.seconds
  • Number.prototype.minutes
  • Number.prototype.hours
  • Number.prototype.days
  • Number.prototype.weeks
  • Number.prototype.months
  • Number.prototype.years

Prior to 1.0.9, these properties exist as methods, and thus must be invoked explicitly.

jonathan

####~~init() - Function~~ removed in 1.0.9 Initialises the cache. You must call this before you can use Jonathan.

####invalidate() - Function Invalidates the entire cache

####add(key, value, duration) - Function Adds any JavaScript Object to the cache under a specified String key. If the duration parameter is not specified, it will be stored indefinitely, otherwise a Number is required representing the total milliseconds to persist the data (see Number.prototype polyfills.)

####get(key) - Function Retrieves a value from the cache by the specified key. If the key is not present in the cache, this method will return undefined.

####remove(key) - Function Removes a key, and its accompanying value, from the cache.

Tests

Jonathan was written using test-driven development (TDD) with Mocha. To run the tests, simply invoke npm test.