transform-cache

0.2.0 • Public • Published

transform-cache NPM version

Cache object that can transform values when setting.

Install

Install with npm

npm i transform-cache --save

Run tests

npm test

Usage

var Cache = require('transform-cache');

API

Create a cache that transforms values when setting.

  • cache {Object}: Object to store the cache on.
  • options {Object}
function makeKey = function (key) { return key.toUpperCase(); };
function transform = function (value) { return value.toUpperCase(); };

var cache = new Cache(makeKey, tranform);

Set a value on the cache. The value will be passed through the transform function before setting.

  • key {String}: Key used to set the value on the cache.
  • value {Mixed}: Value that gets set on the cache after being transformed.
cache.set('foo', 'bar');
//=> { 'FOO': 'BAR' }

Get a value from the cache.

  • key {String}: Key used to lookup the value.
  • returns {Mixed}: Value returned by the key.
var bar = cache.get('foo');
//=> BAR

Contributing

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

Author

Brian Woodward

License

Copyright (c) 2015 Brian Woodward
Released under the MIT license


This file was generated by verb on February 03, 2015.

Readme

Keywords

none

Package Sidebar

Install

npm i transform-cache

Weekly Downloads

4

Version

0.2.0

License

MIT

Last publish

Collaborators

  • doowb