Socket
Socket
Sign inDemoInstall

swissqrbill

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swissqrbill - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

4

CHANGELOG.md
# Change Log
# [v1.2.0](https://github.com/rogerrrrrrrs/swissqrbill/compare/v1.1.0...v1.2.0) - 06.06.2020
* Added optional callback function that gets executed once the pdf file has completed writing.
* Emit finish event once the pdf file has completed writing.
# [v1.1.0](https://github.com/rogerrrrrrrs/swissqrbill/compare/v1.0.6...v1.1.0) - 15.03.2020

@@ -5,0 +9,0 @@ * Fixed some validation checks

@@ -111,2 +111,3 @@ /// <reference types="pdfkit" />

* @param {options} [options] object containing settings, optional.
* @param {callback} [function] function that gets called right after the pdf has been created.
* @memberof PDF

@@ -116,2 +117,4 @@ * @returns an instance of SwissQRBill.PDF

constructor(data: data, outputPath: string, options?: options);
constructor(data: data, outputPath: string, options?: options, callback?: Function);
constructor(data: data, outputPath: string, callback?: Function);
/**

@@ -118,0 +121,0 @@ * Adds a new page

31

lib/index.js

@@ -13,12 +13,3 @@ "use strict";

class PDF extends extended_pdf_1.default.PDF {
/**
* Creates a new PDF.
*
* @param {data} data object containing all relevant billing data.
* @param {string} outputPath string output path for the generated PDF file.
* @param {options} [options] object containing settings, optional.
* @memberof PDF
* @returns an instance of SwissQRBill.PDF
*/
constructor(data, outputPath, options) {
constructor(data, outputPath, optionsOrCallback, callbackOrUndefined) {
super({ autoFirstPage: false });

@@ -31,3 +22,21 @@ this.size = "A6/5";

this._referenceType = "NON";
super.pipe(fs_1.default.createWriteStream(outputPath));
const stream = fs_1.default.createWriteStream(outputPath);
super.pipe(stream);
let callback = undefined;
let options = undefined;
if (typeof optionsOrCallback === "object") {
options = optionsOrCallback;
if (typeof callbackOrUndefined === "function") {
callback = callbackOrUndefined;
}
}
else if (typeof optionsOrCallback === "function") {
callback = optionsOrCallback;
}
stream.on("finish", ev => {
if (typeof callback === "function") {
callback(this);
}
super.emit("finish", ev);
});
if (data === undefined || typeof data !== "object") {

@@ -34,0 +43,0 @@ throw new Error("You must provide an object as billing data.");

{
"name": "swissqrbill",
"version": "1.1.0",
"version": "1.2.0",
"description": "Swiss QR Bill generation in node.js ",

@@ -37,3 +37,3 @@ "main": "./lib/index.js",

"@types/iban": "0.0.30",
"@types/node": "^13.7.7",
"@types/node": "^14.0.0",
"@types/pdfkit": "^0.10.5",

@@ -43,4 +43,4 @@ "@types/qrcode": "^1.3.4",

"@types/svg-parser": "^2.0.1",
"@typescript-eslint/eslint-plugin": "^2.21.0",
"@typescript-eslint/parser": "^2.21.0",
"@typescript-eslint/eslint-plugin": "^2.24.0",
"@typescript-eslint/parser": "^2.24.0",
"eslint": "^6.8.0",

@@ -47,0 +47,0 @@ "typescript": "^3.8.3"

# SwissQRBill
![MIT License](https://img.shields.io/npm/l/swissqrbill?color=brightgreen)
![Dependencies](https://img.shields.io/david/rogerrrrrrrs/swissqrbill)
![Downloads](https://img.shields.io/npm/dw/swissqrbill)
![Issues](https://img.shields.io/github/issues-raw/rogerrrrrrrs/swissqrbill)
![Version](https://img.shields.io/npm/v/swissqrbill?color=brightgreen)
![CI](https://github.com/Rogerrrrrrrs/SwissQRBill/workflows/CI/badge.svg?branch=development)
<a href="https://github.com/Rogerrrrrrrs/SwissQRBill/blob/master/LICENSE">
<img alt="MIT License" src="https://img.shields.io/npm/l/swissqrbill?color=brightgreen">
</a>
<a href="https://www.npmjs.com/package/swissqrbill">
<img alt="Version" src="https://img.shields.io/npm/v/swissqrbill?color=brightgreen">
</a>
<a href="https://github.com/Rogerrrrrrrs/SwissQRBill/issues">
<img alt="Issues" src="https://img.shields.io/github/issues-raw/rogerrrrrrrs/swissqrbill">
</a>
<a href="https://www.npmjs.com/package/swissqrbill">
<img alt="Dependencies" src="https://img.shields.io/david/rogerrrrrrrs/swissqrbill">
</a>
<a href="https://www.npmjs.com/package/swissqrbill">
<img alt="Downloads" src="https://img.shields.io/npm/dw/swissqrbill">
</a>
<a href="https://github.com/Rogerrrrrrrs/SwissQRBill/actions?query=workflow%3ACI">
<img alt="CI" src="https://github.com/Rogerrrrrrrs/SwissQRBill/workflows/CI/badge.svg?branch=development">
</a>

@@ -43,3 +55,3 @@ With SwissQRBill you can easily generate the new QR Code payment slips that will be introduced in Switzerland on June 30, 2020.

It's quite easy to create a simple QR bill. All you have to do is create a new `SwissQRBill.PDF` instance and pass our data as first parameter and our output path as second parameter.
It's quite easy to create a simple QR bill. All you have to do is create a new `SwissQRBill.PDF` instance and pass your billing data object as the first parameter and your output path as the second parameter.

@@ -70,7 +82,9 @@ ```js

const pdf = new SwissQRBill.PDF(data, "qrbill.pdf");
const pdf = new SwissQRBill.PDF(data, "qrbill.pdf", () => {
console.log("PDF has been successfully created.");
});
```
This will create the above PDF file. We can pass an optional third parameter that contains options like language or size etc.
Complete documentation for all methods and parameters can be found in [doc/api.md](https://github.com/Rogerrrrrrrs/SwissQRBill/blob/master/doc/api.md).
This will create the above PDF file. You can pass an optional third parameter containing options such as language or size etc. as well as a callback function that gets called right after the file has finished writing.
A complete documentation for all methods and parameters can be found in [doc/api.md](https://github.com/Rogerrrrrrrs/SwissQRBill/blob/master/doc/api.md).

@@ -77,0 +91,0 @@ <br/>

Sorry, the diff of this file is not supported yet

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