コード例 #1
0
/*!
 * base-data <https://github.com/node-base/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;
    }

    if (!this.dataLoaders) {
      this.define('dataLoaders', []);
    }
コード例 #2
0
ファイル: index.js プロジェクト: jonschlinkert/bower-store
/*!
 * bower-store <https://github.com/jonschlinkert/bower-store>
 *
 * Copyright (c) 2016, Jon Schlinkert.
 * Licensed under the MIT License.
 */

'use strict';

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

/**
 * Initialize a new `Bower` store at the given `cwd` with
 * the specified `options`.
 *
 * ```js
 * var bower = require('bower-store')(process.cwd());
 *
 * console.log(bower.path);
 * //=> '~/your-project/bower.json'
 *
 * console.log(bower.data);
 * //=> {name: 'your-project', ...}
 * ```
 *
 * @param  {String} `cwd` Directory of the bower.json to read.