Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion types/formidable/formidable-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import * as http from "http";
// arrange
const options: Options = {
allowEmptyFiles: true,
enabledPlugins: [],
enabledPlugins: [json, querystring],
encoding: "utf-8",
fileWriteStreamHandler: undefined,
hashAlgorithm: false,
Expand Down
2 changes: 1 addition & 1 deletion types/formidable/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ declare namespace formidable {
*/
filename?: (name: string, ext: string, part: Part, form: Formidable) => string;

enabledPlugins?: string[] | undefined;
enabledPlugins?: formidable.PluginFunction[] | undefined;

filter?: (part: Part) => boolean;
}
Expand Down
5 changes: 5 additions & 0 deletions types/node-bzip2/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!**/*.d.ts
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
20 changes: 20 additions & 0 deletions types/node-bzip2/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// <reference types="node" />
export interface CompressOptions {
/** Compression level from 1 (fastest) to 9 (best). Default is 9. */
level?: number;
/** Buffering behavior, e.g., 'auto'. */
buffering?: "auto" | string;
}

export interface DecompressOptions {
/** Use less memory during decompression at the cost of speed. */
small?: boolean;
}

export function compress(input: string | Buffer | Uint8Array, options?: CompressOptions): Buffer;

export function decompress(input: Buffer | Uint8Array, options?: DecompressOptions): Buffer;

export function compressAsync(input: string | Buffer | Uint8Array, options?: CompressOptions): Promise<Buffer>;

export function decompressAsync(input: Buffer | Uint8Array, options?: DecompressOptions): Promise<Buffer>;
39 changes: 39 additions & 0 deletions types/node-bzip2/node-bzip2-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as bzip2 from "node-bzip2";

interface Result {
data: Buffer | null;
error: Error | null;
}

async function doCompress(): Promise<Result> {
try {
const input = "Hello, world!";
const compressed = await bzip2.compressAsync(input, { level: 9 });
return { data: compressed, error: null };
} catch (e) {
return { data: null, error: e as Error };
}
}

async function doDecompress(cResult: Result): Promise<Result> {
if (cResult.error || !cResult.data) return cResult;
try {
const decompressed = await bzip2.decompressAsync(cResult.data);
return { data: decompressed, error: null };
} catch (e) {
return { data: null, error: e as Error };
}
}

async function doTest() {
const cResult = await doCompress();
const dResult = await doDecompress(cResult);

if (!dResult.error && dResult.data?.toString() === "Hello, world!") {
console.log("Success");
} else {
console.log("Failure", dResult.error);
}
}

doTest();
20 changes: 20 additions & 0 deletions types/node-bzip2/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"private": true,
"name": "@types/node-bzip2",
"version": "1.0.9999",
"projects": [
"https://github.com/WilliamVenner/node-bzip2"
],
"dependencies": {
"@types/node": "*"
},
"devDependencies": {
"@types/node-bzip2": "workspace:."
},
"owners": [
{
"name": "Sheryl Gavin",
"githubUsername": "shadowslasher410"
}
]
}
22 changes: 22 additions & 0 deletions types/node-bzip2/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "node16",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"node-bzip2": ["./index.d.ts"]
}
},
"files": [
"index.d.ts",
"node-bzip2-tests.ts"
]
}