How to use the cache-base.namespace function in cache-base

To help you get started, we’ve selected a few cache-base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OTRChat / NodeChat / nodeChatServer / node_modules / base / index.js View on Github external
function namespace(name) {
  var Cache = name ? CacheBase.namespace(name) : CacheBase;
  var fns = [];

  /**
   * Create an instance of `Base` with the given `config` and `options`.
   *
   * ```js
   * // initialize with `config` and `options`
   * var app = new Base({isApp: true}, {abc: true});
   * app.set('foo', 'bar');
   *
   * // values defined with the given `config` object will be on the root of the instance
   * console.log(app.baz); //=> undefined
   * console.log(app.foo); //=> 'bar'
   * // or use `.get`
   * console.log(app.get('isApp')); //=> true
   * console.log(app.get('foo')); //=> 'bar'
github base / base-data / index.js View on Github external
/*!
 * base-data 
 *
 * Copyright (c) 2015-2017, Jon Schlinkert.
 * Released under the MIT License.
 */

'use strict';

var util = require('util');
var cache = require('cache-base');
var Cache = cache.namespace('cache');
var utils = require('./utils');

module.exports = function(prop, config) {
  if (utils.isObject(prop)) {
    config = prop;
    prop = 'cache.data';
  }
  if (typeof prop === 'undefined') {
    prop = 'cache.data';
  }

  return function baseData() {
    if (!utils.isValid(this, prop)) {
      return;
    }

cache-base

Basic object cache with `get`, `set`, `del`, and `has` methods for node.js/javascript projects.

MIT
Latest version published 3 years ago

Package Health Score

65 / 100
Full package analysis

Popular cache-base functions