Add types for @hapi/pez (#65690)

* Add types for `@hapi/pez`

Signed-off-by: Grant Timmerman <grant@observablehq.com>

* ci: run lint

Signed-off-by: Grant Timmerman <grant@observablehq.com>

* remove @hapi/pez

Signed-off-by: Grant Timmerman <grant@observablehq.com>

* remove @hapi/content

Signed-off-by: Grant Timmerman <grant@observablehq.com>

---------

Signed-off-by: Grant Timmerman <grant@observablehq.com>
This commit is contained in:
Grant Timmerman
2023-06-05 16:27:01 -07:00
committed by GitHub
parent cee508633b
commit 09239fd9de
5 changed files with 68 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import Content from "@hapi/content";
import Pez from '@hapi/pez';
const contentType = Content.type("application/json; charset=utf-8");
const minDispenser = new Pez.Dispenser({ boundary: 'AaB03x' });
const maxBytesDispenser = new Pez.Dispenser({
boundary: 'AaB03x',
maxBytes: 4096 - 1,
maxParts: 1,
});
// Example with Node Stream Options type
const nodeOptionDispenser = new Pez.Dispenser({
boundary: 'AaB03x',
maxBytes: 50e6,
...contentType,
});

17
types/hapi__pez/index.d.ts vendored Normal file
View File

@@ -0,0 +1,17 @@
// Type definitions for @hapi/pez 6.1
// Project: https://github.com/hapijs/pez
// Definitions by: Grant Timmerman <https://github.com/grant>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import * as stream from 'stream';
export interface PezOptions extends stream.WritableOptions {
boundary: string;
maxBytes?: number;
maxParts?: number;
}
export class Dispenser extends stream.Writable {
constructor(options?: PezOptions);
}

View File

@@ -0,0 +1,3 @@
{
"private": true
}

View File

@@ -0,0 +1,29 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"paths": {
"@hapi/*": [
"hapi__*"
]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": [
"index.d.ts",
"hapi__pez-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }