From 9565bf09444dbeefdad975ab44bd48c21c4095a2 Mon Sep 17 00:00:00 2001 From: nuts-n-bits Date: Tue, 10 Dec 2019 12:56:20 -0500 Subject: [PATCH] update beacon and location methods to use overload Signed-off-by: nuts-n-bits --- src/pass.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/pass.ts b/src/pass.ts index c4c8c64..69582c0 100644 --- a/src/pass.ts +++ b/src/pass.ts @@ -281,17 +281,19 @@ export class Pass { /** * Sets current pass' relevancy through beacons - * @param data + * @param data varargs with type schema.Beacon, or single arg null * @returns {Pass} */ - beacons(...data: schema.Beacon[] | null): this { - if (data === null) { + beacons(resetFlag: null): this; + beacons(...data: schema.Beacon[]): this + beacons(...args: (schema.Beacon|null)[]){ + if (args[0] === null) { delete this[passProps]["beacons"]; return this; } - const valid = processRelevancySet("beacons", data); + const valid = processRelevancySet("beacons", args); if (valid.length) { this[passProps]["beacons"] = valid; @@ -302,17 +304,19 @@ export class Pass { /** * Sets current pass' relevancy through locations - * @param data + * @param data varargs with type schema.Location, or single arg null * @returns {Pass} */ - locations(...data: schema.Location[] | null): this { - if (data === null) { + locations(resetFlag : null) : this; + locations(...data: schema.Location[]): this; + locations(...args: (schema.Location|null)[]) : this { + if (args[0] === null) { delete this[passProps]["locations"]; return this; } - const valid = processRelevancySet("locations", data); + const valid = processRelevancySet("locations", args); if (valid.length) { this[passProps]["locations"] = valid;