Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bwip-js

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bwip-js - npm Package Compare versions

Comparing version 3.0.4 to 3.0.5

79

bin/bwip-js.js

@@ -8,3 +8,3 @@ #!/usr/bin/env node

function usage() {
function usage(exit) {
console.log(

@@ -19,2 +19,5 @@ "Usage: bwip-js symbol-name text [options...] png-file\n" +

"Try 'bwip-js --symbols' for a list of supported barcode symbols.\n");
if (exit) {
process.exit(1);
}
}

@@ -212,22 +215,20 @@ function help() {

var opts = {};
var argv = process.argv;
var pngfile;
if (process.argv.length < 5) {
usage();
process.exit(1);
if (argv.length > 2 && !/^(--|bcid=)/.test(argv[2])) {
argv[2] = 'bcid=' + argv[2];
}
if (!/bcid=/.test(process.argv[2])) {
process.argv[2] = 'bcid=' + process.argv[2];
if (argv.length > 3 && !/^(--|text=)/.test(argv[3])) {
argv[3] = 'text=' + argv[3];
}
if (!/text=/.test(process.argv[2])) {
process.argv[3] = 'text=' + process.argv[3];
if (argv.length > 4 && !/^(--|\w+=)/.test(argv[argv.length-1])) {
pngfile = argv.pop();
if (!/\.png$/.test(pngfile)) {
console.log("bwip-js: not a png-file: " + pngfile);
usage(true);
}
}
var pngfile = process.argv[process.argv.length-1];
if (!/\.png$/.test(pngfile)) {
console.log("bwip-js: missing png-file");
usage();
process.exit(1);
}
for (var i = 2, l = process.argv.length - 1; i < l; i++) {
var a = process.argv[i];
for (var i = 2, l = argv.length; i < l; i++) {
var a = argv[i];
if (/^--/.test(a)) {

@@ -257,25 +258,33 @@ a = a.substr(2);

if (process.argv.length == 2) {
usage();
} else if (opts.help) {
if (opts.help) {
help();
} else if (opts.version && !opts.bcid) {
console.log('bwip-js: ' + bwipjs.BWIPJS_VERSION + '\nBWIPP: ' + bwipjs.BWIPP_VERSION);
} else if (opts.symbols && !opts.bcid) {
} else if (opts.symbols) {
for (var sym in symdesc) {
console.log(' ' + sym + ' : ' + symdesc[sym]);
}
} else if (opts.version && !opts.bcid) {
console.log('bwip-js: ' + bwipjs.BWIPJS_VERSION + '\nBWIPP: ' + bwipjs.BWIPP_VERSION);
} else {
bwipjs.toBuffer(opts, function (err, png) {
if (err) {
console.error(''+err);
process.exit(1);
}
try {
fs.writeFileSync(pngfile, png);
} catch (e) {
console.log('bwip-js: ' + e);
}
});
if (!opts.bcid) {
console.log('bwip-js: missing bcid');
usage(true);
} else if (!opts.text) {
console.log('bwip-js: missing text');
usage(true);
} else if (!pngfile) {
console.log('bwip-js: missing pngfile');
usage(true);
} else {
bwipjs.toBuffer(opts, function (err, png) {
if (err) {
console.error(''+err);
process.exit(1);
}
try {
fs.writeFileSync(pngfile, png);
} catch (e) {
console.log('bwip-js: ' + e);
}
});
}
}

@@ -158,5 +158,7 @@ // bwip-js/examples/drawing-example.js

// `y` is the baseline.
//
// `font` is an object with properties { name, width, height, dx }
//
// `name` will be the same as the font name in `measure()`.
//
// `width` and `height` are the font cell size.

@@ -163,0 +165,0 @@ // `dx` is extra space requested between characters (usually zero).

{
"name": "bwip-js",
"version": "3.0.4",
"version": "3.0.5",
"description": "JavaScript barcode generator supporting over 100 types and standards.",

@@ -5,0 +5,0 @@ "main": "./dist/bwip-js-node.js",

@@ -20,3 +20,3 @@ # // Barcode Writer in Pure JavaScript

* Current bwip-js version is 3.0.4 (2021-08-05)
* Current bwip-js version is 3.0.5 (2022-05-22)
* Current BWIPP version is 2021-02-06

@@ -23,0 +23,0 @@ * Node.js compatibility: 0.12+

@@ -131,6 +131,6 @@ // file : bwipjs.js

// Postscript (like C) treats nul-char as end of string.
for (var i = 0, l = s.length; i < l && s[i]; i++);
if (i < l) {
return String.fromCharCode.apply(null,s.subarray(0, i));
}
//for (var i = 0, l = s.length; i < l && s[i]; i++);
//if (i < l) {
// return String.fromCharCode.apply(null,s.subarray(0, i));
//}
return String.fromCharCode.apply(null,s)

@@ -267,3 +267,3 @@ }

// The string can be either a uint8-string or regular string
str = this.jsstring(str);
str = this.toUCS2(this.jsstring(str));

@@ -617,3 +617,18 @@ var bbox = this.drawing.measure(str, this.g_font.FontName, size*tsx, size*tsy);

};
// UTF-8 to UCS-2 (no surrogates)
BWIPJS.prototype.toUCS2 = function(str) {
return str.replace(/[\xc0-\xdf][\x80-\xbf]|[\xe0-\xff][\x80-\xbf]{2}/g,
function(s) {
var code;
if (s.length == 2) {
code = ((s.charCodeAt(0)&0x1f)<<6)|
(s.charCodeAt(1)&0x3f);
} else {
code = ((s.charCodeAt(0)&0x0f)<<12)|
((s.charCodeAt(1)&0x3f)<<6)|
(s.charCodeAt(2)&0x3f);
}
return String.fromCharCode(code);
});
};
// dx,dy are inter-character gaps

@@ -636,4 +651,4 @@ BWIPJS.prototype.show = function(str, dx, dy) {

// The string can be either a uint8-string or regular string
str = this.jsstring(str);
// The string can be either a uint8-string or regular string.
str = this.toUCS2(this.jsstring(str));

@@ -640,0 +655,0 @@ // Convert dx,dy to device space

@@ -106,2 +106,6 @@ // fontlib.js

if (!glyph) {
glyph = STBTT.GetGlyph(font, 0, width * font.bwipjs_multx / 100,
height * font.bwipjs_multy / 100);
}
glyph.bytes = glyph.pixels;

@@ -108,0 +112,0 @@ glyph.cachekey = cachekey;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc