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

nq-cache

v0.0.3

Published

function cache

Readme

NQ-CACHE

function cache

build status codecov node version David deps license

Features

  • IE8+
  • Support for Typescript

Document

  • [Example on JSBin] (https://jsbin.com/baluray/edit?html,js,output)

Installation

Install npm package

npm install nq-cache

Use pureFuncMemoryCache

add.js

import { pureFuncMemoryCache } from 'nq-cache'

export function add (a, b) {
  return a + b
}

export const addCache = pureFuncMemoryCache(add)

app.js

import { addCache as add } from './add'
add(1, 2) // execute and cache the result
add(1, 2) // Get results directly from the cache

use promiseMemoryCache

request.js

import { promiseMemoryCache } from 'nq-cache'

export function request (data) {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve(data)
    }, 2 * 1000)
  })
}

export const requestCache = promiseMemoryCache(request)

app.js

import { requestCache as request } from './request'
// execute and cache the result
request({ name: 'bowl' }).then(res => {
  // get results directly from the cache
  return request({ name: 'bowl' })
})

use promiseSessionStorageCache

request.js

import { promiseSessionStorageCache } from 'nq-cache'

export function request (data) {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve(data)
    }, 2 * 1000)
  })
}

export const requestCache = promiseSessionStorageCache(request, 'request')

app.js

import { requestCache as request } from './request'
// execute and cache the result
request({ name: 'bowl' }).then(res => {
  // Get results directly from the cache
  return request({ name: 'bowl' })
})

CDN

Contains only nq-cache

<!-- Use the latest version -->
<script src="https://unpkg.com/nq-cache@latest"></script>
<!-- or specify a version -->
<script src="https://unpkg.com/[email protected]"></script>
<script>
  function add (a, b) {
    return a + b
  }
  addCache = cache.pureFuncMemoryCache(add)
  addCache(1, 2) // Execute and cache the result
  addCache(1, 2) // Get the result directly from the cache
</script>

For more other methods, you can view [example] (https://jsbin.com/baluray/edit?html,js,output)

if the browser does not support Promise or JSON, you should do a polyfill

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"></script>
<!--[if lt IE 8]>
  <script type="text/javascript" src="https://cdn.bootcss.com/json2/20160511/json2.min.js"></script>
<![endif]-->

Methods

  • pureFuncMemoryCache
  • promiseMemoryCache
  • promiseSessionStorageCache
  • clearCache
  • argToKey

Local development

  • Installation dependencies
npm install
  • Testing
npm test
  • Build
npm run build
  • Flow
npm run flow
  • ESLint
npm run lint
  • Update documentation
npm run doc
  • Run the test page
npm run build
npm run example

Then open it with a browser
Http://localhost:5000/examples/
  • Release
npm version [new version]
npm run build
npm publish