diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2015-06-11 06:58:53 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2015-06-11 06:58:53 +0300 |
commit | ad75823610867b54ad5a4831229899c329c0b793 (patch) | |
tree | aa6980189d8422cc2bd80602054fbcdf98f21555 /index.js | |
parent | 5f3e73f9937228fac0b9974de7db5b4fbb16b1bf (diff) |
factor out common variable into const
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -19,14 +19,15 @@ var Torrent = require('./lib/torrent') inherits(WebTorrent, EventEmitter) +var VERSION = require('./package.json').version + /** * BitTorrent client version string (used in peer ID). * Generated from package.json major and minor version. For example: * '0.16.1' -> '0016' * '1.2.5' -> '0102' */ -var VERSION = require('./package.json').version - .match(/([0-9]+)/g).slice(0, 2).map(zeroFill(2)).join('') +var VERSION_STR = VERSION.match(/([0-9]+)/g).slice(0, 2).map(zeroFill(2)).join('') /** * WebTorrent Client @@ -58,7 +59,7 @@ function WebTorrent (opts) { : Storage self.peerId = opts.peerId === undefined - ? new Buffer('-WW' + VERSION + '-' + hat(48), 'utf8') + ? new Buffer('-WW' + VERSION_STR + '-' + hat(48), 'utf8') : typeof opts.peerId === 'string' ? new Buffer(opts.peerId, 'hex') : opts.peerId @@ -198,7 +199,7 @@ WebTorrent.prototype.seed = function (input, opts, onseed) { } if (!opts) opts = {} opts.noVerify = true - opts.createdBy = 'WebTorrent/' + require('./package.json').version + opts.createdBy = 'WebTorrent/' + VERSION var streams var torrent = self.add(undefined, opts, function (torrent) { |