UNPKG

@clearbit-dcp/clearbit.js-core

Version:

The hassle-free way to integrate analytics into any web application.

65 lines (50 loc) 869 B
'use strict'; /* * Module Dependencies. */ var bindAll = require('bind-all'); var clone = require('@ndhoule/clone'); /** * HOP. */ var has = Object.prototype.hasOwnProperty; /** * Expose `Memory` */ module.exports = bindAll(new Memory()); /** * Initialize `Memory` store */ function Memory() { this.store = {}; } /** * Set a `key` and `value`. * * @param {String} key * @param {Mixed} value * @return {Boolean} */ Memory.prototype.set = function(key, value) { this.store[key] = clone(value); return true; }; /** * Get a `key`. * * @param {String} key */ Memory.prototype.get = function(key) { if (!has.call(this.store, key)) return; return clone(this.store[key]); }; /** * Remove a `key`. * * @param {String} key * @return {Boolean} */ Memory.prototype.remove = function(key) { delete this.store[key]; return true; };