Socket
Socket
Sign inDemoInstall

bitgener

Package Overview
Dependencies
0
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.10 to 1.2.11

src/Barcode/Codabar.js

2

LICENSE.md
*Bitgener* is released under the MIT license.
Copyright (C) 2021 Adrien Valcke
Copyright (C) 2023 Elysium Phase

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

{
"name": "bitgener",
"version": "1.2.10",
"version": "1.2.11",
"description": "A lightweight and zero-dependencies pure Node.js barcode generator",
"author": "Adrien Valcke <adrienvalcke@icloud.com> (https://github.com/adrienv1520)",
"main": "lib/index.js",
"author": "Elysium Phase <hi@elysiumphase.com> (https://github.com/elysiumphase)",
"main": "src/index.js",
"private": false,

@@ -16,9 +16,8 @@ "preferGlobal": false,

"scripts": {
"test:lint": "eslint lib/",
"test:unit": "NODE_ENV=test mocha test/* --exit",
"test": "npm run test:lint && npm run test:unit"
"lint": "eslint src/",
"test": "NODE_ENV=test mocha test/* --exit"
},
"repository": {
"type": "git",
"url": "https://github.com/adrienv1520/bitgener.git"
"url": "https://github.com/elysiumphase/bitgener.git"
},

@@ -49,12 +48,11 @@ "keywords": [

"files": [
"lib"
"src"
],
"dependencies": {},
"devDependencies": {
"chai": "~4.3.4",
"eslint": "~7.28.0",
"eslint-config-airbnb-base": "~14.2.1",
"eslint-plugin-import": "~2.23.4",
"mocha": "~9.0.0"
"chai": "4.3.7",
"eslint": "8.42.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-plugin-import": "2.27.5",
"mocha": "10.2.0"
}
}

@@ -10,2 +10,4 @@ <p align="center">

# Table of Contents
- [Table of Contents](#table-of-contents)
- [Presentation](#presentation)

@@ -47,3 +49,3 @@ - [Bitgener Online Demo](#bitgener-online-demo)

SVGs generated by *Bitgener* uses crisp edges shape rendering to tell the user agent to turn off anti-aliasing to preserved the contrast, colors and edges without any smoothing or blurring that applies to images scaled up or down. Browsers support is nice and can be found here: https://caniuse.com/#feat=css-crisp-edges.
SVGs generated by *Bitgener* uses crisp edges shape rendering to tell the user agent to turn off anti-aliasing to preserved the contrast, colors and edges without any smoothing or blurring that applies to images scaled up or down. Browsers support is nice and can be found here: <https://caniuse.com/#feat=css-crisp-edges>.

@@ -75,6 +77,2 @@ The aim of this project is to provide a simple, lightweight, zero-dependencies and fast barcode generator and let user choose the external or native image processing library to transform the SVG generated into the specific format if needed.

Command to run all tests:
`npm test`
### Linting

@@ -84,3 +82,3 @@

`npm run test:lint`
`npm run lint`

@@ -91,3 +89,3 @@ ### Unit

`npm run test:unit`
`npm test`

@@ -97,2 +95,3 @@ # Supported symbologies

One dimension:
- Codabar

@@ -111,2 +110,3 @@ - Code 11

Two dimensions:
- DataMatrix (ECC 200 standard, square and rectangular)

@@ -128,110 +128,109 @@

- `options`**<Object\>**:
- `data`* **<String\>** The data to encode.
- `type`* **<String\>** The supported symbology in which data will be encoded.
- `codabar`: each character to encode must be one of *0123456789-$:/.+*
- `code11`: each character to encode must be one of *0123456789-*
- `code39`: each character to encode must be one of *0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*
- `code93`: each character to encode must be one of *0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*
- `code128`: each character to encode must be one of <i>!"#$%&'()*+,-./0123456789:;<=\>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~</i>
- `ean8`: data to encode must contain 7 numerical digits.
- `ean13`: data to encode must contain 12 numerical digits.
- `std25` (standard 2 of 5): data to encode must contain only numerical digits.
- `int25` (interleaved 2 of 5): data to encode must contain only numerical digits.
- `msi`: data to encode must contain only numerical digits.
- `upc`: data to encode must contain 11 numerical digits.
- `datamatrix`: data to encode has no restrictions.
- `output` **<String\>** The output format for the *svg* property of the object returned by this function. *Default*: `stream`
- `stream`: generated SVG tags as a Readable Stream.
- `string`: generated SVG tags as a string.
- `buffer`: generated SVG tags as a Buffer.
- `{path to a file}`: a valid path to a SVG file. The file will be created or overwritten, eg.: './docs/bitgener.svg'.
- `encoding` **<String\>** For stream, buffer and file outputs. *Default*: `utf8`
- `utf8`: multibyte encoded Unicode characters. Many web pages and other document formats use UTF-8.
- `ascii`: for 7-bit ASCII data only. This encoding is fast and will strip the high bit if set.
- `utf16le`: 2 or 4 bytes, little-endian encoded Unicode characters. Surrogate pairs (U+10000 to U+10FFFF) are supported.
- `ucs2`: alias of 'utf16le'.
- `base64`: base64 encoding. When creating a Buffer from a string, this encoding will also correctly accept "URL and Filename Safe Alphabet" as specified in RFC4648, Section 5.
- `latin1`: a way of encoding the Buffer into a one-byte encoded string (as defined by the IANA in RFC1345, page 63, to be the Latin-1 supplement block and C0/C1 control codes).
- `binary`: alias for 'latin1'.
- `hex`: encode each byte as two hexadecimal characters.
- `crc` **<Boolean\>** Cyclic redundancy check. For *code93*, *std25*, *int25* and *msi* barcode types. *Default*: `true`
- `rectangular` **<Boolean\>** For datamatrix only. *Default*: `false`
- `padding` **<Number\>** The space in pixels around one side of the barcode that will be applied for its 4 sides. *Default*: `0`
- `width` **<Number\>** The width in pixels to fix for the generated image. *Default*: `150`
- `height` **<Number\>** The height in pixels to fix for the generated image. *Default*: `150`
- `barWidth` **<Number\>** The bar width in pixels for 1D barcodes. *Default*: `1`
- `barHeight` **<Number\>** The bar height in pixels for 1D barcodes. *Default*: `50`
- `original1DSize` **<Boolean\>** If true keep the original 1D barcode size determined by barWidth and barHeight else apply the specified width and height sizes to the final image. *Default*: `false`
- `original2DSize` **<Boolean\>** For rectangular datamatrixes, if true keep the original 2D barcode size based on width else apply the specified width and height sizes to the final image. *Default*: `false`
- `addQuietZone` **<Boolean\>** Add a quiet zone at the end of 1D barcodes. *Default*: `true`
- `color` **<String\>** The bars and hri color. An hexadecimal value or one of these [generic names](lib/helpers/color.js). *Default*: `#000000`
- `opacity` **<Number\>** The bars and hri opacity. *Min*: `0` *Max*: `1` *Default*: `1`
- `bgColor` **<String\>** The background color. An hexadecimal value or one of these [generic names](lib/helpers/color.js). *Default*: `#FFFFFF`
- `bgOpacity` **<Number\>** The background opacity. *Min*: `0` *Max*: `1` *Default*: `1`
- `hri` **<Object\>** The human readable interpretation of the encoded data.
- `show` **<Boolean\>** *Default*: `true`
- `fontFamily` **<String\>** A generic font name based on [cssfontstack.com](cssfontstack.com) *Default*: `Arial`
- `Sans-serif`
- `Arial`
- `Arial Black`
- `Arial Narrow`
- `Arial Rounded MT Bold`
- `Avant Garde`
- `Calibri`
- `Candara`
- `Century Gothic`
- `Franklin Gothic Medium`
- `Futura`
- `Geneva`
- `Gill Sans`
- `Helvetica`
- `Impact`
- `Lucida Grande`
- `Optima`
- `Segoe UI`
- `Tahoma`
- `Trebuchet MS`
- `Verdana`
- `Serif`
- `Bodoni MT`
- `Book Antiqua`
- `Calisto MT`
- `Cambria`
- `Didot`
- `Garamond`
- `Goudy Old Style`
- `Lucida Bright`
- `Palatino`
- `Perpetua`
- `Rockwell`
- `Rockwell Extra Bold`
- `Baskerville`
- `Times New Roman`
- `Consolas`
- `Courier New`
- `Lucida Console`
- `Lucida Sans Typewriter`
- `Monaco`
- `Andale Mono`
- `Copperlate`
- `Papyrus`
- `Brush Script MT`
- `fontSize` **<Number\>** The font size in pixels. *Default*: `10`
- `marginTop` **<Number\>** The margin size in pixels between the barcode bottom and the hri text. *Default*: `0`
- `options`**<Object\>**:
- `data`* **<String\>** The data to encode.
- `type`* **<String\>** The supported symbology in which data will be encoded.
- `codabar`: each character to encode must be one of *0123456789-$:/.+*
- `code11`: each character to encode must be one of *0123456789-*
- `code39`: each character to encode must be one of *0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*
- `code93`: each character to encode must be one of *0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*
- `code128`: each character to encode must be one of <i>!"#$%&'()*+,-./0123456789:;<=\>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~</i>
- `ean8`: data to encode must contain 7 numerical digits.
- `ean13`: data to encode must contain 12 numerical digits.
- `std25` (standard 2 of 5): data to encode must contain only numerical digits.
- `int25` (interleaved 2 of 5): data to encode must contain only numerical digits.
- `msi`: data to encode must contain only numerical digits.
- `upc`: data to encode must contain 11 numerical digits.
- `datamatrix`: data to encode has no restrictions.
- `output` **<String\>** The output format for the *svg* property of the object returned by this function. *Default*: `stream`
- `stream`: generated SVG tags as a Readable Stream.
- `string`: generated SVG tags as a string.
- `buffer`: generated SVG tags as a Buffer.
- `{path to a file}`: a valid path to a SVG file. The file will be created or overwritten, eg.: './docs/bitgener.svg'.
- `encoding` **<String\>** For stream, buffer and file outputs. *Default*: `utf8`
- `utf8`: multibyte encoded Unicode characters. Many web pages and other document formats use UTF-8.
- `ascii`: for 7-bit ASCII data only. This encoding is fast and will strip the high bit if set.
- `utf16le`: 2 or 4 bytes, little-endian encoded Unicode characters. Surrogate pairs (U+10000 to U+10FFFF) are supported.
- `ucs2`: alias of 'utf16le'.
- `base64`: base64 encoding. When creating a Buffer from a string, this encoding will also correctly accept "URL and Filename Safe Alphabet" as specified in RFC4648, Section 5.
- `latin1`: a way of encoding the Buffer into a one-byte encoded string (as defined by the IANA in RFC1345, page 63, to be the Latin-1 supplement block and C0/C1 control codes).
- `binary`: alias for 'latin1'.
- `hex`: encode each byte as two hexadecimal characters.
- `crc` **<Boolean\>** Cyclic redundancy check. For *code93*, *std25*, *int25* and *msi* barcode types. *Default*: `true`
- `rectangular` **<Boolean\>** For datamatrix only. *Default*: `false`
- `padding` **<Number\>** The space in pixels around one side of the barcode that will be applied for its 4 sides. *Default*: `0`
- `width` **<Number\>** The width in pixels to fix for the generated image. *Default*: `150`
- `height` **<Number\>** The height in pixels to fix for the generated image. *Default*: `150`
- `barWidth` **<Number\>** The bar width in pixels for 1D barcodes. *Default*: `1`
- `barHeight` **<Number\>** The bar height in pixels for 1D barcodes. *Default*: `50`
- `original1DSize` **<Boolean\>** If true keep the original 1D barcode size determined by barWidth and barHeight else apply the specified width and height sizes to the final image. *Default*: `false`
- `original2DSize` **<Boolean\>** For rectangular datamatrixes, if true keep the original 2D barcode size based on width else apply the specified width and height sizes to the final image. *Default*: `false`
- `addQuietZone` **<Boolean\>** Add a quiet zone at the end of 1D barcodes. *Default*: `true`
- `color` **<String\>** The bars and hri color. An hexadecimal value or one of these [generic names](lib/helpers/color.js). *Default*: `#000000`
- `opacity` **<Number\>** The bars and hri opacity. *Min*: `0` *Max*: `1` *Default*: `1`
- `bgColor` **<String\>** The background color. An hexadecimal value or one of these [generic names](lib/helpers/color.js). *Default*: `#FFFFFF`
- `bgOpacity` **<Number\>** The background opacity. *Min*: `0` *Max*: `1` *Default*: `1`
- `hri` **<Object\>** The human readable interpretation of the encoded data.
- `show` **<Boolean\>** *Default*: `true`
- `fontFamily` **<String\>** A generic font name based on [cssfontstack.com](cssfontstack.com) *Default*: `Arial`
- `Sans-serif`
- `Arial`
- `Arial Black`
- `Arial Narrow`
- `Arial Rounded MT Bold`
- `Avant Garde`
- `Calibri`
- `Candara`
- `Century Gothic`
- `Franklin Gothic Medium`
- `Futura`
- `Geneva`
- `Gill Sans`
- `Helvetica`
- `Impact`
- `Lucida Grande`
- `Optima`
- `Segoe UI`
- `Tahoma`
- `Trebuchet MS`
- `Verdana`
- `Serif`
- `Bodoni MT`
- `Book Antiqua`
- `Calisto MT`
- `Cambria`
- `Didot`
- `Garamond`
- `Goudy Old Style`
- `Lucida Bright`
- `Palatino`
- `Perpetua`
- `Rockwell`
- `Rockwell Extra Bold`
- `Baskerville`
- `Times New Roman`
- `Consolas`
- `Courier New`
- `Lucida Console`
- `Lucida Sans Typewriter`
- `Monaco`
- `Andale Mono`
- `Copperlate`
- `Papyrus`
- `Brush Script MT`
- `fontSize` **<Number\>** The font size in pixels. *Default*: `10`
- `marginTop` **<Number\>** The margin size in pixels between the barcode bottom and the hri text. *Default*: `0`
- Returns: **<Promise\>**
- Resolve: **<Object\>**
- `width` **<Number\>** The final image width.
- `height` **<Number\>** The final image height.
- `density` **<Number\>** The number of pixels per inch (DPI) calculated as optimized.
- `type` **<String\>** The symbology used.
- `data` **<String\>** The data encoded.
- `hri` **<String\>** The human readable interpretation of the encoded data.
- `output` **<String\>** The effective output option used.
- `encoding` **<String\>** The encoding format used.
- `svg` **<Readable\>** | **<String\>** | **<Buffer\>** The SVG tags of the generated SVG image. In case the ouput is a file, this field contains the SVG tags in a string format.
- Throws: **<DataError\>** | **<BarcodeTypeError\>** | **<OutputError\>**
- Returns: **<Promise\>**
- Resolve: **<Object\>**
- `width` **<Number\>** The final image width.
- `height` **<Number\>** The final image height.
- `density` **<Number\>** The number of pixels per inch (DPI) calculated as optimized.
- `type` **<String\>** The symbology used.
- `data` **<String\>** The data encoded.
- `hri` **<String\>** The human readable interpretation of the encoded data.
- `output` **<String\>** The effective output option used.
- `encoding` **<String\>** The encoding format used.
- `svg` **<Readable\>** | **<String\>** | **<Buffer\>** The SVG tags of the generated SVG image. In case the ouput is a file, this field contains the SVG tags in a string format.
- Throws: **<DataError\>** | **<BarcodeTypeError\>** | **<OutputError\>**
### Examples

@@ -243,3 +242,3 @@

##### 1D barcode
#### 1D barcode

@@ -281,3 +280,3 @@ ```javascript

##### 2D barcode
#### 2D barcode

@@ -318,3 +317,3 @@ ```javascript

##### Full example using Sharp
#### Full example using Sharp

@@ -327,3 +326,3 @@ ```javascript

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

@@ -423,7 +422,8 @@ const pipeline = promisify(stream.pipeline);

**DEBUG** is used to whether debug a specific module. *DEBUG* value can be a **comma-separated string** listing module names to debug or to avoid debugging. Format is: `DEBUG=moduleName[,moduleName]`
- `DEBUG=moduleName` will debug *moduleName* module;
- `DEBUG=moduleName:*` will debug *moduleName* module and sub modules;
- `DEBUG=-moduleName:*` will disable debugging any *moduleName* module and sub modules;
- `DEBUG=*` will debug all *moduleName* module and sub modules plus other modules used in your project if they use a debugger similar to __[bugbug](https://github.com/adrienv1520/bugbug)__ embed in this module.
- `DEBUG=moduleName` will debug *moduleName* module;
- `DEBUG=moduleName:*` will debug *moduleName* module and sub modules;
- `DEBUG=-moduleName:*` will disable debugging any *moduleName* module and sub modules;
- `DEBUG=*` will debug all *moduleName* module and sub modules plus other modules used in your project if they use a debugger similar to __[bugbug](https://github.com/elysiumphase/bugbug)__ embed in this module.
Example: `DEBUG=bitgener:*`

@@ -464,3 +464,3 @@

<td>The data to encode is missing.</td>
<td>lib/index</td>
<td>src/index</td>
</tr>

@@ -471,3 +471,3 @@

<td>The data to encode is empty.</td>
<td>lib/index</td>
<td>src/index</td>
</tr>

@@ -478,3 +478,3 @@

<td>The data to encode doesn't require the prerequisites.</td>
<td>lib/index<br />lib/Barcode/</td>
<td>src/index<br />src/Barcode/</td>
</tr>

@@ -489,3 +489,3 @@

<td>The symbology supported is missing.</td>
<td>lib/index</td>
<td>src/index</td>
</tr>

@@ -496,3 +496,3 @@

<td>The symbology is not one of those supported.</td>
<td>lib/index</td>
<td>src/index</td>
</tr>

@@ -507,3 +507,3 @@

<td>The output is not one of those supported. If the ouput is a path to a file make sure that the path is valid.</td>
<td>lib/helpers/output</td>
<td>src/helpers/output</td>
</tr>

@@ -518,3 +518,3 @@

<td>The barcode generator returned no digit and cannot generate svg tags.</td>
<td>lib/Barcode/index</td>
<td>src/Barcode/index</td>
</tr>

@@ -529,3 +529,3 @@

<td>Internal failure or invalid chunk of data pushed on readable stream.</td>
<td>lib/helpers/output</td>
<td>src/helpers/output</td>
</tr>

@@ -540,3 +540,3 @@

<td>Internal failure writing or piping data on writable stream.</td>
<td>lib/helpers/output</td>
<td>src/helpers/output</td>
</tr>

@@ -556,5 +556,7 @@

# Code of Conduct
This project has a [Code of Conduct](.github/CODE_OF_CONDUCT.md). By interacting with this repository, organization, or community you agree to abide by its terms.
# Contributing
Please have a look at our [TODO](TODO.md) for any work in progress.

@@ -565,8 +567,11 @@

# Support
Please see our [Support](.github/SUPPORT.md) page if you have any questions or for any help needed.
# Security
For any security concerns or issues, please visit our [Security Policy](.github/SECURITY.md) page.
# License
[MIT](LICENSE.md).
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc