0.2.0 • Published 9 years ago

transform-cache v0.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

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

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

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

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.