Primeiro commit do projeto Angular
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
import { Minipass } from 'minipass';
|
||||
export declare class SizeError extends Error {
|
||||
expect: number;
|
||||
found: number;
|
||||
code: 'EBADSIZE';
|
||||
constructor(found: number, expect: number, from?: (...a: any[]) => any);
|
||||
get name(): string;
|
||||
}
|
||||
export type Options<T extends Minipass.BufferOrString> = Minipass.Options<T> & {
|
||||
objectMode?: false;
|
||||
size: number;
|
||||
};
|
||||
export declare class MinipassSized<RType extends Minipass.BufferOrString, WType extends Minipass.BufferOrString, Events extends Minipass.Events<RType> = Minipass.Events<RType>> extends Minipass<RType, WType, Events> {
|
||||
found: number;
|
||||
expect: number;
|
||||
constructor(options: Options<RType>);
|
||||
write(chunk: WType, cb?: () => void): boolean;
|
||||
write(chunk: WType, encoding?: Minipass.Encoding, cb?: () => void): boolean;
|
||||
emit<Event extends keyof Events>(ev: Event, ...args: Events[Event]): boolean;
|
||||
}
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAKnC,qBAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,UAAU,CAAa;gBACjB,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,GAAG;IAMtE,IAAI,IAAI,WAEP;CACF;AAED,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,QAAQ,CAAC,cAAc,IACnD,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;IACpB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAEH,qBAAa,aAAa,CACxB,KAAK,SAAS,QAAQ,CAAC,cAAc,EACrC,KAAK,SAAS,QAAQ,CAAC,cAAc,EACrC,MAAM,SAAS,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAC9D,SAAQ,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;IACtC,KAAK,EAAE,MAAM,CAAI;IACjB,MAAM,EAAE,MAAM,CAAA;gBAEF,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC;IA2BnC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO;IAC7C,KAAK,CACH,KAAK,EAAE,KAAK,EACZ,QAAQ,CAAC,EAAE,QAAQ,CAAC,QAAQ,EAC5B,EAAE,CAAC,EAAE,MAAM,IAAI,GACd,OAAO;IAoCV,IAAI,CAAC,KAAK,SAAS,MAAM,MAAM,EAC7B,EAAE,EAAE,KAAK,EACT,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,GACrB,OAAO;CAWX"}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MinipassSized = exports.SizeError = void 0;
|
||||
const minipass_1 = require("minipass");
|
||||
const isBufferEncoding = (enc) => typeof enc === 'string';
|
||||
class SizeError extends Error {
|
||||
expect;
|
||||
found;
|
||||
code = 'EBADSIZE';
|
||||
constructor(found, expect, from) {
|
||||
super(`Bad data size: expected ${expect} bytes, but got ${found}`);
|
||||
this.expect = expect;
|
||||
this.found = found;
|
||||
Error.captureStackTrace(this, from ?? this.constructor);
|
||||
}
|
||||
get name() {
|
||||
return 'SizeError';
|
||||
}
|
||||
}
|
||||
exports.SizeError = SizeError;
|
||||
class MinipassSized extends minipass_1.Minipass {
|
||||
found = 0;
|
||||
expect;
|
||||
constructor(options) {
|
||||
const size = options?.size;
|
||||
if (typeof size !== 'number' ||
|
||||
size > Number.MAX_SAFE_INTEGER ||
|
||||
isNaN(size) ||
|
||||
size < 0 ||
|
||||
!isFinite(size) ||
|
||||
size !== Math.floor(size)) {
|
||||
throw new Error('invalid expected size: ' + size);
|
||||
}
|
||||
//@ts-ignore
|
||||
super(options);
|
||||
if (options.objectMode) {
|
||||
throw new TypeError(`${this.constructor.name} streams only work with string and buffer data`);
|
||||
}
|
||||
this.expect = size;
|
||||
}
|
||||
write(chunk, encoding, cb) {
|
||||
const buffer = Buffer.isBuffer(chunk) ? chunk
|
||||
: typeof chunk === 'string' ?
|
||||
Buffer.from(chunk, isBufferEncoding(encoding) ? encoding : 'utf8')
|
||||
: chunk;
|
||||
if (typeof encoding === 'function') {
|
||||
cb = encoding;
|
||||
encoding = null;
|
||||
}
|
||||
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, ...args) {
|
||||
if (ev === 'end') {
|
||||
if (this.found !== this.expect) {
|
||||
this.emit('error', new SizeError(this.found, this.expect, this.emit));
|
||||
}
|
||||
}
|
||||
return super.emit(ev, ...args);
|
||||
}
|
||||
}
|
||||
exports.MinipassSized = MinipassSized;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { Minipass } from 'minipass';
|
||||
export declare class SizeError extends Error {
|
||||
expect: number;
|
||||
found: number;
|
||||
code: 'EBADSIZE';
|
||||
constructor(found: number, expect: number, from?: (...a: any[]) => any);
|
||||
get name(): string;
|
||||
}
|
||||
export type Options<T extends Minipass.BufferOrString> = Minipass.Options<T> & {
|
||||
objectMode?: false;
|
||||
size: number;
|
||||
};
|
||||
export declare class MinipassSized<RType extends Minipass.BufferOrString, WType extends Minipass.BufferOrString, Events extends Minipass.Events<RType> = Minipass.Events<RType>> extends Minipass<RType, WType, Events> {
|
||||
found: number;
|
||||
expect: number;
|
||||
constructor(options: Options<RType>);
|
||||
write(chunk: WType, cb?: () => void): boolean;
|
||||
write(chunk: WType, encoding?: Minipass.Encoding, cb?: () => void): boolean;
|
||||
emit<Event extends keyof Events>(ev: Event, ...args: Events[Event]): boolean;
|
||||
}
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAKnC,qBAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,UAAU,CAAa;gBACjB,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,GAAG;IAMtE,IAAI,IAAI,WAEP;CACF;AAED,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,QAAQ,CAAC,cAAc,IACnD,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;IACpB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAEH,qBAAa,aAAa,CACxB,KAAK,SAAS,QAAQ,CAAC,cAAc,EACrC,KAAK,SAAS,QAAQ,CAAC,cAAc,EACrC,MAAM,SAAS,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAC9D,SAAQ,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;IACtC,KAAK,EAAE,MAAM,CAAI;IACjB,MAAM,EAAE,MAAM,CAAA;gBAEF,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC;IA2BnC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO;IAC7C,KAAK,CACH,KAAK,EAAE,KAAK,EACZ,QAAQ,CAAC,EAAE,QAAQ,CAAC,QAAQ,EAC5B,EAAE,CAAC,EAAE,MAAM,IAAI,GACd,OAAO;IAoCV,IAAI,CAAC,KAAK,SAAS,MAAM,MAAM,EAC7B,EAAE,EAAE,KAAK,EACT,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,GACrB,OAAO;CAWX"}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
import { Minipass } from 'minipass';
|
||||
const isBufferEncoding = (enc) => typeof enc === 'string';
|
||||
export class SizeError extends Error {
|
||||
expect;
|
||||
found;
|
||||
code = 'EBADSIZE';
|
||||
constructor(found, expect, from) {
|
||||
super(`Bad data size: expected ${expect} bytes, but got ${found}`);
|
||||
this.expect = expect;
|
||||
this.found = found;
|
||||
Error.captureStackTrace(this, from ?? this.constructor);
|
||||
}
|
||||
get name() {
|
||||
return 'SizeError';
|
||||
}
|
||||
}
|
||||
export class MinipassSized extends Minipass {
|
||||
found = 0;
|
||||
expect;
|
||||
constructor(options) {
|
||||
const size = options?.size;
|
||||
if (typeof size !== 'number' ||
|
||||
size > Number.MAX_SAFE_INTEGER ||
|
||||
isNaN(size) ||
|
||||
size < 0 ||
|
||||
!isFinite(size) ||
|
||||
size !== Math.floor(size)) {
|
||||
throw new Error('invalid expected size: ' + size);
|
||||
}
|
||||
//@ts-ignore
|
||||
super(options);
|
||||
if (options.objectMode) {
|
||||
throw new TypeError(`${this.constructor.name} streams only work with string and buffer data`);
|
||||
}
|
||||
this.expect = size;
|
||||
}
|
||||
write(chunk, encoding, cb) {
|
||||
const buffer = Buffer.isBuffer(chunk) ? chunk
|
||||
: typeof chunk === 'string' ?
|
||||
Buffer.from(chunk, isBufferEncoding(encoding) ? encoding : 'utf8')
|
||||
: chunk;
|
||||
if (typeof encoding === 'function') {
|
||||
cb = encoding;
|
||||
encoding = null;
|
||||
}
|
||||
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, ...args) {
|
||||
if (ev === 'end') {
|
||||
if (this.found !== this.expect) {
|
||||
this.emit('error', new SizeError(this.found, this.expect, this.emit));
|
||||
}
|
||||
}
|
||||
return super.emit(ev, ...args);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
Reference in New Issue
Block a user