This commit is contained in:
lalBi94
2023-03-05 13:23:23 +01:00
commit 7bc56c09b5
14034 changed files with 1834369 additions and 0 deletions

22
node_modules/minipass-sized/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,22 @@
# ignore most things, include some others
/*
/.*
!bin/
!lib/
!docs/
!package.json
!package-lock.json
!README.md
!CONTRIBUTING.md
!LICENSE
!CHANGELOG.md
!example/
!scripts/
!tap-snapshots/
!test/
!.travis.yml
!.gitignore
!.gitattributes
!coverage-map.js
!index.js

15
node_modules/minipass-sized/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

28
node_modules/minipass-sized/README.md generated vendored Normal file
View File

@@ -0,0 +1,28 @@
# minipass-sized
A Minipass stream that raises an error if you get a different number of
bytes than expected.
## USAGE
Use just like any old [minipass](http://npm.im/minipass) stream, but
provide a `size` option to the constructor.
The `size` option must be a positive integer, smaller than
`Number.MAX_SAFE_INTEGER`.
```js
const MinipassSized = require('minipass-sized')
// figure out how much data you expect to get
const expectedSize = +headers['content-length']
const stream = new MinipassSized({ size: expectedSize })
stream.on('error', er => {
// if it's the wrong size, then this will raise an error with
// { found: <number>, expect: <number>, code: 'EBADSIZE' }
})
response.pipe(stream)
```
Caveats: this does not work with `objectMode` streams, and will throw a
`TypeError` from the constructor if the size argument is missing or
invalid.

67
node_modules/minipass-sized/index.js generated vendored Normal file
View File

@@ -0,0 +1,67 @@
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

3464
node_modules/minipass-sized/package-lock.json generated vendored Normal file

File diff suppressed because it is too large Load Diff

39
node_modules/minipass-sized/package.json generated vendored Normal file
View File

@@ -0,0 +1,39 @@
{
"name": "minipass-sized",
"version": "1.0.3",
"description": "A Minipass stream that raises an error if you get a different number of bytes than expected",
"author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)",
"license": "ISC",
"scripts": {
"test": "tap",
"snap": "tap",
"preversion": "npm test",
"postversion": "npm publish",
"postpublish": "git push origin --follow-tags"
},
"tap": {
"check-coverage": true
},
"devDependencies": {
"tap": "^14.6.4"
},
"dependencies": {
"minipass": "^3.0.0"
},
"main": "index.js",
"keywords": [
"minipass",
"size",
"length"
],
"directories": {
"test": "test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/isaacs/minipass-sized.git"
},
"engines": {
"node": ">=8"
}
}

83
node_modules/minipass-sized/test/basic.js generated vendored Normal file
View File

@@ -0,0 +1,83 @@
const t = require('tap')
const MPS = require('../')
t.test('ok if size checks out', t => {
const mps = new MPS({ size: 4 })
mps.write(Buffer.from('a').toString('hex'), 'hex')
mps.write(Buffer.from('sd'))
mps.end('f')
return mps.concat().then(data => t.equal(data.toString(), 'asdf'))
})
t.test('error if size exceeded', t => {
const mps = new MPS({ size: 1 })
mps.on('error', er => {
t.match(er, {
message: 'Bad data size: expected 1 bytes, but got 4',
found: 4,
expect: 1,
code: 'EBADSIZE',
name: 'SizeError',
})
t.end()
})
mps.write('asdf')
})
t.test('error if size is not met', t => {
const mps = new MPS({ size: 999 })
t.throws(() => mps.end(), {
message: 'Bad data size: expected 999 bytes, but got 0',
found: 0,
name: 'SizeError',
expect: 999,
code: 'EBADSIZE',
})
t.end()
})
t.test('error if non-string/buffer is written', t => {
const mps = new MPS({size:1})
mps.on('error', er => {
t.match(er, {
message: 'MinipassSized streams only work with string and buffer data'
})
t.end()
})
mps.write({some:'object'})
})
t.test('projectiles', t => {
t.throws(() => new MPS(), {
message: 'invalid expected size: undefined'
}, 'size is required')
t.throws(() => new MPS({size: true}), {
message: 'invalid expected size: true'
}, 'size must be number')
t.throws(() => new MPS({size: NaN}), {
message: 'invalid expected size: NaN'
}, 'size must not be NaN')
t.throws(() => new MPS({size:1.2}), {
message: 'invalid expected size: 1.2'
}, 'size must be integer')
t.throws(() => new MPS({size: Infinity}), {
message: 'invalid expected size: Infinity'
}, 'size must be finite')
t.throws(() => new MPS({size: -1}), {
message: 'invalid expected size: -1'
}, 'size must be positive')
t.throws(() => new MPS({objectMode: true}), {
message: 'MinipassSized streams only work with string and buffer data'
}, 'no objectMode')
t.throws(() => new MPS({size: Number.MAX_SAFE_INTEGER + 1000000}), {
message: 'invalid expected size: 9007199255740992'
})
t.end()
})
t.test('exports SizeError class', t => {
t.isa(MPS.SizeError, 'function')
t.isa(MPS.SizeError.prototype, Error)
t.end()
})