@webexatech/plugin-collection-transfer 0.0.0-stage → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/LICENSE +201 -0
- package/README.md +149 -2
- package/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/949.3230de7f57066bc7.js +10 -0
- package/dist/client/SettingsPage.d.ts +3 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +10 -0
- package/dist/client/plugin.d.ts +5 -0
- package/dist/client-v2/907.bed81d14270e80c6.js +10 -0
- package/dist/client-v2/CollectionTransferSettings.d.ts +21 -0
- package/dist/client-v2/SettingsPage.d.ts +4 -0
- package/dist/client-v2/index.d.ts +1 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/client-v2/locale.d.ts +7 -0
- package/dist/client-v2/plugin.d.ts +7 -0
- package/dist/externalVersion.js +24 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +70 -0
- package/dist/locale/zh-CN.json +70 -0
- package/dist/node_modules/archiver/LICENSE +22 -0
- package/dist/node_modules/archiver/index.js +68 -0
- package/dist/node_modules/archiver/lib/core.js +974 -0
- package/dist/node_modules/archiver/lib/error.js +40 -0
- package/dist/node_modules/archiver/lib/plugins/json.js +110 -0
- package/dist/node_modules/archiver/lib/plugins/tar.js +167 -0
- package/dist/node_modules/archiver/lib/plugins/zip.js +120 -0
- package/dist/node_modules/archiver/node_modules/async/all.js +119 -0
- package/dist/node_modules/archiver/node_modules/async/allLimit.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/allSeries.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/any.js +122 -0
- package/dist/node_modules/archiver/node_modules/async/anyLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/anySeries.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/apply.js +11 -0
- package/dist/node_modules/archiver/node_modules/async/applyEach.js +57 -0
- package/dist/node_modules/archiver/node_modules/async/applyEachSeries.js +37 -0
- package/dist/node_modules/archiver/node_modules/async/asyncify.js +118 -0
- package/dist/node_modules/archiver/node_modules/async/auto.js +333 -0
- package/dist/node_modules/archiver/node_modules/async/autoInject.js +182 -0
- package/dist/node_modules/archiver/node_modules/async/bower.json +17 -0
- package/dist/node_modules/archiver/node_modules/async/cargo.js +63 -0
- package/dist/node_modules/archiver/node_modules/async/cargoQueue.js +71 -0
- package/dist/node_modules/archiver/node_modules/async/compose.js +55 -0
- package/dist/node_modules/archiver/node_modules/async/concat.js +115 -0
- package/dist/node_modules/archiver/node_modules/async/concatLimit.js +60 -0
- package/dist/node_modules/archiver/node_modules/async/concatSeries.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/constant.js +14 -0
- package/dist/node_modules/archiver/node_modules/async/detect.js +96 -0
- package/dist/node_modules/archiver/node_modules/async/detectLimit.js +48 -0
- package/dist/node_modules/archiver/node_modules/async/detectSeries.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/dir.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/dist/async.js +6062 -0
- package/dist/node_modules/archiver/node_modules/async/dist/async.min.js +1 -0
- package/dist/node_modules/archiver/node_modules/async/doDuring.js +68 -0
- package/dist/node_modules/archiver/node_modules/async/doUntil.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/doWhilst.js +68 -0
- package/dist/node_modules/archiver/node_modules/async/during.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/each.js +129 -0
- package/dist/node_modules/archiver/node_modules/async/eachLimit.js +50 -0
- package/dist/node_modules/archiver/node_modules/async/eachOf.js +185 -0
- package/dist/node_modules/archiver/node_modules/async/eachOfLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/eachOfSeries.js +39 -0
- package/dist/node_modules/archiver/node_modules/async/eachSeries.js +44 -0
- package/dist/node_modules/archiver/node_modules/async/ensureAsync.js +67 -0
- package/dist/node_modules/archiver/node_modules/async/every.js +119 -0
- package/dist/node_modules/archiver/node_modules/async/everyLimit.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/everySeries.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/filter.js +93 -0
- package/dist/node_modules/archiver/node_modules/async/filterLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/filterSeries.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/find.js +96 -0
- package/dist/node_modules/archiver/node_modules/async/findLimit.js +48 -0
- package/dist/node_modules/archiver/node_modules/async/findSeries.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/flatMap.js +115 -0
- package/dist/node_modules/archiver/node_modules/async/flatMapLimit.js +60 -0
- package/dist/node_modules/archiver/node_modules/async/flatMapSeries.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/foldl.js +153 -0
- package/dist/node_modules/archiver/node_modules/async/foldr.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/forEach.js +129 -0
- package/dist/node_modules/archiver/node_modules/async/forEachLimit.js +50 -0
- package/dist/node_modules/archiver/node_modules/async/forEachOf.js +185 -0
- package/dist/node_modules/archiver/node_modules/async/forEachOfLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/forEachOfSeries.js +39 -0
- package/dist/node_modules/archiver/node_modules/async/forEachSeries.js +44 -0
- package/dist/node_modules/archiver/node_modules/async/forever.js +68 -0
- package/dist/node_modules/archiver/node_modules/async/groupBy.js +108 -0
- package/dist/node_modules/archiver/node_modules/async/groupByLimit.js +71 -0
- package/dist/node_modules/archiver/node_modules/async/groupBySeries.js +36 -0
- package/dist/node_modules/archiver/node_modules/async/index.js +588 -0
- package/dist/node_modules/archiver/node_modules/async/inject.js +153 -0
- package/dist/node_modules/archiver/node_modules/async/internal/DoublyLinkedList.js +92 -0
- package/dist/node_modules/archiver/node_modules/async/internal/Heap.js +120 -0
- package/dist/node_modules/archiver/node_modules/async/internal/applyEach.js +29 -0
- package/dist/node_modules/archiver/node_modules/async/internal/asyncEachOfLimit.js +75 -0
- package/dist/node_modules/archiver/node_modules/async/internal/awaitify.js +28 -0
- package/dist/node_modules/archiver/node_modules/async/internal/breakLoop.js +10 -0
- package/dist/node_modules/archiver/node_modules/async/internal/consoleFunc.js +31 -0
- package/dist/node_modules/archiver/node_modules/async/internal/createTester.js +40 -0
- package/dist/node_modules/archiver/node_modules/async/internal/eachOfLimit.js +90 -0
- package/dist/node_modules/archiver/node_modules/async/internal/filter.js +55 -0
- package/dist/node_modules/archiver/node_modules/async/internal/getIterator.js +11 -0
- package/dist/node_modules/archiver/node_modules/async/internal/initialParams.js +14 -0
- package/dist/node_modules/archiver/node_modules/async/internal/isArrayLike.js +10 -0
- package/dist/node_modules/archiver/node_modules/async/internal/iterator.js +57 -0
- package/dist/node_modules/archiver/node_modules/async/internal/map.js +30 -0
- package/dist/node_modules/archiver/node_modules/async/internal/once.js +17 -0
- package/dist/node_modules/archiver/node_modules/async/internal/onlyOnce.js +15 -0
- package/dist/node_modules/archiver/node_modules/async/internal/parallel.js +34 -0
- package/dist/node_modules/archiver/node_modules/async/internal/promiseCallback.js +23 -0
- package/dist/node_modules/archiver/node_modules/async/internal/queue.js +294 -0
- package/dist/node_modules/archiver/node_modules/async/internal/range.js +14 -0
- package/dist/node_modules/archiver/node_modules/async/internal/reject.js +26 -0
- package/dist/node_modules/archiver/node_modules/async/internal/setImmediate.js +34 -0
- package/dist/node_modules/archiver/node_modules/async/internal/withoutIndex.js +10 -0
- package/dist/node_modules/archiver/node_modules/async/internal/wrapAsync.js +34 -0
- package/dist/node_modules/archiver/node_modules/async/log.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/map.js +142 -0
- package/dist/node_modules/archiver/node_modules/async/mapLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/mapSeries.js +44 -0
- package/dist/node_modules/archiver/node_modules/async/mapValues.js +152 -0
- package/dist/node_modules/archiver/node_modules/async/mapValuesLimit.js +61 -0
- package/dist/node_modules/archiver/node_modules/async/mapValuesSeries.js +37 -0
- package/dist/node_modules/archiver/node_modules/async/memoize.js +91 -0
- package/dist/node_modules/archiver/node_modules/async/nextTick.js +52 -0
- package/dist/node_modules/archiver/node_modules/async/package.json +75 -0
- package/dist/node_modules/archiver/node_modules/async/parallel.js +180 -0
- package/dist/node_modules/archiver/node_modules/async/parallelLimit.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/priorityQueue.js +60 -0
- package/dist/node_modules/archiver/node_modules/async/queue.js +24 -0
- package/dist/node_modules/archiver/node_modules/async/race.js +67 -0
- package/dist/node_modules/archiver/node_modules/async/reduce.js +153 -0
- package/dist/node_modules/archiver/node_modules/async/reduceRight.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/reflect.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/reflectAll.js +93 -0
- package/dist/node_modules/archiver/node_modules/async/reject.js +87 -0
- package/dist/node_modules/archiver/node_modules/async/rejectLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/rejectSeries.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/retry.js +159 -0
- package/dist/node_modules/archiver/node_modules/async/retryable.js +77 -0
- package/dist/node_modules/archiver/node_modules/async/select.js +93 -0
- package/dist/node_modules/archiver/node_modules/async/selectLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/selectSeries.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/seq.js +79 -0
- package/dist/node_modules/archiver/node_modules/async/series.js +186 -0
- package/dist/node_modules/archiver/node_modules/async/setImmediate.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/some.js +122 -0
- package/dist/node_modules/archiver/node_modules/async/someLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/someSeries.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/sortBy.js +190 -0
- package/dist/node_modules/archiver/node_modules/async/timeout.js +89 -0
- package/dist/node_modules/archiver/node_modules/async/times.js +50 -0
- package/dist/node_modules/archiver/node_modules/async/timesLimit.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/timesSeries.js +32 -0
- package/dist/node_modules/archiver/node_modules/async/transform.js +173 -0
- package/dist/node_modules/archiver/node_modules/async/tryEach.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/unmemoize.js +25 -0
- package/dist/node_modules/archiver/node_modules/async/until.js +61 -0
- package/dist/node_modules/archiver/node_modules/async/waterfall.js +105 -0
- package/dist/node_modules/archiver/node_modules/async/whilst.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/wrapSync.js +118 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/errors-browser.js +127 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/errors.js +116 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/experimentalWarning.js +17 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_duplex.js +126 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_passthrough.js +37 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_readable.js +1027 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_transform.js +190 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_writable.js +641 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/async_iterator.js +180 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/buffer_list.js +183 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/destroy.js +96 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +86 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/from.js +52 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/pipeline.js +86 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/state.js +22 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/package.json +68 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/readable-browser.js +9 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/readable.js +16 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/extract.js +257 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/headers.js +295 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/index.js +2 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/pack.js +255 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/package.json +58 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/sandbox.js +11 -0
- package/dist/node_modules/archiver/package.json +1 -0
- package/dist/node_modules/yauzl/LICENSE +21 -0
- package/dist/node_modules/yauzl/fd-slicer.js +314 -0
- package/dist/node_modules/yauzl/index.js +1 -0
- package/dist/node_modules/yauzl/package.json +1 -0
- package/dist/server/exporter.d.ts +42 -0
- package/dist/server/exporter.js +311 -0
- package/dist/server/field-value-writer.d.ts +9 -0
- package/dist/server/field-value-writer.js +107 -0
- package/dist/server/importer.d.ts +138 -0
- package/dist/server/importer.js +842 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +42 -0
- package/dist/server/package-format.d.ts +50 -0
- package/dist/server/package-format.js +115 -0
- package/dist/server/plugin.d.ts +6 -0
- package/dist/server/plugin.js +61 -0
- package/dist/server/resourcer.d.ts +14 -0
- package/dist/server/resourcer.js +144 -0
- package/package.json +54 -4
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
var constants = require('fs-constants')
|
|
2
|
+
var eos = require('end-of-stream')
|
|
3
|
+
var inherits = require('inherits')
|
|
4
|
+
var alloc = Buffer.alloc
|
|
5
|
+
|
|
6
|
+
var Readable = require('readable-stream').Readable
|
|
7
|
+
var Writable = require('readable-stream').Writable
|
|
8
|
+
var StringDecoder = require('string_decoder').StringDecoder
|
|
9
|
+
|
|
10
|
+
var headers = require('./headers')
|
|
11
|
+
|
|
12
|
+
var DMODE = parseInt('755', 8)
|
|
13
|
+
var FMODE = parseInt('644', 8)
|
|
14
|
+
|
|
15
|
+
var END_OF_TAR = alloc(1024)
|
|
16
|
+
|
|
17
|
+
var noop = function () {}
|
|
18
|
+
|
|
19
|
+
var overflow = function (self, size) {
|
|
20
|
+
size &= 511
|
|
21
|
+
if (size) self.push(END_OF_TAR.slice(0, 512 - size))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function modeToType (mode) {
|
|
25
|
+
switch (mode & constants.S_IFMT) {
|
|
26
|
+
case constants.S_IFBLK: return 'block-device'
|
|
27
|
+
case constants.S_IFCHR: return 'character-device'
|
|
28
|
+
case constants.S_IFDIR: return 'directory'
|
|
29
|
+
case constants.S_IFIFO: return 'fifo'
|
|
30
|
+
case constants.S_IFLNK: return 'symlink'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return 'file'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var Sink = function (to) {
|
|
37
|
+
Writable.call(this)
|
|
38
|
+
this.written = 0
|
|
39
|
+
this._to = to
|
|
40
|
+
this._destroyed = false
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
inherits(Sink, Writable)
|
|
44
|
+
|
|
45
|
+
Sink.prototype._write = function (data, enc, cb) {
|
|
46
|
+
this.written += data.length
|
|
47
|
+
if (this._to.push(data)) return cb()
|
|
48
|
+
this._to._drain = cb
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Sink.prototype.destroy = function () {
|
|
52
|
+
if (this._destroyed) return
|
|
53
|
+
this._destroyed = true
|
|
54
|
+
this.emit('close')
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var LinkSink = function () {
|
|
58
|
+
Writable.call(this)
|
|
59
|
+
this.linkname = ''
|
|
60
|
+
this._decoder = new StringDecoder('utf-8')
|
|
61
|
+
this._destroyed = false
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
inherits(LinkSink, Writable)
|
|
65
|
+
|
|
66
|
+
LinkSink.prototype._write = function (data, enc, cb) {
|
|
67
|
+
this.linkname += this._decoder.write(data)
|
|
68
|
+
cb()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
LinkSink.prototype.destroy = function () {
|
|
72
|
+
if (this._destroyed) return
|
|
73
|
+
this._destroyed = true
|
|
74
|
+
this.emit('close')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var Void = function () {
|
|
78
|
+
Writable.call(this)
|
|
79
|
+
this._destroyed = false
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
inherits(Void, Writable)
|
|
83
|
+
|
|
84
|
+
Void.prototype._write = function (data, enc, cb) {
|
|
85
|
+
cb(new Error('No body allowed for this entry'))
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
Void.prototype.destroy = function () {
|
|
89
|
+
if (this._destroyed) return
|
|
90
|
+
this._destroyed = true
|
|
91
|
+
this.emit('close')
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
var Pack = function (opts) {
|
|
95
|
+
if (!(this instanceof Pack)) return new Pack(opts)
|
|
96
|
+
Readable.call(this, opts)
|
|
97
|
+
|
|
98
|
+
this._drain = noop
|
|
99
|
+
this._finalized = false
|
|
100
|
+
this._finalizing = false
|
|
101
|
+
this._destroyed = false
|
|
102
|
+
this._stream = null
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
inherits(Pack, Readable)
|
|
106
|
+
|
|
107
|
+
Pack.prototype.entry = function (header, buffer, callback) {
|
|
108
|
+
if (this._stream) throw new Error('already piping an entry')
|
|
109
|
+
if (this._finalized || this._destroyed) return
|
|
110
|
+
|
|
111
|
+
if (typeof buffer === 'function') {
|
|
112
|
+
callback = buffer
|
|
113
|
+
buffer = null
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (!callback) callback = noop
|
|
117
|
+
|
|
118
|
+
var self = this
|
|
119
|
+
|
|
120
|
+
if (!header.size || header.type === 'symlink') header.size = 0
|
|
121
|
+
if (!header.type) header.type = modeToType(header.mode)
|
|
122
|
+
if (!header.mode) header.mode = header.type === 'directory' ? DMODE : FMODE
|
|
123
|
+
if (!header.uid) header.uid = 0
|
|
124
|
+
if (!header.gid) header.gid = 0
|
|
125
|
+
if (!header.mtime) header.mtime = new Date()
|
|
126
|
+
|
|
127
|
+
if (typeof buffer === 'string') buffer = Buffer.from(buffer)
|
|
128
|
+
if (Buffer.isBuffer(buffer)) {
|
|
129
|
+
header.size = buffer.length
|
|
130
|
+
this._encode(header)
|
|
131
|
+
var ok = this.push(buffer)
|
|
132
|
+
overflow(self, header.size)
|
|
133
|
+
if (ok) process.nextTick(callback)
|
|
134
|
+
else this._drain = callback
|
|
135
|
+
return new Void()
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (header.type === 'symlink' && !header.linkname) {
|
|
139
|
+
var linkSink = new LinkSink()
|
|
140
|
+
eos(linkSink, function (err) {
|
|
141
|
+
if (err) { // stream was closed
|
|
142
|
+
self.destroy()
|
|
143
|
+
return callback(err)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
header.linkname = linkSink.linkname
|
|
147
|
+
self._encode(header)
|
|
148
|
+
callback()
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
return linkSink
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this._encode(header)
|
|
155
|
+
|
|
156
|
+
if (header.type !== 'file' && header.type !== 'contiguous-file') {
|
|
157
|
+
process.nextTick(callback)
|
|
158
|
+
return new Void()
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
var sink = new Sink(this)
|
|
162
|
+
|
|
163
|
+
this._stream = sink
|
|
164
|
+
|
|
165
|
+
eos(sink, function (err) {
|
|
166
|
+
self._stream = null
|
|
167
|
+
|
|
168
|
+
if (err) { // stream was closed
|
|
169
|
+
self.destroy()
|
|
170
|
+
return callback(err)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (sink.written !== header.size) { // corrupting tar
|
|
174
|
+
self.destroy()
|
|
175
|
+
return callback(new Error('size mismatch'))
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
overflow(self, header.size)
|
|
179
|
+
if (self._finalizing) self.finalize()
|
|
180
|
+
callback()
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
return sink
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
Pack.prototype.finalize = function () {
|
|
187
|
+
if (this._stream) {
|
|
188
|
+
this._finalizing = true
|
|
189
|
+
return
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (this._finalized) return
|
|
193
|
+
this._finalized = true
|
|
194
|
+
this.push(END_OF_TAR)
|
|
195
|
+
this.push(null)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
Pack.prototype.destroy = function (err) {
|
|
199
|
+
if (this._destroyed) return
|
|
200
|
+
this._destroyed = true
|
|
201
|
+
|
|
202
|
+
if (err) this.emit('error', err)
|
|
203
|
+
this.emit('close')
|
|
204
|
+
if (this._stream && this._stream.destroy) this._stream.destroy()
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
Pack.prototype._encode = function (header) {
|
|
208
|
+
if (!header.pax) {
|
|
209
|
+
var buf = headers.encode(header)
|
|
210
|
+
if (buf) {
|
|
211
|
+
this.push(buf)
|
|
212
|
+
return
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
this._encodePax(header)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
Pack.prototype._encodePax = function (header) {
|
|
219
|
+
var paxHeader = headers.encodePax({
|
|
220
|
+
name: header.name,
|
|
221
|
+
linkname: header.linkname,
|
|
222
|
+
pax: header.pax
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
var newHeader = {
|
|
226
|
+
name: 'PaxHeader',
|
|
227
|
+
mode: header.mode,
|
|
228
|
+
uid: header.uid,
|
|
229
|
+
gid: header.gid,
|
|
230
|
+
size: paxHeader.length,
|
|
231
|
+
mtime: header.mtime,
|
|
232
|
+
type: 'pax-header',
|
|
233
|
+
linkname: header.linkname && 'PaxHeader',
|
|
234
|
+
uname: header.uname,
|
|
235
|
+
gname: header.gname,
|
|
236
|
+
devmajor: header.devmajor,
|
|
237
|
+
devminor: header.devminor
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
this.push(headers.encode(newHeader))
|
|
241
|
+
this.push(paxHeader)
|
|
242
|
+
overflow(this, paxHeader.length)
|
|
243
|
+
|
|
244
|
+
newHeader.size = header.size
|
|
245
|
+
newHeader.type = header.type
|
|
246
|
+
this.push(headers.encode(newHeader))
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
Pack.prototype._read = function (n) {
|
|
250
|
+
var drain = this._drain
|
|
251
|
+
this._drain = noop
|
|
252
|
+
drain()
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
module.exports = Pack
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tar-stream",
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"description": "tar-stream is a streaming tar parser and generator and nothing else. It is streams2 and operates purely using streams which means you can easily extract/parse tarballs without ever hitting the file system.",
|
|
5
|
+
"author": "Mathias Buus <mathiasbuus@gmail.com>",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"bl": "^4.0.3",
|
|
8
|
+
"end-of-stream": "^1.4.1",
|
|
9
|
+
"fs-constants": "^1.0.0",
|
|
10
|
+
"inherits": "^2.0.3",
|
|
11
|
+
"readable-stream": "^3.1.1"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"concat-stream": "^2.0.0",
|
|
15
|
+
"standard": "^12.0.1",
|
|
16
|
+
"tape": "^4.9.2"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "standard && tape test/extract.js test/pack.js",
|
|
20
|
+
"test-all": "standard && tape test/*.js"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"tar",
|
|
24
|
+
"tarball",
|
|
25
|
+
"parse",
|
|
26
|
+
"parser",
|
|
27
|
+
"generate",
|
|
28
|
+
"generator",
|
|
29
|
+
"stream",
|
|
30
|
+
"stream2",
|
|
31
|
+
"streams",
|
|
32
|
+
"streams2",
|
|
33
|
+
"streaming",
|
|
34
|
+
"pack",
|
|
35
|
+
"extract",
|
|
36
|
+
"modify"
|
|
37
|
+
],
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/mafintosh/tar-stream/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/mafintosh/tar-stream",
|
|
42
|
+
"main": "index.js",
|
|
43
|
+
"files": [
|
|
44
|
+
"*.js",
|
|
45
|
+
"LICENSE"
|
|
46
|
+
],
|
|
47
|
+
"directories": {
|
|
48
|
+
"test": "test"
|
|
49
|
+
},
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/mafintosh/tar-stream.git"
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=6"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const tar = require('tar-stream')
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const pipeline = require('pump') // eequire('stream').pipeline
|
|
5
|
+
|
|
6
|
+
fs.createReadStream('test.tar')
|
|
7
|
+
.pipe(tar.extract())
|
|
8
|
+
.on('entry', function (header, stream, done) {
|
|
9
|
+
console.log(header.name)
|
|
10
|
+
pipeline(stream, fs.createWriteStream(path.join('/tmp', header.name)), done)
|
|
11
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"archiver","version":"5.3.2","description":"a streaming interface for archive generation","homepage":"https://github.com/archiverjs/node-archiver","author":{"name":"Chris Talkington","url":"http://christalkington.com/"},"repository":{"type":"git","url":"https://github.com/archiverjs/node-archiver.git"},"bugs":{"url":"https://github.com/archiverjs/node-archiver/issues"},"license":"MIT","main":"index.js","files":["index.js","lib"],"engines":{"node":">= 10"},"scripts":{"test":"mocha --reporter dot","bench":"node benchmark/simple/pack-zip.js"},"dependencies":{"archiver-utils":"^2.1.0","async":"^3.2.4","buffer-crc32":"^0.2.1","readable-stream":"^3.6.0","readdir-glob":"^1.1.2","tar-stream":"^2.2.0","zip-stream":"^4.1.0"},"devDependencies":{"archiver-jsdoc-theme":"^1.1.3","chai":"^4.3.7","jsdoc":"^3.6.4","mkdirp":"^2.1.5","mocha":"^9.0.2","rimraf":"^4.3.1","stream-bench":"^0.1.2","tar":"^6.1.13","yauzl":"^2.9.0"},"keywords":["archive","archiver","stream","zip","tar"],"publishConfig":{"registry":"https://registry.npmjs.org/"},"_lastModified":"2026-11-22T13:16:02.487Z"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Josh Wolfe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
// This was adapted from https://github.com/andrewrk/node-fd-slicer by Andrew Kelley under the MIT License.
|
|
2
|
+
var fs = require('fs');
|
|
3
|
+
var util = require('util');
|
|
4
|
+
var stream = require('stream');
|
|
5
|
+
var Readable = stream.Readable;
|
|
6
|
+
var Writable = stream.Writable;
|
|
7
|
+
var PassThrough = stream.PassThrough;
|
|
8
|
+
var Pend = require('pend');
|
|
9
|
+
var EventEmitter = require('events').EventEmitter;
|
|
10
|
+
|
|
11
|
+
exports.createFromBuffer = createFromBuffer;
|
|
12
|
+
exports.createFromFd = createFromFd;
|
|
13
|
+
exports.BufferSlicer = BufferSlicer;
|
|
14
|
+
exports.FdSlicer = FdSlicer;
|
|
15
|
+
|
|
16
|
+
util.inherits(FdSlicer, EventEmitter);
|
|
17
|
+
function FdSlicer(fd, options) {
|
|
18
|
+
options = options || {};
|
|
19
|
+
EventEmitter.call(this);
|
|
20
|
+
|
|
21
|
+
this.fd = fd;
|
|
22
|
+
this.pend = new Pend();
|
|
23
|
+
this.pend.max = 1;
|
|
24
|
+
this.refCount = 0;
|
|
25
|
+
this.autoClose = !!options.autoClose;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
29
|
+
var self = this;
|
|
30
|
+
self.pend.go(function(cb) {
|
|
31
|
+
fs.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer) {
|
|
32
|
+
cb();
|
|
33
|
+
callback(err, bytesRead, buffer);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
39
|
+
var self = this;
|
|
40
|
+
self.pend.go(function(cb) {
|
|
41
|
+
fs.write(self.fd, buffer, offset, length, position, function(err, written, buffer) {
|
|
42
|
+
cb();
|
|
43
|
+
callback(err, written, buffer);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
FdSlicer.prototype.createReadStream = function(options) {
|
|
49
|
+
return new ReadStream(this, options);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
FdSlicer.prototype.createWriteStream = function(options) {
|
|
53
|
+
return new WriteStream(this, options);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
FdSlicer.prototype.ref = function() {
|
|
57
|
+
this.refCount += 1;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
FdSlicer.prototype.unref = function() {
|
|
61
|
+
var self = this;
|
|
62
|
+
self.refCount -= 1;
|
|
63
|
+
|
|
64
|
+
if (self.refCount > 0) return;
|
|
65
|
+
if (self.refCount < 0) throw new Error("invalid unref");
|
|
66
|
+
|
|
67
|
+
if (self.autoClose) {
|
|
68
|
+
fs.close(self.fd, onCloseDone);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function onCloseDone(err) {
|
|
72
|
+
if (err) {
|
|
73
|
+
self.emit('error', err);
|
|
74
|
+
} else {
|
|
75
|
+
self.emit('close');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
util.inherits(ReadStream, Readable);
|
|
81
|
+
function ReadStream(context, options) {
|
|
82
|
+
options = options || {};
|
|
83
|
+
Readable.call(this, options);
|
|
84
|
+
|
|
85
|
+
this.context = context;
|
|
86
|
+
this.context.ref();
|
|
87
|
+
|
|
88
|
+
this.start = options.start || 0;
|
|
89
|
+
this.endOffset = options.end;
|
|
90
|
+
this.pos = this.start;
|
|
91
|
+
this.destroyed = false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
ReadStream.prototype._read = function(n) {
|
|
95
|
+
var self = this;
|
|
96
|
+
if (self.destroyed) return;
|
|
97
|
+
|
|
98
|
+
var toRead = Math.min(self._readableState.highWaterMark, n);
|
|
99
|
+
if (self.endOffset != null) {
|
|
100
|
+
toRead = Math.min(toRead, self.endOffset - self.pos);
|
|
101
|
+
}
|
|
102
|
+
if (toRead <= 0) {
|
|
103
|
+
self.destroyed = true;
|
|
104
|
+
self.push(null);
|
|
105
|
+
self.context.unref();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
self.context.pend.go(function(cb) {
|
|
109
|
+
if (self.destroyed) return cb();
|
|
110
|
+
var buffer = Buffer.allocUnsafe(toRead);
|
|
111
|
+
fs.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
|
|
112
|
+
if (err) {
|
|
113
|
+
self.destroy(err);
|
|
114
|
+
} else if (bytesRead === 0) {
|
|
115
|
+
self.destroyed = true;
|
|
116
|
+
self.push(null);
|
|
117
|
+
self.context.unref();
|
|
118
|
+
} else {
|
|
119
|
+
self.pos += bytesRead;
|
|
120
|
+
self.push(buffer.slice(0, bytesRead));
|
|
121
|
+
}
|
|
122
|
+
cb();
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
ReadStream.prototype.destroy = function(err) {
|
|
128
|
+
if (this.destroyed) return;
|
|
129
|
+
err = err || new Error("stream destroyed");
|
|
130
|
+
this.destroyed = true;
|
|
131
|
+
this.emit('error', err);
|
|
132
|
+
this.context.unref();
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
util.inherits(WriteStream, Writable);
|
|
136
|
+
function WriteStream(context, options) {
|
|
137
|
+
options = options || {};
|
|
138
|
+
Writable.call(this, options);
|
|
139
|
+
|
|
140
|
+
this.context = context;
|
|
141
|
+
this.context.ref();
|
|
142
|
+
|
|
143
|
+
this.start = options.start || 0;
|
|
144
|
+
this.endOffset = (options.end == null) ? Infinity : +options.end;
|
|
145
|
+
this.bytesWritten = 0;
|
|
146
|
+
this.pos = this.start;
|
|
147
|
+
this.destroyed = false;
|
|
148
|
+
|
|
149
|
+
this.on('finish', this.destroy.bind(this));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
WriteStream.prototype._write = function(buffer, encoding, callback) {
|
|
153
|
+
var self = this;
|
|
154
|
+
if (self.destroyed) return;
|
|
155
|
+
|
|
156
|
+
if (self.pos + buffer.length > self.endOffset) {
|
|
157
|
+
var err = new Error("maximum file length exceeded");
|
|
158
|
+
err.code = 'ETOOBIG';
|
|
159
|
+
self.destroy();
|
|
160
|
+
callback(err);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
self.context.pend.go(function(cb) {
|
|
164
|
+
if (self.destroyed) return cb();
|
|
165
|
+
fs.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err, bytes) {
|
|
166
|
+
if (err) {
|
|
167
|
+
self.destroy();
|
|
168
|
+
cb();
|
|
169
|
+
callback(err);
|
|
170
|
+
} else {
|
|
171
|
+
self.bytesWritten += bytes;
|
|
172
|
+
self.pos += bytes;
|
|
173
|
+
self.emit('progress');
|
|
174
|
+
cb();
|
|
175
|
+
callback();
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
WriteStream.prototype.destroy = function() {
|
|
182
|
+
if (this.destroyed) return;
|
|
183
|
+
this.destroyed = true;
|
|
184
|
+
this.context.unref();
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
util.inherits(BufferSlicer, EventEmitter);
|
|
188
|
+
function BufferSlicer(buffer, options) {
|
|
189
|
+
EventEmitter.call(this);
|
|
190
|
+
|
|
191
|
+
options = options || {};
|
|
192
|
+
this.refCount = 0;
|
|
193
|
+
this.buffer = buffer;
|
|
194
|
+
this.maxChunkSize = options.maxChunkSize || Number.MAX_SAFE_INTEGER;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
198
|
+
if (!(0 <= offset && offset <= buffer.length)) throw new RangeError("offset outside buffer: 0 <= " + offset + " <= " + buffer.length);
|
|
199
|
+
if (position < 0) throw new RangeError("position is negative: " + position);
|
|
200
|
+
if (offset + length > buffer.length) {
|
|
201
|
+
// The caller's buffer can't hold all the bytes they're trying to read.
|
|
202
|
+
// Clamp the length instead of giving an error.
|
|
203
|
+
// The callback will be informed of fewer than expected bytes written.
|
|
204
|
+
length = buffer.length - offset;
|
|
205
|
+
}
|
|
206
|
+
if (position + length > this.buffer.length) {
|
|
207
|
+
// Clamp any attempt to read past the end of the source buffer.
|
|
208
|
+
length = this.buffer.length - position;
|
|
209
|
+
}
|
|
210
|
+
if (length <= 0) {
|
|
211
|
+
// After any clamping, we're fully out of bounds or otherwise have nothing to do.
|
|
212
|
+
// This isn't an error; it's just zero bytes written.
|
|
213
|
+
setImmediate(function() {
|
|
214
|
+
callback(null, 0);
|
|
215
|
+
});
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
this.buffer.copy(buffer, offset, position, position + length);
|
|
219
|
+
setImmediate(function() {
|
|
220
|
+
callback(null, length);
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
225
|
+
buffer.copy(this.buffer, position, offset, offset + length);
|
|
226
|
+
setImmediate(function() {
|
|
227
|
+
callback(null, length, buffer);
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
BufferSlicer.prototype.createReadStream = function(options) {
|
|
232
|
+
options = options || {};
|
|
233
|
+
var readStream = new PassThrough(options);
|
|
234
|
+
readStream.destroyed = false;
|
|
235
|
+
readStream.start = options.start || 0;
|
|
236
|
+
readStream.endOffset = options.end;
|
|
237
|
+
// by the time this function returns, we'll be done.
|
|
238
|
+
readStream.pos = readStream.endOffset || this.buffer.length;
|
|
239
|
+
|
|
240
|
+
// respect the maxChunkSize option to slice up the chunk into smaller pieces.
|
|
241
|
+
var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
|
|
242
|
+
var offset = 0;
|
|
243
|
+
while (true) {
|
|
244
|
+
var nextOffset = offset + this.maxChunkSize;
|
|
245
|
+
if (nextOffset >= entireSlice.length) {
|
|
246
|
+
// last chunk
|
|
247
|
+
if (offset < entireSlice.length) {
|
|
248
|
+
readStream.write(entireSlice.slice(offset, entireSlice.length));
|
|
249
|
+
}
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
readStream.write(entireSlice.slice(offset, nextOffset));
|
|
253
|
+
offset = nextOffset;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
readStream.end();
|
|
257
|
+
readStream.destroy = function() {
|
|
258
|
+
readStream.destroyed = true;
|
|
259
|
+
};
|
|
260
|
+
return readStream;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
BufferSlicer.prototype.createWriteStream = function(options) {
|
|
264
|
+
var bufferSlicer = this;
|
|
265
|
+
options = options || {};
|
|
266
|
+
var writeStream = new Writable(options);
|
|
267
|
+
writeStream.start = options.start || 0;
|
|
268
|
+
writeStream.endOffset = (options.end == null) ? this.buffer.length : +options.end;
|
|
269
|
+
writeStream.bytesWritten = 0;
|
|
270
|
+
writeStream.pos = writeStream.start;
|
|
271
|
+
writeStream.destroyed = false;
|
|
272
|
+
writeStream._write = function(buffer, encoding, callback) {
|
|
273
|
+
if (writeStream.destroyed) return;
|
|
274
|
+
|
|
275
|
+
var end = writeStream.pos + buffer.length;
|
|
276
|
+
if (end > writeStream.endOffset) {
|
|
277
|
+
var err = new Error("maximum file length exceeded");
|
|
278
|
+
err.code = 'ETOOBIG';
|
|
279
|
+
writeStream.destroyed = true;
|
|
280
|
+
callback(err);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
|
|
284
|
+
|
|
285
|
+
writeStream.bytesWritten += buffer.length;
|
|
286
|
+
writeStream.pos = end;
|
|
287
|
+
writeStream.emit('progress');
|
|
288
|
+
callback();
|
|
289
|
+
};
|
|
290
|
+
writeStream.destroy = function() {
|
|
291
|
+
writeStream.destroyed = true;
|
|
292
|
+
};
|
|
293
|
+
return writeStream;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
BufferSlicer.prototype.ref = function() {
|
|
297
|
+
this.refCount += 1;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
BufferSlicer.prototype.unref = function() {
|
|
301
|
+
this.refCount -= 1;
|
|
302
|
+
|
|
303
|
+
if (this.refCount < 0) {
|
|
304
|
+
throw new Error("invalid unref");
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
function createFromBuffer(buffer, options) {
|
|
309
|
+
return new BufferSlicer(buffer, options);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function createFromFd(fd, options) {
|
|
313
|
+
return new FdSlicer(fd, options);
|
|
314
|
+
}
|