aboutsummaryrefslogtreecommitdiff
path: root/sandbox/testAppNevena/Front/node_modules/minipass-sized/index.js
diff options
context:
space:
mode:
authorNevena Bojovic <nenabojov@gmail.com>2022-03-01 22:05:25 +0100
committerNevena Bojovic <nenabojov@gmail.com>2022-03-01 22:05:25 +0100
commit6555fb80fdd8f6a5d201efadec3189d1244830a0 (patch)
treec1aa1c5aedc634ad1ea7fad4847884d559b51290 /sandbox/testAppNevena/Front/node_modules/minipass-sized/index.js
parent7d3640f824f46490b47bd95f1c5a16644f712068 (diff)
Izbrisala bin, obj i node-modules.
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/minipass-sized/index.js')
-rw-r--r--sandbox/testAppNevena/Front/node_modules/minipass-sized/index.js67
1 files changed, 0 insertions, 67 deletions
diff --git a/sandbox/testAppNevena/Front/node_modules/minipass-sized/index.js b/sandbox/testAppNevena/Front/node_modules/minipass-sized/index.js
deleted file mode 100644
index a0c8acde..00000000
--- a/sandbox/testAppNevena/Front/node_modules/minipass-sized/index.js
+++ /dev/null
@@ -1,67 +0,0 @@
-const Minipass = require('minipass')
-
-class SizeError extends Error {
- constructor (found, expect) {
- super(`Bad data size: expected ${expect} bytes, but got ${found}`)
- this.expect = expect
- this.found = found
- this.code = 'EBADSIZE'
- Error.captureStackTrace(this, this.constructor)
- }
- get name () {
- return 'SizeError'
- }
-}
-
-class MinipassSized extends Minipass {
- constructor (options = {}) {
- super(options)
-
- if (options.objectMode)
- throw new TypeError(`${
- this.constructor.name
- } streams only work with string and buffer data`)
-
- this.found = 0
- this.expect = options.size
- if (typeof this.expect !== 'number' ||
- this.expect > Number.MAX_SAFE_INTEGER ||
- isNaN(this.expect) ||
- this.expect < 0 ||
- !isFinite(this.expect) ||
- this.expect !== Math.floor(this.expect))
- throw new Error('invalid expected size: ' + this.expect)
- }
-
- write (chunk, encoding, cb) {
- const buffer = Buffer.isBuffer(chunk) ? chunk
- : typeof chunk === 'string' ?
- Buffer.from(chunk, typeof encoding === 'string' ? encoding : 'utf8')
- : chunk
-
- if (!Buffer.isBuffer(buffer)) {
- this.emit('error', new TypeError(`${
- this.constructor.name
- } streams only work with string and buffer data`))
- return false
- }
-
- this.found += buffer.length
- if (this.found > this.expect)
- this.emit('error', new SizeError(this.found, this.expect))
-
- return super.write(chunk, encoding, cb)
- }
-
- emit (ev, ...data) {
- if (ev === 'end') {
- if (this.found !== this.expect)
- this.emit('error', new SizeError(this.found, this.expect))
- }
- return super.emit(ev, ...data)
- }
-}
-
-MinipassSized.SizeError = SizeError
-
-module.exports = MinipassSized