Adding a "allowApi" property to authorize the API in a website.

This commit is contained in:
David Négrier 2021-07-23 23:06:59 +02:00
parent ce3c53ae3f
commit 5bb29e99ba
3 changed files with 46 additions and 0 deletions

View file

@ -8,6 +8,23 @@ export class PropertyUtils {
return properties?.find((property) => property.name === name)?.value;
}
public static findBooleanProperty(
name: string,
properties: ITiledMapProperty[] | undefined,
context?: string
): boolean | undefined {
const property = PropertyUtils.findProperty(name, properties);
if (property === undefined) {
return undefined;
}
if (typeof property !== "boolean") {
throw new Error(
'Expected property "' + name + '" to be a boolean. ' + (context ? " (" + context + ")" : "")
);
}
return property;
}
public static mustFindProperty(
name: string,
properties: ITiledMapProperty[] | undefined,