Skip to content

Commit d51852d

Browse files
committed
Enhanced dontdraw option to have global effect so it works with composite symbols
1 parent 99083e3 commit d51852d

File tree

8 files changed

+21
-12
lines changed

8 files changed

+21
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ found at the end of this document.
2424
2525
## Status
2626

27-
* Current bwip-js version is 2.0.7 (2020-06-03)
27+
* Current bwip-js version is 2.0.8 (2020-06-25)
2828
* Current BWIPP version is 2019-11-08
2929
* Node.js compatibility: 0.12+
3030
* Browser compatibility: Edge, Firefox, Chrome

dist/bwip-js-min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/bwip-js.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33631,7 +33631,10 @@ BWIPJS.prototype.bbox = function(x0, y0, x1, y1) {
3363133631
};
3363233632
BWIPJS.prototype.render = function() {
3363333633
if (this.minx === Infinity) {
33634-
return callback(new Error('--empty-drawing-surface--'));
33634+
// Most likely, `dontdraw` was set in the options
33635+
return new Promise(function (resolve, reject) {
33636+
resolve(null);
33637+
});
3363533638
}
3363633639
// Draw the image
3363733640
this.drawing.init(this.maxx - this.minx + 1, this.maxy - this.miny + 1,
@@ -36227,7 +36230,7 @@ return {
3622736230
toCanvas:ToCanvas, render:Render, raw:Raw,
3622836231
fixupOptions:FixupOptions,
3622936232
loadFont:FontLib.loadFont,
36230-
VERSION:'2.0.7 (2020-06-03)',
36233+
VERSION:'2.0.8 (2020-06-25)',
3623136234

3623236235
// Internals
3623336236
BWIPJS:BWIPJS, BWIPP:BWIPP, STBTT:STBTT, FontLib:FontLib,

dist/node-bwipjs.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33665,7 +33665,10 @@ BWIPJS.prototype.bbox = function(x0, y0, x1, y1) {
3366533665
};
3366633666
BWIPJS.prototype.render = function() {
3366733667
if (this.minx === Infinity) {
33668-
return callback(new Error('--empty-drawing-surface--'));
33668+
// Most likely, `dontdraw` was set in the options
33669+
return new Promise(function (resolve, reject) {
33670+
resolve(null);
33671+
});
3366933672
}
3367033673
// Draw the image
3367133674
this.drawing.init(this.maxx - this.minx + 1, this.maxy - this.miny + 1,
@@ -36401,7 +36404,7 @@ return {
3640136404
request:Request, toBuffer:ToBuffer, render:Render, raw:Raw,
3640236405
fixupOptions:FixupOptions,
3640336406
loadFont:FontLib.loadFont,
36404-
VERSION:'2.0.7 (2020-06-03)',
36407+
VERSION:'2.0.8 (2020-06-25)',
3640536408

3640636409
// Internals
3640736410
BWIPJS:BWIPJS, BWIPP:BWIPP, STBTT:STBTT, FontLib:FontLib,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bwip-js",
3-
"version": "2.0.7",
3+
"version": "2.0.8",
44
"description": "JavaScript barcode generator supporting over 100 types and standards.",
55
"main": "./dist/node-bwipjs.js",
66
"browser": "./dist/bwip-js.js",

src/bwipjs.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,10 @@ BWIPJS.prototype.bbox = function(x0, y0, x1, y1) {
636636
};
637637
BWIPJS.prototype.render = function() {
638638
if (this.minx === Infinity) {
639-
return callback(new Error('--empty-drawing-surface--'));
639+
// Most likely, `dontdraw` was set in the options
640+
return new Promise(function (resolve, reject) {
641+
resolve(null);
642+
});
640643
}
641644
// Draw the image
642645
this.drawing.init(this.maxx - this.minx + 1, this.maxy - this.miny + 1,

src/bwipp-min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bwipp.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32724,7 +32724,7 @@ function BWIPP() {
3272432724
}
3272532725

3272632726
// Don't draw? (See file runtest)
32727-
$0.bwipjs_dontdraw = dontdraw || false;
32727+
$0.bwipjs_dontdraw = opts.dontdraw || dontdraw || false;
3272832728

3272932729
// Convert opts to a Map
3273032730
var map = new Map;
@@ -32741,7 +32741,7 @@ function BWIPP() {
3274132741
$0[encoder]();
3274232742

3274332743
// Return what is left on the stack. This branch should only be taken
32744-
// when running tests with the dontdraw option.
32744+
// when running with the dontdraw option.
3274532745
if ($j) {
3274632746
return $k.splice(0, $j);
3274732747
}

0 commit comments

Comments
 (0)