Primeiro commit do projeto Angular

This commit is contained in:
2026-03-14 20:41:55 +00:00
parent 9bebe1de72
commit 94f4f46395
22413 changed files with 3221690 additions and 0 deletions
+15
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.
+30
View File
@@ -0,0 +1,30 @@
# 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`.
```ts
import { MinipassSized } from 'minipass-sized'
// or:
// 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.
+21
View File
@@ -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
View File
@@ -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
View File
@@ -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
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
+21
View File
@@ -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
View File
@@ -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
View File
@@ -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
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
{
"type": "module"
}
+69
View File
@@ -0,0 +1,69 @@
{
"name": "minipass-sized",
"version": "2.0.0",
"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",
"files": [
"dist"
],
"scripts": {
"test": "tap",
"snap": "tap",
"pretest": "npm run prepare",
"presnap": "npm run prepare",
"prepare": "tshy",
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags",
"format": "prettier --write . --log-level warn",
"typedoc": "typedoc"
},
"devDependencies": {
"prettier": "^3.7.4",
"tap": "^21.5.0",
"tshy": "^3.1.0",
"typedoc": "^0.28.15"
},
"dependencies": {
"minipass": "^7.1.2"
},
"main": "./dist/commonjs/index.js",
"keywords": [
"minipass",
"size",
"length"
],
"directories": {
"test": "test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/isaacs/minipass-sized.git"
},
"engines": {
"node": ">=8"
},
"type": "module",
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
}
},
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"types": "./dist/commonjs/index.d.ts",
"module": "./dist/esm/index.js"
}