From e4c39d837ae622b8c51e73915c020d89fea5fd8d Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Sat, 29 Jun 2019 18:15:07 +0200 Subject: [PATCH] Removed barcodes autocompletion --- src/pass.ts | 32 +------------------------------- src/utils.ts | 10 ---------- 2 files changed, 1 insertion(+), 41 deletions(-) diff --git a/src/pass.ts b/src/pass.ts index 61d6a6d..70dc932 100644 --- a/src/pass.ts +++ b/src/pass.ts @@ -8,17 +8,14 @@ import * as schema from "./schema"; import formatMessage from "./messages"; import FieldsArray from "./fieldsArray"; import { - assignLength, generateStringFile, + generateStringFile, dateToW3CString, isValidRGB } from "./utils"; const barcodeDebug = debug("passkit:barcode"); const genericDebug = debug("passkit:generic"); -const noop = () => {}; const transitType = Symbol("transitType"); -const barcodesFillMissing = Symbol("bfm"); -const barcodesSetBackward = Symbol("bsb"); interface PassIndexSignature { [key: string]: any; @@ -390,33 +387,6 @@ export class Pass implements PassIndexSignature { } } - /** - * Given an already compiled props["barcodes"] with missing objects - * (less than 4), takes infos from the first object and replicate them - * in the missing structures. - * - * @method Symbol/barcodesFillMissing - * @returns {this} Improved this, with length property and retroCompatibility method. - */ - - private [barcodesFillMissing](): PassWithBarcodeMethods { - const { barcodes } = this._props; - - if (barcodes.length === 4 || !barcodes.length) { - return assignLength(0, this, { - autocomplete: noop, - backward: (format: schema.BarcodeFormat) => this[barcodesSetBackward](format) - }); - } - - this._props["barcodes"] = barcodesFromUncompleteData(barcodes[0].message); - - return assignLength(4 - barcodes.length, this, { - autocomplete: noop, - backward: (format: schema.BarcodeFormat) => this[barcodesSetBackward](format) - }); - } - /** * Given an index <= the amount of already set "barcodes", * this let you choose which structure to use for retrocompatibility diff --git a/src/utils.ts b/src/utils.ts index ce613b1..2872955 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -80,13 +80,3 @@ export function generateStringFile(lang: { [index: string]: string }): Buffer { return Buffer.from(strings.join(EOL), "utf8"); } - -/** - * Creates a new object with custom length property - * @param {number} value - the length - * @param {Array>} source - the main sources of properties - */ - -export function assignLength(length: number, ...sources: Array<{ [key: string]: any }>): { [key: string]: any } & T { - return Object.assign({ length }, ...sources); -}