diff --git a/barcode/barcode-tests.ts b/barcode/barcode-tests.ts new file mode 100644 index 0000000000..bb7b67187e --- /dev/null +++ b/barcode/barcode-tests.ts @@ -0,0 +1,22 @@ +/// +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!'); +}); \ No newline at end of file diff --git a/barcode/barcode.d.ts b/barcode/barcode.d.ts new file mode 100644 index 0000000000..5f4c6cfd8c --- /dev/null +++ b/barcode/barcode.d.ts @@ -0,0 +1,25 @@ +// Type definitions for barcode +// Project: https://github.com/samt/barcode +// Definitions by: Pascal Vomhoff +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +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; +}