1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __assign = (this && this.__assign) || function () {
- __assign = Object.assign || function(t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
- t[p] = s[p];
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var QRCodeRaw_1 = require("./QRCodeRaw");
- var DEFAULT_OPTIONS = {
- blackSymbol: '▓▓',
- whiteSymbol: ' ',
- };
- var QRCodeText = /** @class */ (function (_super) {
- __extends(QRCodeText, _super);
- function QRCodeText(value, options) {
- if (options === void 0) { options = {}; }
- var _this = _super.call(this, value, options) || this;
- var params = __assign(__assign({}, DEFAULT_OPTIONS), options);
- _this.blackSymbol = params.blackSymbol;
- _this.whiteSymbol = params.whiteSymbol;
- return _this;
- }
- QRCodeText.prototype._clearCache = function () {
- _super.prototype._clearCache.call(this);
- this.qrCodeText = null;
- };
- QRCodeText.prototype.toString = function () {
- if (this.qrCodeText) {
- return this.qrCodeText;
- }
- var dataSize = this.getDataSize();
- if (!dataSize) {
- return null;
- }
- var data = this.getData();
- // FIXME eh?
- if (data === null) {
- return null;
- }
- var symbols = [];
- for (var y = 0; y < dataSize; y += 1) {
- for (var x = 0; x < dataSize; x += 1) {
- var isBlack = data[y][x];
- symbols.push(isBlack ? this.blackSymbol : this.whiteSymbol);
- }
- symbols.push('\n');
- }
- this.qrCodeText = symbols.join('');
- return this.qrCodeText;
- };
- return QRCodeText;
- }(QRCodeRaw_1.default));
- exports.default = QRCodeText;
|