File tree Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -37,3 +37,16 @@ bwipjs.toBuffer({
37
37
// png.readUInt32BE(20) : PNG image height
38
38
}
39
39
} ) ;
40
+
41
+ // Browser canvas implementation
42
+ const canvas = document . createElement ( 'canvas' ) as HTMLCanvasElement ;
43
+ bwipjs ( canvas , {
44
+ bcid : 'qrcode' ,
45
+ text : 'example' ,
46
+ } , ( err ?: string | Error , cvs ?: HTMLCanvasElement ) : void => {
47
+ if ( err ) {
48
+ err ; // $ExpectType string | Error
49
+ } else if ( cvs ) {
50
+ cvs ; // $ExpectType HTMLCanvasElement
51
+ }
52
+ } ) ;
Original file line number Diff line number Diff line change 1
- // Type definitions for bwip-js 1.1.1
1
+ // Type definitions for bwip-js 1.7.3
2
2
// Project: https://github.com/metafloor/bwip-js
3
3
// Definitions by: TANAKA Koichi <https://github.com/MugeSo>
4
+ // Guillaume VanderEst <https://github.com/gvanderest>
4
5
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6
6
7
/// <reference types="node" />
@@ -80,4 +81,19 @@ declare namespace BwipJs {
80
81
81
82
declare function BwipJs ( req : Request , res : Response , opts ?:BwipJs . ToBufferOptions ) : void ;
82
83
84
+ /**
85
+ * The Browser version of the library's functionality, which makes use of an HTMLCanvasElement for rendering.
86
+ * @param canvas ID string or HTML element of the canvas to render within
87
+ * @param opts Options to use for rendering
88
+ * @param callback Function to execute when rendering has completed or failed
89
+ */
90
+ declare function BwipJs (
91
+ canvas : string | HTMLCanvasElement ,
92
+ opts :BwipJs . ToBufferOptions ,
93
+ callback : (
94
+ err : undefined | string | Error ,
95
+ canvas ?: HTMLCanvasElement ,
96
+ ) => void ,
97
+ ) : void ;
98
+
83
99
export = BwipJs ;
Original file line number Diff line number Diff line change 2
2
"compilerOptions" : {
3
3
"module" : " commonjs" ,
4
4
"lib" : [
5
- " es6"
5
+ " es6" ,
6
+ " dom"
6
7
],
7
8
"noImplicitAny" : true ,
8
9
"noImplicitThis" : true ,
20
21
" index.d.ts" ,
21
22
" bwip-js-tests.ts"
22
23
]
23
- }
24
+ }
You can’t perform that action at this time.
0 commit comments