@nr1e/commons 0.0.3-alpha.2 → 0.0.3-alpha.20

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.
Files changed (56) hide show
  1. package/bitsnbytes/b64.d.ts +1 -0
  2. package/bitsnbytes/b64.d.ts.map +1 -0
  3. package/bitsnbytes/b64.js +17 -25
  4. package/bitsnbytes/b64.js.map +1 -1
  5. package/bitsnbytes/index.d.ts +1 -0
  6. package/bitsnbytes/index.d.ts.map +1 -0
  7. package/bitsnbytes/index.js +1 -17
  8. package/bitsnbytes/index.js.map +1 -1
  9. package/errors/errors.d.ts +52 -30
  10. package/errors/errors.d.ts.map +1 -0
  11. package/errors/errors.js +104 -101
  12. package/errors/errors.js.map +1 -1
  13. package/errors/index.d.ts +1 -0
  14. package/errors/index.d.ts.map +1 -0
  15. package/errors/index.js +1 -17
  16. package/errors/index.js.map +1 -1
  17. package/http/http-method.d.ts +1 -0
  18. package/http/http-method.d.ts.map +1 -0
  19. package/http/http-method.js +2 -5
  20. package/http/http-method.js.map +1 -1
  21. package/http/http-status-code.d.ts +1 -0
  22. package/http/http-status-code.d.ts.map +1 -0
  23. package/http/http-status-code.js +2 -5
  24. package/http/http-status-code.js.map +1 -1
  25. package/http/index.d.ts +1 -0
  26. package/http/index.d.ts.map +1 -0
  27. package/http/index.js +2 -18
  28. package/http/index.js.map +1 -1
  29. package/lang/index.d.ts +2 -0
  30. package/lang/index.d.ts.map +1 -0
  31. package/lang/index.js +2 -17
  32. package/lang/index.js.map +1 -1
  33. package/lang/sleep.d.ts +7 -0
  34. package/lang/sleep.d.ts.map +1 -0
  35. package/lang/sleep.js +9 -0
  36. package/lang/sleep.js.map +1 -0
  37. package/lang/type-functions.d.ts +1 -0
  38. package/lang/type-functions.d.ts.map +1 -0
  39. package/lang/type-functions.js +3 -9
  40. package/lang/type-functions.js.map +1 -1
  41. package/package.json +32 -19
  42. package/validator/index.d.ts +1 -0
  43. package/validator/index.d.ts.map +1 -0
  44. package/validator/index.js +1 -17
  45. package/validator/index.js.map +1 -1
  46. package/validator/validators.d.ts +1 -0
  47. package/validator/validators.d.ts.map +1 -0
  48. package/validator/validators.js +37 -64
  49. package/validator/validators.js.map +1 -1
  50. package/.prettierrc.js +0 -3
  51. package/LICENSE +0 -26
  52. package/README.md +0 -14
  53. package/index.d.ts +0 -5
  54. package/index.js +0 -9
  55. package/index.js.map +0 -1
  56. package/jest.config.js +0 -8
@@ -37,3 +37,4 @@ export declare function tob64s(buf: Uint8Array, opts?: Base64Options): string;
37
37
  * @return a base64 string
38
38
  */
39
39
  export declare function stob64s(str: string, opts?: Base64Options): string;
40
+ //# sourceMappingURL=b64.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"b64.d.ts","sourceRoot":"","sources":["../../src/bitsnbytes/b64.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY,EAAE,UAMzB,CAAC;AAOH,eAAO,MAAM,yBAAyB,EAAE,UAMtC,CAAC;AAOH,eAAO,MAAM,gBAAgB,EAAE,UAM7B,CAAC;AAOH,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAElD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,aAAa,CAAC;CAChD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,aAAa,GAAG,UAAU,CA0B5E;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,UAAU,CAyCvE;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,CAEpE;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,CAEjE"}
package/bitsnbytes/b64.js CHANGED
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stob64s = exports.tob64s = exports.tob64 = exports.b64Charset = exports.YUI_BASE64_CHARS = exports.URL_MODIFIED_BASE64_CHARS = exports.BASE64_CHARS = void 0;
4
- const errors_1 = require("../errors");
1
+ import { IllegalArgumentError } from '../errors';
5
2
  // eslint-disable-next-line node/no-unsupported-features/node-builtins
6
3
  const encoder = new TextEncoder();
7
4
  // eslint-disable-next-line node/no-unsupported-features/node-builtins
8
5
  const decoder = new TextDecoder();
9
- exports.BASE64_CHARS = new Uint8Array([
6
+ export const BASE64_CHARS = new Uint8Array([
10
7
  0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,
11
8
  0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
12
9
  0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
@@ -18,7 +15,7 @@ exports.BASE64_CHARS = new Uint8Array([
18
15
  // 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
19
16
  // 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
20
17
  // '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '='
21
- exports.URL_MODIFIED_BASE64_CHARS = new Uint8Array([
18
+ export const URL_MODIFIED_BASE64_CHARS = new Uint8Array([
22
19
  0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,
23
20
  0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
24
21
  0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
@@ -30,7 +27,7 @@ exports.URL_MODIFIED_BASE64_CHARS = new Uint8Array([
30
27
  // 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
31
28
  // 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
32
29
  // '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_',
33
- exports.YUI_BASE64_CHARS = new Uint8Array([
30
+ export const YUI_BASE64_CHARS = new Uint8Array([
34
31
  0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,
35
32
  0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
36
33
  0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
@@ -42,28 +39,27 @@ exports.YUI_BASE64_CHARS = new Uint8Array([
42
39
  *
43
40
  * @param b64chars a base64 character set
44
41
  */
45
- function b64Charset(b64chars) {
42
+ export function b64Charset(b64chars) {
46
43
  if (b64chars === undefined || b64chars === null) {
47
- return exports.BASE64_CHARS;
44
+ return BASE64_CHARS;
48
45
  }
49
46
  if (b64chars instanceof Uint8Array) {
50
47
  if (b64chars.length !== 65 && b64chars.length !== 64) {
51
- throw new errors_1.IllegalArgumentError('b64chars', 'Base 64 character sets must be 64 or 65 characters.');
48
+ throw new IllegalArgumentError('b64chars', 'Base 64 character sets must be 64 or 65 characters.');
52
49
  }
53
50
  return b64chars;
54
51
  }
55
52
  switch (b64chars) {
56
53
  case 'b64':
57
- return exports.BASE64_CHARS;
54
+ return BASE64_CHARS;
58
55
  case 'url':
59
- return exports.URL_MODIFIED_BASE64_CHARS;
56
+ return URL_MODIFIED_BASE64_CHARS;
60
57
  case 'yui':
61
- return exports.YUI_BASE64_CHARS;
58
+ return YUI_BASE64_CHARS;
62
59
  default:
63
- throw new errors_1.IllegalArgumentError('b64chars', `Invalid base64 character set '${b64chars}'`);
60
+ throw new IllegalArgumentError('b64chars', `Invalid base64 character set '${b64chars}'`);
64
61
  }
65
62
  }
66
- exports.b64Charset = b64Charset;
67
63
  /**
68
64
  * Base64 encodes a series of bytes.
69
65
  *
@@ -71,11 +67,10 @@ exports.b64Charset = b64Charset;
71
67
  * @param opts Encoding options
72
68
  * @return a base64 string
73
69
  */
74
- function tob64(buf, opts) {
75
- var _a, _b;
76
- const b64chars = b64Charset(opts === null || opts === void 0 ? void 0 : opts.b64chars);
77
- const toIndex = (_a = opts === null || opts === void 0 ? void 0 : opts.toIndex) !== null && _a !== void 0 ? _a : buf.length;
78
- const fromIndex = (_b = opts === null || opts === void 0 ? void 0 : opts.fromIndex) !== null && _b !== void 0 ? _b : 0;
70
+ export function tob64(buf, opts) {
71
+ const b64chars = b64Charset(opts?.b64chars);
72
+ const toIndex = opts?.toIndex ?? buf.length;
73
+ const fromIndex = opts?.fromIndex ?? 0;
79
74
  // every 3 bytes is 4 characters in padded base64 (6 bits per char)
80
75
  const num = toIndex - fromIndex;
81
76
  const numc = b64chars.length === 65
@@ -111,7 +106,6 @@ function tob64(buf, opts) {
111
106
  }
112
107
  return b64;
113
108
  }
114
- exports.tob64 = tob64;
115
109
  /**
116
110
  * Base64 encodes a series of bytes to a string.
117
111
  *
@@ -119,10 +113,9 @@ exports.tob64 = tob64;
119
113
  * @param opts Encoding options
120
114
  * @return a base64 string
121
115
  */
122
- function tob64s(buf, opts) {
116
+ export function tob64s(buf, opts) {
123
117
  return decoder.decode(tob64(buf, opts));
124
118
  }
125
- exports.tob64s = tob64s;
126
119
  /**
127
120
  * Base64 encodes a string to a string.
128
121
  *
@@ -130,8 +123,7 @@ exports.tob64s = tob64s;
130
123
  * @param opts Encoding options
131
124
  * @return a base64 string
132
125
  */
133
- function stob64s(str, opts) {
126
+ export function stob64s(str, opts) {
134
127
  return tob64s(encoder.encode(str), opts);
135
128
  }
136
- exports.stob64s = stob64s;
137
129
  //# sourceMappingURL=b64.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"b64.js","sourceRoot":"","sources":["b64.ts"],"names":[],"mappings":";;;AAAA,sCAA+C;AAE/C,sEAAsE;AACtE,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAClC,sEAAsE;AACtE,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAErB,QAAA,YAAY,GAAe,IAAI,UAAU,CAAC;IACrD,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAA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;iBACzB;gBACD,MAAM;YACR;gBACE,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;gBACtC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;gBAC9B,MAAM;SACT;KACF;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CAAC,GAAe,EAAE,IAAoB;IAC1D,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,IAAoB;IACvD,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import {IllegalArgumentError} from '../errors';\n\n// eslint-disable-next-line node/no-unsupported-features/node-builtins\nconst encoder = new TextEncoder();\n// eslint-disable-next-line node/no-unsupported-features/node-builtins\nconst decoder = new TextDecoder();\n\nexport const BASE64_CHARS: Uint8Array = new Uint8Array([\n 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,\n 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,\n 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,\n 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,\n 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2b, 0x2f, 0x3d,\n]);\n// 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',\n// 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',\n// 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',\n// 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',\n// '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '='\n\nexport const URL_MODIFIED_BASE64_CHARS: Uint8Array = new Uint8Array([\n 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,\n 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,\n 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,\n 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,\n 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2d, 0x5f,\n]);\n// 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',\n// 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',\n// 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',\n// 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',\n// '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_',\n\nexport const YUI_BASE64_CHARS: Uint8Array = new Uint8Array([\n 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,\n 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,\n 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,\n 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,\n 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2e, 0x5f, 0x2d,\n]);\n// 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',\n// 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',\n// 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',\n// 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',\n// '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '_', '-'\n\nexport type Base64CharSet = 'b64' | 'url' | 'yui';\n\nexport interface Base64Options {\n readonly fromIndex?: number;\n readonly toIndex?: number;\n readonly b64chars?: Uint8Array | Base64CharSet;\n}\n\n/**\n * Returns a base64 character set and validates one if passed in.\n *\n * @param b64chars a base64 character set\n */\nexport function b64Charset(b64chars?: Uint8Array | Base64CharSet): Uint8Array {\n if (b64chars === undefined || b64chars === null) {\n return BASE64_CHARS;\n }\n if (b64chars instanceof Uint8Array) {\n if (b64chars.length !== 65 && b64chars.length !== 64) {\n throw new IllegalArgumentError(\n 'b64chars',\n 'Base 64 character sets must be 64 or 65 characters.'\n );\n }\n return b64chars;\n }\n switch (b64chars) {\n case 'b64':\n return BASE64_CHARS;\n case 'url':\n return URL_MODIFIED_BASE64_CHARS;\n case 'yui':\n return YUI_BASE64_CHARS;\n default:\n throw new IllegalArgumentError(\n 'b64chars',\n `Invalid base64 character set '${b64chars}'`\n );\n }\n}\n\n/**\n * Base64 encodes a series of bytes.\n *\n * @param buf Bytes to encode\n * @param opts Encoding options\n * @return a base64 string\n */\nexport function tob64(buf: Uint8Array, opts?: Base64Options): Uint8Array {\n const b64chars = b64Charset(opts?.b64chars);\n const toIndex = opts?.toIndex ?? buf.length;\n const fromIndex = opts?.fromIndex ?? 0;\n // every 3 bytes is 4 characters in padded base64 (6 bits per char)\n const num = toIndex - fromIndex;\n const numc =\n b64chars.length === 65\n ? ((num + 2 - ((num + 2) % 3)) / 3) * 4 // padded\n : (num * 8) / 6 + ((num * 8) % 6 !== 0 ? 1 : 0); // not padded\n const b64 = new Uint8Array(numc);\n let n = 0;\n for (let i = 0; i < toIndex; i += 3) {\n const v =\n ((buf[i] & 0xff) << 16) |\n (i + 1 < toIndex ? (buf[i + 1] & 0xff) << 8 : 0) |\n (i + 2 < toIndex ? buf[i + 2] & 0xff : 0);\n b64[n++] = b64chars[(v >>> 18) & 0x3f];\n b64[n++] = b64chars[(v >>> 12) & 0x3f];\n switch (\n toIndex - i // calculate bytes remaining to be processed\n ) {\n case 1: // 0 bytes left to process\n if (b64chars.length === 65) {\n b64[n++] = b64chars[64];\n b64[n++] = b64chars[64];\n }\n break;\n case 2: // 1 byte left to process\n b64[n++] = b64chars[(v >>> 6) & 0x3f];\n if (b64chars.length === 65) {\n b64[n++] = b64chars[64];\n }\n break;\n default:\n b64[n++] = b64chars[(v >>> 6) & 0x3f];\n b64[n++] = b64chars[v & 0x3f];\n break;\n }\n }\n return b64;\n}\n\n/**\n * Base64 encodes a series of bytes to a string.\n *\n * @param buf Bytes to encode\n * @param opts Encoding options\n * @return a base64 string\n */\nexport function tob64s(buf: Uint8Array, opts?: Base64Options): string {\n return decoder.decode(tob64(buf, opts));\n}\n\n/**\n * Base64 encodes a string to a string.\n *\n * @param str String to encode\n * @param opts Encoding options\n * @return a base64 string\n */\nexport function stob64s(str: string, opts?: Base64Options): string {\n return tob64s(encoder.encode(str), opts);\n}\n"]}
@@ -1 +1,2 @@
1
1
  export * from './b64';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bitsnbytes/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
@@ -1,18 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./b64"), exports);
1
+ export * from './b64';
18
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bitsnbytes/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC","sourcesContent":["export * from './b64';\n"]}
@@ -1,49 +1,64 @@
1
1
  import { HttpStatusCode } from '../http';
2
+ export { isError } from '../lang';
2
3
  /**
3
4
  * An extended version of Error that includes an HttpStatusCode.
4
5
  * This can be useful in middleware error handlers to determine http status codes to return to the client.
5
6
  */
6
7
  export interface HttpError extends Error {
8
+ /**
9
+ * The HTTP status code.
10
+ */
7
11
  statusCode: HttpStatusCode | number;
8
12
  }
9
13
  /**
10
14
  * Checks if the given parameter is an HttpError.
11
15
  *
12
- * @param e the parameter to check
16
+ * @param e The parameter to check
13
17
  */
14
18
  export declare function isHttpError(e?: unknown): e is HttpError;
19
+ /**
20
+ * Thrown when a resource cannot be found.
21
+ */
22
+ export declare class NotFoundError extends Error implements HttpError {
23
+ readonly statusCode = HttpStatusCode.NOT_FOUND;
24
+ /**
25
+ * The max-age value to set in the Cache-Control header if used in a middleware.
26
+ */
27
+ readonly maxAge?: number;
28
+ constructor(message?: string, maxAge?: number);
29
+ }
15
30
  /**
16
31
  * Checks if the given parameter is a NotFoundError.
17
32
  *
18
- * @param e the parameter to check
33
+ * @param e The parameter to check
19
34
  */
20
35
  export declare function isNotFoundError(e?: unknown): e is NotFoundError;
21
36
  /**
22
- * Thrown when a resource cannot be found.
37
+ * Thrown when a request is missing authentication credentials.
23
38
  */
24
- export declare class NotFoundError extends Error implements HttpError {
25
- readonly statusCode = HttpStatusCode.NOT_FOUND;
39
+ export declare class UnauthorizedError extends Error implements HttpError {
40
+ readonly statusCode = HttpStatusCode.UNAUTHORIZED;
26
41
  constructor(message?: string);
27
42
  }
28
43
  /**
29
- * Checks if the given parameter is a ForbiddenError.
44
+ * Checks if the given parameter is a UnauthorizedError.
30
45
  *
31
- * @param e the parameter to check
46
+ * @param e The parameter to check
32
47
  */
33
- export declare function isForbiddenError(e?: unknown): e is ForbiddenError;
48
+ export declare function isUnauthorizedError(e?: unknown): e is UnauthorizedError;
34
49
  /**
35
- * Thrown when a requested operations is not allowed.
50
+ * Thrown when credentials are present, but the requested operations is not allowed.
36
51
  */
37
52
  export declare class ForbiddenError extends Error implements HttpError {
38
53
  readonly statusCode = HttpStatusCode.FORBIDDEN;
39
54
  constructor(message?: string);
40
55
  }
41
56
  /**
42
- * Checks if the given variable is a ValidationError.
57
+ * Checks if the given parameter is a ForbiddenError.
43
58
  *
44
- * @param e the variable to check
59
+ * @param e The parameter to check
45
60
  */
46
- export declare function isValidationError(e?: unknown): e is ValidationError;
61
+ export declare function isForbiddenError(e?: unknown): e is ForbiddenError;
47
62
  /**
48
63
  * Thrown when a validation error occurs.
49
64
  */
@@ -52,11 +67,11 @@ export declare class ValidationError extends Error implements HttpError {
52
67
  constructor(message?: string);
53
68
  }
54
69
  /**
55
- * Checks if the given parameter is a BadRequestError.
70
+ * Checks if the given variable is a ValidationError.
56
71
  *
57
- * @param e the parameter to check
72
+ * @param e The variable to check
58
73
  */
59
- export declare function isBadRequestError(e?: unknown): e is BadRequestError;
74
+ export declare function isValidationError(e?: unknown): e is ValidationError;
60
75
  /**
61
76
  * Thrown when a bad request is made.
62
77
  */
@@ -65,11 +80,11 @@ export declare class BadRequestError extends Error implements HttpError {
65
80
  constructor(message?: string);
66
81
  }
67
82
  /**
68
- * Checks if the given parameter is a InternalServerError.
83
+ * Checks if the given parameter is a BadRequestError.
69
84
  *
70
- * @param e the parameter to check
85
+ * @param e The parameter to check
71
86
  */
72
- export declare function isInternalServerError(e?: unknown): e is InternalServerError;
87
+ export declare function isBadRequestError(e?: unknown): e is BadRequestError;
73
88
  /**
74
89
  * Throws when an internal server error occurs.
75
90
  */
@@ -78,11 +93,11 @@ export declare class InternalServerError extends Error implements HttpError {
78
93
  constructor(message?: string);
79
94
  }
80
95
  /**
81
- * Checks if the given parameter is a ConflictError.
96
+ * Checks if the given parameter is a InternalServerError.
82
97
  *
83
- * @param e the parameter to check
98
+ * @param e The parameter to check
84
99
  */
85
- export declare function isConflictError(e?: unknown): e is ConflictError;
100
+ export declare function isInternalServerError(e?: unknown): e is InternalServerError;
86
101
  /**
87
102
  * Thrown when a conflict occurs.
88
103
  */
@@ -91,11 +106,11 @@ export declare class ConflictError extends Error implements HttpError {
91
106
  constructor(message?: string);
92
107
  }
93
108
  /**
94
- * Checks if the given parameter is a UnsupportedMediaTypeError.
109
+ * Checks if the given parameter is a ConflictError.
95
110
  *
96
- * @param e the parameter to check
111
+ * @param e The parameter to check
97
112
  */
98
- export declare function isUnsupportedMediaTypeError(e?: unknown): e is UnsupportedMediaTypeError;
113
+ export declare function isConflictError(e?: unknown): e is ConflictError;
99
114
  /**
100
115
  * Thrown when a unsupported media type is used.
101
116
  */
@@ -104,11 +119,11 @@ export declare class UnsupportedMediaTypeError extends Error implements HttpErro
104
119
  constructor(message?: string);
105
120
  }
106
121
  /**
107
- * Checks if the given parameter is a NotImplementedError.
122
+ * Checks if the given parameter is a UnsupportedMediaTypeError.
108
123
  *
109
- * @param e the parameter to check
124
+ * @param e The parameter to check
110
125
  */
111
- export declare function isNotImplementedError(e?: unknown): e is NotImplementedError;
126
+ export declare function isUnsupportedMediaTypeError(e?: unknown): e is UnsupportedMediaTypeError;
112
127
  /**
113
128
  * Thrown when a requested operation is not implemented.
114
129
  */
@@ -118,11 +133,11 @@ export declare class NotImplementedError extends Error implements HttpError {
118
133
  constructor(message?: string);
119
134
  }
120
135
  /**
121
- * Checks if the given parameter is a IllegalArgumentError.
136
+ * Checks if the given parameter is a NotImplementedError.
122
137
  *
123
- * @param e the parameter to check
138
+ * @param e The parameter to check
124
139
  */
125
- export declare function isIllegalArgumentError(e?: unknown): e is IllegalArgumentError;
140
+ export declare function isNotImplementedError(e?: unknown): e is NotImplementedError;
126
141
  /**
127
142
  * Thrown when an illegal argument is passed to a function.
128
143
  */
@@ -130,6 +145,12 @@ export declare class IllegalArgumentError extends Error {
130
145
  readonly argName: string;
131
146
  constructor(argName: string, message?: string);
132
147
  }
148
+ /**
149
+ * Checks if the given parameter is a IllegalArgumentError.
150
+ *
151
+ * @param e The parameter to check
152
+ */
153
+ export declare function isIllegalArgumentError(e?: unknown): e is IllegalArgumentError;
133
154
  /**
134
155
  * Converts the given parameter to an HttpError.
135
156
  *
@@ -137,3 +158,4 @@ export declare class IllegalArgumentError extends Error {
137
158
  * @param message The error message
138
159
  */
139
160
  export declare function toError(code: number | HttpStatusCode, message?: string): Error;
161
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAA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