mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
Add typing for barcode
This commit is contained in:
22
barcode/barcode-tests.ts
Normal file
22
barcode/barcode-tests.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/// <reference path="barcode.d.ts" />
|
||||
import barcode = require('barcode');
|
||||
import path = require('path');
|
||||
|
||||
var code39 = barcode('code39', {
|
||||
data: "it works",
|
||||
width: 400,
|
||||
height: 100,
|
||||
});
|
||||
|
||||
code39.getStream(function (err, readStream) {
|
||||
if (err) throw err;
|
||||
|
||||
// 'readStream' is an instance of ReadableStream
|
||||
});
|
||||
|
||||
var outfile = path.join(__dirname, 'imgs', 'mycode.png');
|
||||
code39.saveImage(outfile, function (err) {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('File has been written!');
|
||||
});
|
||||
25
barcode/barcode.d.ts
vendored
Normal file
25
barcode/barcode.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// Type definitions for barcode
|
||||
// Project: https://github.com/samt/barcode
|
||||
// Definitions by: Pascal Vomhoff <https://github.com/pvomhoff>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "barcode" {
|
||||
|
||||
interface BarcodeOptions {
|
||||
data:string|number;
|
||||
width:number;
|
||||
height:number;
|
||||
}
|
||||
|
||||
interface BarcodeResult {
|
||||
getStream(callback:(err:NodeJS.ErrnoException, stream:NodeJS.ReadableStream) => void):void;
|
||||
saveImage(outputfilePath:string, callback:(err:NodeJS.ErrnoException) => void):void;
|
||||
getBase64(callback:(err:NodeJS.ErrnoException, base64String:string) => void):void;
|
||||
}
|
||||
|
||||
function barcode(type:string, options:BarcodeOptions):BarcodeResult;
|
||||
|
||||
export = barcode;
|
||||
}
|
||||
Reference in New Issue
Block a user