Skip to content
This repository was archived by the owner on Jan 7, 2022. It is now read-only.

Commit e52105f

Browse files
committed
remove xtend
1 parent a2e9623 commit e52105f

7 files changed

Lines changed: 15 additions & 20 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ tmp
44
coverage/
55
npm-debug.log*
66
.nyc_output/
7-
yarn.lock
7+
yarn.lock
8+
package-lock.json

dat.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
var assert = require('assert')
22
var path = require('path')
3-
var xtend = require('xtend')
43
var untildify = require('untildify')
54
var importFiles = require('./lib/import-files')
65
var createNetwork = require('./lib/network')
@@ -32,7 +31,7 @@ function Dat (archive, opts) {
3231
var self = this
3332

3433
this.archive = archive
35-
this.options = xtend(opts)
34+
this.options = Object.assign({}, opts)
3635
if (opts.dir) {
3736
this.path = path.resolve(untildify(opts.dir))
3837
}
@@ -91,7 +90,7 @@ Dat.prototype.join = function (opts, cb) {
9190
else opts = opts || {}
9291
cb = cb || noop
9392

94-
var netOpts = xtend({
93+
var netOpts = Object.assign({}, {
9594
stream: function (peer) {
9695
var stream = self.archive.replicate({
9796
upload: !(opts.upload === false),
@@ -157,7 +156,7 @@ Dat.prototype.resume = function () {
157156
* @type {Function}
158157
*/
159158
Dat.prototype.trackStats = function (opts) {
160-
opts = xtend({}, opts)
159+
opts = Object.assign({}, opts)
161160
this.stats = stats(this.archive, opts)
162161
return this.stats
163162
}
@@ -177,7 +176,7 @@ Dat.prototype.importFiles = function (src, opts, cb) {
177176

178177
var self = this
179178
src = src && src.length ? src : self.path
180-
opts = xtend({
179+
opts = Object.assign({
181180
indexing: (opts && opts.indexing) || (src === self.path)
182181
}, opts)
183182

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
var assert = require('assert')
22
var fs = require('fs')
33
var path = require('path')
4-
var xtend = require('xtend')
54
var hyperdrive = require('hyperdrive')
65
var resolveDatLink = require('dat-link-resolve')
76
var debug = require('debug')('dat-node')
@@ -37,7 +36,7 @@ function createDat (dirOrStorage, opts, cb) {
3736
var createIfMissing = !(opts.createIfMissing === false)
3837
var errorIfExists = opts.errorIfExists || false
3938
var hasDat = false
40-
opts = xtend({
39+
opts = Object.assign({
4140
// TODO: make sure opts.dir is a directory, not file
4241
dir: dir,
4342
latest: true

lib/import-files.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ var path = require('path')
33
var mirror = require('mirror-folder')
44
var datIgnore = require('dat-ignore')
55
var speed = require('speedometer')
6-
var xtend = require('xtend')
76
var debug = require('debug')('dat-node')
87

98
module.exports = importer
@@ -20,7 +19,7 @@ function importer (archive, src, opts, cb) {
2019
var ignoreDirs = !(opts.ignoreDirs === false)
2120
src = path.normalize(src)
2221

23-
opts = xtend({
22+
opts = Object.assign({
2423
watch: false,
2524
dereference: true,
2625
count: true
@@ -36,7 +35,7 @@ function importer (archive, src, opts, cb) {
3635
if (opts.count) {
3736
// Dry Run Import to get initial import size
3837
importCount = { files: 0, bytes: 0 }
39-
var dryRunOpts = xtend(opts, { dryRun: true, watch: false }) // force right side opts
38+
var dryRunOpts = Object.assign({}, opts, { dryRun: true, watch: false }) // force right side opts
4039
var dryRun = mirror(src, { name: '/', fs: archive }, dryRunOpts, function (err) {
4140
if (err) return cb(err)
4241
progress.emit('count', importCount)

lib/network.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
var assert = require('assert')
22
var swarmDefaults = require('dat-swarm-defaults')
33
var disc = require('discovery-swarm')
4-
var xtend = require('xtend')
54

65
module.exports = function (archive, opts, cb) {
76
assert.ok(archive, 'dat-node: lib/network archive required')
87
assert.ok(opts, 'dat-node: lib/network opts required')
98

109
var DEFAULT_PORT = 3282
11-
var swarmOpts = xtend({
10+
var swarmOpts = Object.assign({
1211
hash: false,
1312
stream: opts.stream
1413
}, opts)

lib/serve.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
var assert = require('assert')
22
var http = require('http')
33
var serve = require('hyperdrive-http')
4-
var xtend = require('xtend')
54
var debug = require('debug')('dat-node')
65

76
module.exports = function (archive, opts) {
87
assert.ok(archive, 'lib/serve: archive required')
9-
opts = xtend({
8+
opts = Object.assign({
109
port: 8080,
1110
live: true,
1211
footer: 'Served via Dat.'

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,19 @@
2222
"dat-ignore": "^2.1.1",
2323
"dat-link-resolve": "^2.2.0",
2424
"dat-storage": "^1.1.1",
25-
"dat-swarm-defaults": "^1.0.0",
25+
"dat-swarm-defaults": "^1.0.2",
2626
"debug": "^4.1.0",
2727
"discovery-swarm": "^5.1.2",
2828
"hyperdrive": "^9.14.2",
2929
"hyperdrive-http": "^4.3.3",
3030
"hyperdrive-network-speed": "^2.1.0",
3131
"mirror-folder": "^3.0.0",
3232
"random-access-file": "^2.0.1",
33-
"random-access-memory": "^3.0.0",
33+
"random-access-memory": "^3.1.1",
3434
"sparse-bitfield": "^3.0.3",
3535
"speedometer": "^1.1.0",
3636
"stream-each": "^1.2.3",
37-
"untildify": "^3.0.2",
38-
"xtend": "^4.0.1"
37+
"untildify": "^3.0.2"
3938
},
4039
"devDependencies": {
4140
"count-files": "^2.6.2",
@@ -45,7 +44,7 @@
4544
"memdown": "^3.0.0",
4645
"mkdirp": "^0.5.1",
4746
"nyc": "^13.1.0",
48-
"rimraf": "^2.5.4",
47+
"rimraf": "^2.6.3",
4948
"standard": "^12.0.1",
5049
"tape": "^4.9.1",
5150
"temporary-directory": "^1.0.2"

0 commit comments

Comments
 (0)