mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 18:25:24 +00:00
Removed barcodes autocompletion
This commit is contained in:
32
src/pass.ts
32
src/pass.ts
@@ -8,17 +8,14 @@ import * as schema from "./schema";
|
|||||||
import formatMessage from "./messages";
|
import formatMessage from "./messages";
|
||||||
import FieldsArray from "./fieldsArray";
|
import FieldsArray from "./fieldsArray";
|
||||||
import {
|
import {
|
||||||
assignLength, generateStringFile,
|
generateStringFile,
|
||||||
dateToW3CString, isValidRGB
|
dateToW3CString, isValidRGB
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
|
|
||||||
const barcodeDebug = debug("passkit:barcode");
|
const barcodeDebug = debug("passkit:barcode");
|
||||||
const genericDebug = debug("passkit:generic");
|
const genericDebug = debug("passkit:generic");
|
||||||
|
|
||||||
const noop = () => {};
|
|
||||||
const transitType = Symbol("transitType");
|
const transitType = Symbol("transitType");
|
||||||
const barcodesFillMissing = Symbol("bfm");
|
|
||||||
const barcodesSetBackward = Symbol("bsb");
|
|
||||||
|
|
||||||
interface PassIndexSignature {
|
interface PassIndexSignature {
|
||||||
[key: string]: any;
|
[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",
|
* Given an index <= the amount of already set "barcodes",
|
||||||
* this let you choose which structure to use for retrocompatibility
|
* this let you choose which structure to use for retrocompatibility
|
||||||
|
|||||||
10
src/utils.ts
10
src/utils.ts
@@ -80,13 +80,3 @@ export function generateStringFile(lang: { [index: string]: string }): Buffer {
|
|||||||
|
|
||||||
return Buffer.from(strings.join(EOL), "utf8");
|
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);
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user