(options)
| 8 | |
| 9 | // Creates a new Datasource |
| 10 | function 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 | } |
| 35 | Datasource.prototype = new EventEmitter(); |
| 36 | |
| 37 | // Makes Datasource the prototype of the given class |
no test coverage detected