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

plasma-cache

v0.2.2

Published

Object cache for [Plasma].

Readme

plasma-cache NPM version

Object cache for Plasma.

Install

Install with npm

$ npm i plasma-cache --save

Install with bower

$ bower install plasma-cache --save

Usage

var PlasmaCache = require('plasma-cache');
var cache = new PlasmaCache();

API

PlasmaCache

Initialize a new PlasmaCache.

.plasma

Extend the data object with the value returned by plasma.

See the plasma documentation for all available options.

Params

  • data {Object|String|Array}: File path(s), glob pattern, or object of data.
  • options {Object}: Options to pass to plasma.

Example

cache
  .plasma({foo: 'bar'}, {baz: 'quux'});
  .plasma({fez: 'bang'});

.dataLoader

Register a dataLoader that will read and load data from files with the given ext.

Params

  • ext {String}: The extension of files to read.
  • fn {String}: The loader function

Example

var fs = require('fs');
var yaml = require('js-yaml');

plasma.dataLoader('yml', function (fp) {
  var str = fs.readFileSync(fp, 'utf8');
  return yaml.safeLoad(str);
});

.process

Use expander to recursively expand template strings into their resolved values.

Params

  • lookup {*}: Any value to process, usually strings with a cache template, like <%= foo %> or ${foo}.
  • opts {*}: Options to pass to Lo-Dash _.template.

Example

cache.process({a: '<%= b %>', b: 'c'});
//=> {a: 'c', b: 'c'}

.flattenData

If a data property is on the given data object (e.g. data.data, like when files named data.json or data.yml are used), data.data is flattened to just data

Params

  • data {Object}
  • returns {Object}: Flattened object.

.extendData

Extend the cache.data object with the given data. This method is chainable.

  • returns {Object} PlasmaCache: to enable chaining

Example

cache
  .extendData({foo: 'bar'}, {baz: 'quux'});
  .extendData({fez: 'bang'});

.data

Extend the cache.data object with data from a JSON or YAML file, or by passing an object directly - glob patterns or file paths may be used.

Params

  • values {Object|Array|String}: Values to pass to plasma.
  • process {Boolean}: If true is passed as the last argumemnt data will
  • returns {Object} PlasmaCache: to enable chaining

Example

cache
  .data({a: 'b'})
  .data({c: 'd'});

console.log(cache);
//=> {data: {a: 'b', c: 'd'}}

cache.data('*.{json,yml}');
// or
cache.data('package.json');
//=> {name: 'plasma-cache', ...}

// process config templates
cache.data({a: '<%= b %>', b: 'z'})
//=> {data: {a: 'z', b: 'z'}}

Related projects

  • config-cache: General purpose JavaScript object storage methods.
  • data-store: Easily get, set and persist config data.
  • option-cache: Simple API for managing options in JavaScript applications.
  • plasma: Load data from globs or files or directly from objects.

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on June 01, 2015.