Cache object that can transform values when setting.
Install with npm
npm i transform-cache --save
npm test
var Cache = require('transform-cache');
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
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Brian Woodward
Copyright (c) 2015 Brian Woodward
Released under the MIT license
This file was generated by verb on February 03, 2015.