MCPcopy Create free account
hub / github.com/LinkedDataFragments/Server.js / Datasource

Function Datasource

lib/datasources/Datasource.js:10–34  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

8
9// Creates a new Datasource
10function Datasource(options) {
11 if (!(this instanceof Datasource))
12 return new Datasource();
13 EventEmitter.call(this);
14
15 // Set the options
16 options = options || {};
17 this._request = options.request || require('request');
18 this._blankNodePrefix = options.blankNodePrefix || 'genid:';
19 this._blankNodePrefixLength = this._blankNodePrefix.length;
20
21 // Initialize the datasource asynchronously
22 setImmediate(function (self) {
23 var done = _.once(function (error) {
24 if (error)
25 self.emit('error', error);
26 else {
27 self.initialized = true;
28 self.emit('initialized');
29 }
30 });
31 try { self._initialize(done); }
32 catch (error) { done(error); }
33 }, this);
34}
35Datasource.prototype = new EventEmitter();
36
37// Makes Datasource the prototype of the given class

Callers 1

Datasource-test.jsFile · 0.85

Calls 1

doneFunction · 0.85

Tested by

no test coverage detected