mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
🤖 Merge PR #63307 Add types for ipp-printer by @mattsmithcode
* Add types for ipp-printer * Reshape ipp-printer types
This commit is contained in:
72
types/ipp-printer/index.d.ts
vendored
Normal file
72
types/ipp-printer/index.d.ts
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
// Type definitions for ipp-printer 1.0
|
||||
// Project: https://github.com/watson/ipp-printer
|
||||
// Definitions by: Matt Smith <https://github.com/mattsmithcode>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import * as http from 'http';
|
||||
import { Readable } from 'node:stream';
|
||||
|
||||
declare class Printer {
|
||||
constructor(opts?: Printer.Options | string);
|
||||
fallback: boolean;
|
||||
jobs: Printer.Job[];
|
||||
name: string;
|
||||
port: number;
|
||||
server: http.Server;
|
||||
started: Date;
|
||||
state: number;
|
||||
uri: string;
|
||||
|
||||
on(event: 'job', handler: (job: Printer.Job) => void): Printer;
|
||||
on(event: 'operation', handler: (operation: Printer.Operation) => void): Printer;
|
||||
}
|
||||
|
||||
declare namespace Printer {
|
||||
interface Attribute {
|
||||
name: string;
|
||||
tag: number;
|
||||
value: string | number | Date;
|
||||
}
|
||||
|
||||
interface AttributeGroup {
|
||||
attributes: Attribute[];
|
||||
tag: number;
|
||||
}
|
||||
|
||||
class Job extends Readable {
|
||||
compression: string;
|
||||
createdAt: Date;
|
||||
id: number;
|
||||
name: string;
|
||||
state: number;
|
||||
uri: string;
|
||||
userName: string;
|
||||
|
||||
attributes(filter?: ReadonlyArray<string>): Attribute[];
|
||||
pause(): this;
|
||||
resume(): this;
|
||||
setEncoding(encoding: BufferEncoding): this;
|
||||
unpipe(destination?: NodeJS.WritableStream): this;
|
||||
wrap(oldStream: NodeJS.ReadableStream): this;
|
||||
}
|
||||
|
||||
interface Operation {
|
||||
version: { major: number, minor: number };
|
||||
operationId: number;
|
||||
requestId: number;
|
||||
groups: AttributeGroup[];
|
||||
}
|
||||
|
||||
interface Options {
|
||||
fallback?: boolean;
|
||||
name?: string;
|
||||
port?: number;
|
||||
server?: http.Server;
|
||||
uri?: string;
|
||||
zeroconf?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export = Printer;
|
||||
19
types/ipp-printer/ipp-printer-tests.ts
Normal file
19
types/ipp-printer/ipp-printer-tests.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import * as Printer from 'ipp-printer';
|
||||
import * as fs from 'node:fs';
|
||||
|
||||
const printer = new Printer({
|
||||
port: 631
|
||||
});
|
||||
|
||||
printer.on('job', (job: Printer.Job) => {
|
||||
console.log('[job %d] Printing document: %s', job.id, job.name);
|
||||
|
||||
const filename = `job-${job.id}.ps`;
|
||||
const file = fs.createWriteStream(filename);
|
||||
|
||||
job.on('end', () => {
|
||||
console.log('[job %d] Document saved as %s', job.id, filename);
|
||||
});
|
||||
|
||||
job.pipe(file);
|
||||
});
|
||||
23
types/ipp-printer/tsconfig.json
Normal file
23
types/ipp-printer/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ipp-printer-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/ipp-printer/tslint.json
Normal file
1
types/ipp-printer/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "@definitelytyped/dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user