Socket
Socket
Sign inDemoInstall

bitgener

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitgener - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

doc/examples/bitgener.svg

5

CHANGELOG.md
# CHANGELOG
## 1.1.4 - delivery @03/01/2020
- update doc examples
- update readme
## 1.1.3 - delivery @27/12/2019

@@ -4,0 +9,0 @@

2

doc/examples/1d.js

@@ -27,4 +27,2 @@ const bitgener = require('../../lib');

console.log(ret);
// shows
} catch (e) {

@@ -31,0 +29,0 @@ console.error(e.toString());

@@ -0,1 +1,2 @@

const path = require('path');
const bitgener = require('../../lib');

@@ -8,3 +9,3 @@

type: 'datamatrix',
output: 'bitgener.svg',
output: path.join(__dirname, 'bitgener.svg'),
encoding: 'utf8',

@@ -27,4 +28,2 @@ rectangular: true,

console.log(ret);
// shows
} catch (e) {

@@ -31,0 +30,0 @@ console.error(e.toString());

@@ -0,6 +1,9 @@

const stream = require('stream');
const { createWriteStream } = require('fs');
const path = require('path');
const { promisify } = require('util');
const sharp = require('sharp');
const bitgener = require('../../lib');
const wstream = createWriteStream('sharp.png');
const pipeline = promisify(stream.pipeline);

@@ -10,12 +13,15 @@ /**

* into the specified format and get the specified output.
* Please note that no verification is made in this function.
* @param {Buffer} buffer The buffer generated by Bitgener.
* @param {Number} density The density needed to resize the image with no
* image quality loss.
* @param {String} format Format could be one of png, jpeg,
* webp, tiff, raw supported by Sharp.
* @param {String} method Method could be one of toFile, toBuffer,
* or a Readable Stream returned by default by Sharp.
* @return {Promise} A Readable Stream, a Buffer, ... depending on
* the method.
*
* Please note that no type/value checks are made in this function.
*
* @param {Buffer} buffer The buffer generated by Bitgener.
* @param {Number} density The density needed to resize the image with no
* image quality loss.
* @param {String} format Format could be one of png, jpeg,
* webp, tiff, raw supported by Sharp.
* @param {String} method Method could be one of toFile, toBuffer,
* or a Readable Stream returned by default by Sharp.
* @param {String} filePath Path to write the image data to. If set, method is not required.
* @return {Promise} A Readable Stream by default, a Buffer,
* a Sharp info object depending on the method.
*/

@@ -27,3 +33,3 @@ const convert = async function convert({

method,
file,
filePath,
} = {}) {

@@ -34,4 +40,5 @@ // sharp it!

if (method === 'toFile') {
ret = await sharped.toFile(file);
if (method === 'toFile' || filePath !== undefined) {
ret = await sharped.toFile(filePath);
// object returned by sharp: https://sharp.pixelplumbing.com/en/stable/api-output/#tofile
} else if (method === 'toBuffer') {

@@ -50,2 +57,3 @@ ret = sharped.toFormat(format).toBuffer();

try {
const wstream = createWriteStream(path.join(__dirname, 'sharped.png'));
const {

@@ -80,5 +88,6 @@ svg: buffer,

rstream.pipe(wstream);
// listen to rstream and wstream error events ;)
// listen to rstream and wstream events ;)
// use pipeline to automatically clean up streams or you're exposing your code to memory leaks
await pipeline(rstream, wstream);

@@ -85,0 +94,0 @@ // ...

{
"name": "bitgener",
"version": "1.1.3",
"version": "1.1.4",
"description": "A lightweight and zero-dependencies pure Node.js barcode library",

@@ -5,0 +5,0 @@ "author": "Adrien Valcke",

<p align="center">
<img src="doc/bitgener.svg" alt="Bitgener" style="border-radius:50%"/>
<img src="doc/examples/bitgener.svg" alt="Bitgener" style="border-radius:50%"/>
<p>

@@ -193,2 +193,4 @@

You can find these examples here: [doc/examples](doc/examples)
In these examples please prefer a well-known and tested asynchronous logger over the use of *console* module.

@@ -268,18 +270,27 @@

```javascript
const stream = require('stream');
const { createWriteStream } = require('fs');
const path = require('path');
const { promisify } = require('util');
const sharp = require('sharp');
const bitgener = require('bitgener');
const bitgener = require('../../lib');
const pipeline = promisify(stream.pipeline);
/**
* Generic function to convert the svg generated from Bitgener
* into the specified format and get the specified output.
* Please note that no verification is made in this function.
* @param {Buffer} buffer The buffer generated by Bitgener.
* @param {Number} density The density needed to resize the image with no
* image quality loss.
* @param {String} format Format could be one of png, jpeg,
* webp, tiff, raw supported by Sharp.
* @param {String} method Method could be one of toFile, toBuffer,
* or a Readable Stream returned by default by Sharp.
* @return {Promise} A Readable Stream, a Buffer, ... depending on
* the method.
*
* Please note that no type/value checks are made in this function.
*
* @param {Buffer} buffer The buffer generated by Bitgener.
* @param {Number} density The density needed to resize the image with no
* image quality loss.
* @param {String} format Format could be one of png, jpeg,
* webp, tiff, raw supported by Sharp.
* @param {String} method Method could be one of toFile, toBuffer,
* or a Readable Stream returned by default by Sharp.
* @param {String} filePath Path to write the image data to. If set, method is not required.
* @return {Promise} A Readable Stream by default, a Buffer,
* a Sharp info object depending on the method.
*/

@@ -291,3 +302,3 @@ const convert = async function convert({

method,
file,
filePath,
} = {}) {

@@ -298,4 +309,5 @@ // sharp it!

if (method === 'toFile') {
ret = await sharped.toFile(file);
if (method === 'toFile' || filePath !== undefined) {
ret = await sharped.toFile(filePath);
// object returned by sharp: https://sharp.pixelplumbing.com/en/stable/api-output/#tofile
} else if (method === 'toBuffer') {

@@ -314,7 +326,3 @@ ret = sharped.toFormat(format).toBuffer();

try {
const stream = require('stream');
const { promisify } = require('util');
const wstream = stream.createWriteStream('sharped.png');
const pipeline = promisify(stream.pipeline);
const wstream = createWriteStream(path.join(__dirname, 'sharped.png'));
const {

@@ -321,0 +329,0 @@ svg: buffer,

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