ciam-commons
Advanced tools
Comparing version 1.23.2 to 1.24.0
@@ -81,2 +81,3 @@ export interface DiscordUser { | ||
value: string; | ||
length: number; | ||
isWildcard: boolean; | ||
@@ -94,7 +95,11 @@ cooldown: number; | ||
} | ||
export declare class StrictFlag extends String { | ||
export declare class StrictFlag { | ||
value: string; | ||
length: number; | ||
keys: string[]; | ||
constructor(value: string); | ||
static validate(value: string | Flag | StrictFlag): StrictFlag; | ||
equals(other: StrictFlag | Flag): boolean; | ||
equals(other: Flag | StrictFlag): boolean; | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
@@ -101,0 +106,0 @@ export declare const flagArray: (perms: (string | Flag)[], ignoreInvalid?: boolean, removeDuplicate?: boolean) => Flag[]; |
@@ -48,2 +48,3 @@ export const isPermissionHolder = (value) => { | ||
value; | ||
length; | ||
isWildcard; | ||
@@ -58,2 +59,3 @@ cooldown; | ||
this.value = value; | ||
this.length = value.length; | ||
const parts = value.split(':'); | ||
@@ -80,3 +82,3 @@ this.isWildcard = parts[0] === '*' || parts[0].endsWith('.*'); | ||
equals(other) { | ||
return this.toString() === other.toString(); | ||
return this.value === other.value; | ||
} | ||
@@ -90,18 +92,29 @@ toString() { | ||
} | ||
export class StrictFlag extends String { | ||
export class StrictFlag { | ||
value; | ||
length; | ||
keys; | ||
constructor(value) { | ||
strictFlag(value); | ||
super(value); | ||
this.value = value; | ||
this.length = value.length; | ||
this.keys = value.split('.'); | ||
} | ||
static validate(value) { | ||
if (!(value instanceof StrictFlag)) { | ||
if (value instanceof Flag) | ||
return new StrictFlag(value.value); | ||
else if (value instanceof StrictFlag) | ||
return value; | ||
else | ||
return new StrictFlag(value); | ||
} | ||
return value; | ||
} | ||
equals(other) { | ||
return this.toString() === other.toString(); | ||
return this.value === other.value; | ||
} | ||
toString() { | ||
return this.value; | ||
} | ||
toJSON() { | ||
return this.value; | ||
} | ||
} | ||
@@ -108,0 +121,0 @@ export const flagArray = (perms, ignoreInvalid = false, removeDuplicate = true) => { |
{ | ||
"name": "ciam-commons", | ||
"version": "1.23.2", | ||
"version": "1.24.0", | ||
"description": "Common types and functions for CIAM", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
11089
313