forked from enviPath/enviPy
Current Dev State
This commit is contained in:
61
static/js/ketcher2/node_modules/istanbul/lib/store/fslookup.js
generated
vendored
Normal file
61
static/js/ketcher2/node_modules/istanbul/lib/store/fslookup.js
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
Copyright (c) 2012, Yahoo! Inc. All rights reserved.
|
||||
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
||||
*/
|
||||
|
||||
var util = require('util'),
|
||||
fs = require('fs'),
|
||||
Store = require('./index');
|
||||
|
||||
/**
|
||||
* a `Store` implementation that doesn't actually store anything. It assumes that keys
|
||||
* are absolute file paths, and contents are contents of those files.
|
||||
* Thus, `set` for this store is no-op, `get` returns the
|
||||
* contents of the filename that the key represents, `hasKey` returns true if the key
|
||||
* supplied is a valid file path and `keys` always returns an empty array.
|
||||
*
|
||||
* Usage
|
||||
* -----
|
||||
*
|
||||
* var store = require('istanbul').Store.create('fslookup');
|
||||
*
|
||||
*
|
||||
* @class LookupStore
|
||||
* @extends Store
|
||||
* @module store
|
||||
* @constructor
|
||||
*/
|
||||
function LookupStore(opts) {
|
||||
Store.call(this, opts);
|
||||
}
|
||||
|
||||
LookupStore.TYPE = 'fslookup';
|
||||
util.inherits(LookupStore, Store);
|
||||
|
||||
Store.mix(LookupStore, {
|
||||
keys: function () {
|
||||
return [];
|
||||
},
|
||||
get: function (key) {
|
||||
return fs.readFileSync(key, 'utf8');
|
||||
},
|
||||
hasKey: function (key) {
|
||||
var stats;
|
||||
try {
|
||||
stats = fs.statSync(key);
|
||||
return stats.isFile();
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
set: function (key /*, contents */) {
|
||||
if (!this.hasKey(key)) {
|
||||
throw new Error('Attempt to set contents for non-existent file [' + key + '] on a fslookup store');
|
||||
}
|
||||
return key;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
module.exports = LookupStore;
|
||||
|
||||
123
static/js/ketcher2/node_modules/istanbul/lib/store/index.js
generated
vendored
Normal file
123
static/js/ketcher2/node_modules/istanbul/lib/store/index.js
generated
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
Copyright (c) 2012, Yahoo! Inc. All rights reserved.
|
||||
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
||||
*/
|
||||
|
||||
var Factory = require('../util/factory'),
|
||||
factory = new Factory('store', __dirname, false);
|
||||
/**
|
||||
* An abstraction for keeping track of content against some keys (e.g.
|
||||
* original source, instrumented source, coverage objects against file names).
|
||||
* This class is both the base class as well as a factory for `Store` implementations.
|
||||
*
|
||||
* Usage
|
||||
* -----
|
||||
*
|
||||
* var Store = require('istanbul').Store,
|
||||
* store = Store.create('memory');
|
||||
*
|
||||
* //basic use
|
||||
* store.set('foo', 'foo-content');
|
||||
* var content = store.get('foo');
|
||||
*
|
||||
* //keys and values
|
||||
* store.keys().forEach(function (key) {
|
||||
* console.log(key + ':\n' + store.get(key);
|
||||
* });
|
||||
* if (store.hasKey('bar') { console.log(store.get('bar'); }
|
||||
*
|
||||
*
|
||||
* //syntactic sugar
|
||||
* store.setObject('foo', { foo: true });
|
||||
* console.log(store.getObject('foo').foo);
|
||||
*
|
||||
* store.dispose();
|
||||
*
|
||||
* @class Store
|
||||
* @constructor
|
||||
* @module store
|
||||
* @param {Object} options Optional. The options supported by a specific store implementation.
|
||||
* @main store
|
||||
*/
|
||||
function Store(/* options */) {}
|
||||
|
||||
//add register, create, mix, loadAll, getStoreList as class methods
|
||||
factory.bindClassMethods(Store);
|
||||
|
||||
/**
|
||||
* registers a new store implementation.
|
||||
* @method register
|
||||
* @static
|
||||
* @param {Function} constructor the constructor function for the store. This function must have a
|
||||
* `TYPE` property of type String, that will be used in `Store.create()`
|
||||
*/
|
||||
/**
|
||||
* returns a store implementation of the specified type.
|
||||
* @method create
|
||||
* @static
|
||||
* @param {String} type the type of store to create
|
||||
* @param {Object} opts Optional. Options specific to the store implementation
|
||||
* @return {Store} a new store of the specified type
|
||||
*/
|
||||
|
||||
Store.prototype = {
|
||||
/**
|
||||
* sets some content associated with a specific key. The manner in which
|
||||
* duplicate keys are handled for multiple `set()` calls with the same
|
||||
* key is implementation-specific.
|
||||
*
|
||||
* @method set
|
||||
* @param {String} key the key for the content
|
||||
* @param {String} contents the contents for the key
|
||||
*/
|
||||
set: function (/* key, contents */) { throw new Error("set: must be overridden"); },
|
||||
/**
|
||||
* returns the content associated to a specific key or throws if the key
|
||||
* was not `set`
|
||||
* @method get
|
||||
* @param {String} key the key for which to get the content
|
||||
* @return {String} the content for the specified key
|
||||
*/
|
||||
get: function (/* key */) { throw new Error("get: must be overridden"); },
|
||||
/**
|
||||
* returns a list of all known keys
|
||||
* @method keys
|
||||
* @return {Array} an array of seen keys
|
||||
*/
|
||||
keys: function () { throw new Error("keys: must be overridden"); },
|
||||
/**
|
||||
* returns true if the key is one for which a `get()` call would work.
|
||||
* @method hasKey
|
||||
* @param {String} key
|
||||
* @return true if the key is valid for this store, false otherwise
|
||||
*/
|
||||
hasKey: function (/* key */) { throw new Error("hasKey: must be overridden"); },
|
||||
/**
|
||||
* lifecycle method to dispose temporary resources associated with the store
|
||||
* @method dispose
|
||||
*/
|
||||
dispose: function () {},
|
||||
/**
|
||||
* sugar method to return an object associated with a specific key. Throws
|
||||
* if the content set against the key was not a valid JSON string.
|
||||
* @method getObject
|
||||
* @param {String} key the key for which to return the associated object
|
||||
* @return {Object} the object corresponding to the key
|
||||
*/
|
||||
getObject: function (key) {
|
||||
return JSON.parse(this.get(key));
|
||||
},
|
||||
/**
|
||||
* sugar method to set an object against a specific key.
|
||||
* @method setObject
|
||||
* @param {String} key the key for the object
|
||||
* @param {Object} object the object to be stored
|
||||
*/
|
||||
setObject: function (key, object) {
|
||||
return this.set(key, JSON.stringify(object));
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Store;
|
||||
|
||||
|
||||
56
static/js/ketcher2/node_modules/istanbul/lib/store/memory.js
generated
vendored
Normal file
56
static/js/ketcher2/node_modules/istanbul/lib/store/memory.js
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
Copyright (c) 2012, Yahoo! Inc. All rights reserved.
|
||||
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
||||
*/
|
||||
|
||||
var util = require('util'),
|
||||
Store = require('./index');
|
||||
|
||||
/**
|
||||
* a `Store` implementation using an in-memory object.
|
||||
*
|
||||
* Usage
|
||||
* -----
|
||||
*
|
||||
* var store = require('istanbul').Store.create('memory');
|
||||
*
|
||||
*
|
||||
* @class MemoryStore
|
||||
* @extends Store
|
||||
* @module store
|
||||
* @constructor
|
||||
*/
|
||||
function MemoryStore() {
|
||||
Store.call(this);
|
||||
this.map = {};
|
||||
}
|
||||
|
||||
MemoryStore.TYPE = 'memory';
|
||||
util.inherits(MemoryStore, Store);
|
||||
|
||||
Store.mix(MemoryStore, {
|
||||
set: function (key, contents) {
|
||||
this.map[key] = contents;
|
||||
},
|
||||
|
||||
get: function (key) {
|
||||
if (!this.hasKey(key)) {
|
||||
throw new Error('Unable to find entry for [' + key + ']');
|
||||
}
|
||||
return this.map[key];
|
||||
},
|
||||
|
||||
hasKey: function (key) {
|
||||
return this.map.hasOwnProperty(key);
|
||||
},
|
||||
|
||||
keys: function () {
|
||||
return Object.keys(this.map);
|
||||
},
|
||||
|
||||
dispose: function () {
|
||||
this.map = {};
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = MemoryStore;
|
||||
81
static/js/ketcher2/node_modules/istanbul/lib/store/tmp.js
generated
vendored
Normal file
81
static/js/ketcher2/node_modules/istanbul/lib/store/tmp.js
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
Copyright (c) 2012, Yahoo! Inc. All rights reserved.
|
||||
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
||||
*/
|
||||
|
||||
var util = require('util'),
|
||||
path = require('path'),
|
||||
os = require('os'),
|
||||
fs = require('fs'),
|
||||
mkdirp = require('mkdirp'),
|
||||
Store = require('./index');
|
||||
|
||||
function makeTempDir() {
|
||||
var dir = path.join(os.tmpdir ? os.tmpdir() : /* istanbul ignore next */ (process.env.TMPDIR || '/tmp'), 'ts' + new Date().getTime());
|
||||
mkdirp.sync(dir);
|
||||
return dir;
|
||||
}
|
||||
/**
|
||||
* a `Store` implementation using temporary files.
|
||||
*
|
||||
* Usage
|
||||
* -----
|
||||
*
|
||||
* var store = require('istanbul').Store.create('tmp');
|
||||
*
|
||||
*
|
||||
* @class TmpStore
|
||||
* @extends Store
|
||||
* @module store
|
||||
* @param {Object} opts Optional.
|
||||
* @param {String} [opts.tmp] a pre-existing directory to use as the `tmp` directory. When not specified, a random directory
|
||||
* is created under `os.tmpdir()`
|
||||
* @constructor
|
||||
*/
|
||||
function TmpStore(opts) {
|
||||
opts = opts || {};
|
||||
this.tmp = opts.tmp || makeTempDir();
|
||||
this.map = {};
|
||||
this.seq = 0;
|
||||
this.prefix = 't' + new Date().getTime() + '-';
|
||||
}
|
||||
|
||||
TmpStore.TYPE = 'tmp';
|
||||
util.inherits(TmpStore, Store);
|
||||
|
||||
Store.mix(TmpStore, {
|
||||
generateTmpFileName: function () {
|
||||
this.seq += 1;
|
||||
return path.join(this.tmp, this.prefix + this.seq + '.tmp');
|
||||
},
|
||||
|
||||
set: function (key, contents) {
|
||||
var tmpFile = this.generateTmpFileName();
|
||||
fs.writeFileSync(tmpFile, contents, 'utf8');
|
||||
this.map[key] = tmpFile;
|
||||
},
|
||||
|
||||
get: function (key) {
|
||||
var tmpFile = this.map[key];
|
||||
if (!tmpFile) { throw new Error('Unable to find tmp entry for [' + tmpFile + ']'); }
|
||||
return fs.readFileSync(tmpFile, 'utf8');
|
||||
},
|
||||
|
||||
hasKey: function (key) {
|
||||
return !!this.map[key];
|
||||
},
|
||||
|
||||
keys: function () {
|
||||
return Object.keys(this.map);
|
||||
},
|
||||
|
||||
dispose: function () {
|
||||
var map = this.map;
|
||||
Object.keys(map).forEach(function (key) {
|
||||
fs.unlinkSync(map[key]);
|
||||
});
|
||||
this.map = {};
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = TmpStore;
|
||||
Reference in New Issue
Block a user