@ztimson/utils 0.28.4 → 0.28.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/errors.d.ts CHANGED
@@ -43,6 +43,11 @@ export declare class NotAcceptableError extends CustomError {
43
43
  constructor(message?: string);
44
44
  static instanceof(err: Error): boolean;
45
45
  }
46
+ export declare class TooManyRequestsError extends CustomError {
47
+ static code: number;
48
+ constructor(message?: string);
49
+ static instanceof(err: Error): boolean;
50
+ }
46
51
  export declare class InternalServerError extends CustomError {
47
52
  static code: number;
48
53
  constructor(message?: string);
package/dist/index.cjs CHANGED
@@ -1507,6 +1507,15 @@ ${opts.message || this.desc}`;
1507
1507
  return err.constructor.code == this.code;
1508
1508
  }
1509
1509
  }
1510
+ class TooManyRequestsError extends CustomError {
1511
+ static code = 429;
1512
+ constructor(message = "Rate Limit Reached") {
1513
+ super(message);
1514
+ }
1515
+ static instanceof(err) {
1516
+ return err.constructor.code == this.code;
1517
+ }
1518
+ }
1510
1519
  class InternalServerError extends CustomError {
1511
1520
  static code = 500;
1512
1521
  constructor(message = "Internal Server Error") {
@@ -1888,6 +1897,8 @@ ${opts.message || this.desc}`;
1888
1897
  module;
1889
1898
  /** Entire path, including the module & name */
1890
1899
  fullPath;
1900
+ /** Parent directory, excludes module & name */
1901
+ dir;
1891
1902
  /** Path including the name, excluding the module */
1892
1903
  path;
1893
1904
  /** Last segment of path */
@@ -1965,6 +1976,7 @@ ${opts.message || this.desc}`;
1965
1976
  if (p === "" || p === void 0 || p === "*") {
1966
1977
  this.module = "";
1967
1978
  this.path = "";
1979
+ this.dir = "";
1968
1980
  this.fullPath = "**";
1969
1981
  this.name = "";
1970
1982
  this.methods = new ASet(p === "*" ? ["*"] : method.split(""));
@@ -1975,6 +1987,7 @@ ${opts.message || this.desc}`;
1975
1987
  let temp = p.split("/").filter((p2) => !!p2);
1976
1988
  this.module = temp.splice(0, 1)[0] || "";
1977
1989
  this.path = temp.join("/");
1990
+ this.dir = temp.length > 2 ? temp.slice(0, -1).join("/") : "";
1978
1991
  this.fullPath = `${this.module}${this.module && this.path ? "/" : ""}${this.path}`;
1979
1992
  this.name = temp.pop() || "";
1980
1993
  this.hasGlob = this.fullPath.includes("*");
@@ -2733,6 +2746,7 @@ ${err.message || err.toString()}`);
2733
2746
  exports2.ServiceUnavailableError = ServiceUnavailableError;
2734
2747
  exports2.Table = Table;
2735
2748
  exports2.TemplateError = TemplateError;
2749
+ exports2.TooManyRequestsError = TooManyRequestsError;
2736
2750
  exports2.TypedEmitter = TypedEmitter;
2737
2751
  exports2.UnauthorizedError = UnauthorizedError;
2738
2752
  exports2.addUnique = addUnique;