Removed barcodes autocompletion

This commit is contained in:
Alexander Cerutti
2019-06-29 18:15:07 +02:00
parent c5a8de4964
commit e4c39d837a
2 changed files with 1 additions and 41 deletions

View File

@@ -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<PassWithBarcodeMethods>(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

View File

@@ -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<Object<string, any>>} source - the main sources of properties
*/
export function assignLength<T>(length: number, ...sources: Array<{ [key: string]: any }>): { [key: string]: any } & T {
return Object.assign({ length }, ...sources);
}