Socket
Socket
Sign inDemoInstall

qrcode-terminal

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qrcode-terminal - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

example/small-qrcode.js

78

lib/main.js

@@ -14,2 +14,9 @@ var QRCode = require('./../vendor/QRCode'),

};
},
fill = function(length, value) {
var arr = new Array(length);
for (var i = 0; i < length; i++) {
arr[i] = value;
}
return arr;
};

@@ -21,3 +28,8 @@

generate: function (input, cb) {
generate: function (input, opts, cb) {
if (typeof opts === 'function') {
cb = opts;
opts = {};
}
var qrcode = new QRCode(-1, this.error);

@@ -27,13 +39,57 @@ qrcode.addData(input);

var output = '',
border = repeat(white).times(qrcode.getModuleCount() + 3);
var output = '';
if (opts && opts.small) {
var BLACK = true, WHITE = false;
var moduleCount = qrcode.getModuleCount();
var moduleData = qrcode.modules.slice();
output += border + '\n';
qrcode.modules.forEach(function (row) {
output += white;
output += row.map(toCell).join('');
output += white + '\n';
});
output += border;
var oddRow = moduleCount % 2 === 1;
if (oddRow) {
moduleData.push(fill(moduleCount, WHITE));
}
var platte= {
WHITE_ALL: '\u2588',
WHITE_BLACK: '\u2580',
BLACK_WHITE: '\u2584',
BLACK_ALL: ' ',
};
var borderTop = repeat(platte.BLACK_WHITE).times(moduleCount + 3);
var borderBottom = repeat(platte.WHITE_BLACK).times(moduleCount + 3);
output += borderTop + '\n';
for (var row = 0; row < moduleCount; row += 2) {
output += platte.WHITE_ALL;
for (var col = 0; col < moduleCount; col++) {
if (moduleData[row][col] === WHITE && moduleData[row + 1][col] === WHITE) {
output += platte.WHITE_ALL;
} else if (moduleData[row][col] === WHITE && moduleData[row + 1][col] === BLACK) {
output += platte.WHITE_BLACK;
} else if (moduleData[row][col] === BLACK && moduleData[row + 1][col] === WHITE) {
output += platte.BLACK_WHITE;
} else {
output += platte.BLACK_ALL;
}
}
output += platte.WHITE_ALL + '\n';
}
if (!oddRow) {
output += borderBottom;
}
} else {
var border = repeat(white).times(qrcode.getModuleCount() + 3);
output += border + '\n';
qrcode.modules.forEach(function (row) {
output += white;
output += row.map(toCell).join('');
output += white + '\n';
});
output += border;
}
if (cb) cb(output);

@@ -44,5 +100,5 @@ else console.log(output);

setErrorLevel: function (error) {
this.error = QRErrorCorrectLevel[error] || this.error;
this.error = QRErrorCorrectLevel[error] || this.error;
}
};

2

package.json
{
"name": "qrcode-terminal",
"keywords": ["ansi", "ascii", "qrcode", "console"],
"version" : "0.10.0",
"version" : "0.11.0",
"description" : "QRCodes, in the terminal",

@@ -6,0 +6,0 @@ "homepage": "https://github.com/gtanner/qrcode-terminal",

@@ -36,2 +36,10 @@ # QRCode Terminal Edition [![Build Status][travis-ci-img]][travis-ci-url]

If you want to display small output, provide `opts` with `small`:
qrcode.generate('This will be a small QRCode, eh!', {small: true});
qrcode.generate('This will be a small QRCode, eh!', {small: true}, function (qrcode) {
console.log(qrcode)
});
# Command-Line

@@ -38,0 +46,0 @@

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