@beecode/msh-util 1.0.1-alpha

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 (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/lib/class-factory-pattern.d.ts +25 -0
  4. package/lib/class-factory-pattern.d.ts.map +1 -0
  5. package/lib/class-factory-pattern.js +30 -0
  6. package/lib/class-factory-pattern.js.map +1 -0
  7. package/lib/express/error-handler.d.ts +17 -0
  8. package/lib/express/error-handler.d.ts.map +1 -0
  9. package/lib/express/error-handler.js +28 -0
  10. package/lib/express/error-handler.js.map +1 -0
  11. package/lib/index.d.ts +14 -0
  12. package/lib/index.d.ts.map +1 -0
  13. package/lib/index.js +30 -0
  14. package/lib/index.js.map +1 -0
  15. package/lib/joi-util.d.ts +47 -0
  16. package/lib/joi-util.d.ts.map +1 -0
  17. package/lib/joi-util.js +63 -0
  18. package/lib/joi-util.js.map +1 -0
  19. package/lib/memoize-factory.d.ts +16 -0
  20. package/lib/memoize-factory.d.ts.map +1 -0
  21. package/lib/memoize-factory.js +28 -0
  22. package/lib/memoize-factory.js.map +1 -0
  23. package/lib/object-util.d.ts +70 -0
  24. package/lib/object-util.d.ts.map +1 -0
  25. package/lib/object-util.js +114 -0
  26. package/lib/object-util.js.map +1 -0
  27. package/lib/regex-util.d.ts +12 -0
  28. package/lib/regex-util.d.ts.map +1 -0
  29. package/lib/regex-util.js +15 -0
  30. package/lib/regex-util.js.map +1 -0
  31. package/lib/single-threshold-promise.d.ts +31 -0
  32. package/lib/single-threshold-promise.d.ts.map +1 -0
  33. package/lib/single-threshold-promise.js +49 -0
  34. package/lib/single-threshold-promise.js.map +1 -0
  35. package/lib/singleton/async.d.ts +50 -0
  36. package/lib/singleton/async.d.ts.map +1 -0
  37. package/lib/singleton/async.js +78 -0
  38. package/lib/singleton/async.js.map +1 -0
  39. package/lib/singleton/pattern.d.ts +34 -0
  40. package/lib/singleton/pattern.d.ts.map +1 -0
  41. package/lib/singleton/pattern.js +45 -0
  42. package/lib/singleton/pattern.js.map +1 -0
  43. package/lib/string-util.d.ts +10 -0
  44. package/lib/string-util.d.ts.map +1 -0
  45. package/lib/string-util.js +19 -0
  46. package/lib/string-util.js.map +1 -0
  47. package/lib/time-util.d.ts +74 -0
  48. package/lib/time-util.d.ts.map +1 -0
  49. package/lib/time-util.js +97 -0
  50. package/lib/time-util.js.map +1 -0
  51. package/lib/timeout.d.ts +15 -0
  52. package/lib/timeout.d.ts.map +1 -0
  53. package/lib/timeout.js +21 -0
  54. package/lib/timeout.js.map +1 -0
  55. package/lib/type-util.d.ts +50 -0
  56. package/lib/type-util.d.ts.map +1 -0
  57. package/lib/type-util.js +57 -0
  58. package/lib/type-util.js.map +1 -0
  59. package/lib/types/any-function/index.d.ts +2 -0
  60. package/lib/types/any-function/index.d.ts.map +1 -0
  61. package/lib/types/any-function/index.js +3 -0
  62. package/lib/types/any-function/index.js.map +1 -0
  63. package/lib/types/any-function/no-params.d.ts +2 -0
  64. package/lib/types/any-function/no-params.d.ts.map +1 -0
  65. package/lib/types/any-function/no-params.js +3 -0
  66. package/lib/types/any-function/no-params.js.map +1 -0
  67. package/lib/types/any-function/promise-no-params.d.ts +2 -0
  68. package/lib/types/any-function/promise-no-params.d.ts.map +1 -0
  69. package/lib/types/any-function/promise-no-params.js +3 -0
  70. package/lib/types/any-function/promise-no-params.js.map +1 -0
  71. package/lib/types/any-function/promise.d.ts +2 -0
  72. package/lib/types/any-function/promise.d.ts.map +1 -0
  73. package/lib/types/any-function/promise.js +3 -0
  74. package/lib/types/any-function/promise.js.map +1 -0
  75. package/package.json +127 -0
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.typeUtil = void 0;
4
+ exports.typeUtil = {
5
+ /**
6
+ * In TypeScript, exhaustiveMessage is a technique that can be used with switch statements to ensure that all possible cases are handled.
7
+ *
8
+ * When using switch statements, it is common to have a default case that handles any unanticipated cases. However, sometimes it is important to ensure that all cases are explicitly handled to avoid potential errors or bugs in the code.
9
+ * @param {string} message
10
+ * @param {never} _
11
+ * @return {string}
12
+ * @example
13
+ * export type Animal = 'cat' | 'dog' | 'bird';
14
+ *
15
+ * export const makeSound = (animal: Animal): string => {
16
+ * switch (animal) {
17
+ * case 'cat':
18
+ * return 'Meow'
19
+ * case 'dog':
20
+ * return 'Woof'
21
+ * case 'bird':
22
+ * return 'Tweet'
23
+ * default:
24
+ * console.error(new TypeUtil().exhaustiveMessage('Unknown animal [animal]', animal))
25
+ * return 'unknown sound'
26
+ * }
27
+ * }
28
+ */
29
+ exhaustiveMessage: (message, _) => {
30
+ return message;
31
+ },
32
+ /**
33
+ * This is the similar to exhaustiveMessage, but instead of message we are returning error so we can throw it
34
+ * @param {string} message
35
+ * @param {never} _
36
+ * @return {Error}
37
+ * @example
38
+ * export type Animal = 'cat' | 'dog' | 'bird';
39
+ *
40
+ * export const makeSound = (animal: Animal): string => {
41
+ * switch (animal) {
42
+ * case 'cat':
43
+ * return 'Meow'
44
+ * case 'dog':
45
+ * return 'Woof'
46
+ * case 'bird':
47
+ * return 'Tweet'
48
+ * default:
49
+ * throw typeUtil.exhaustiveError('Unknown animal [animal]', animal)
50
+ * }
51
+ * }
52
+ */
53
+ exhaustiveError: (message, _) => {
54
+ return new Error(message);
55
+ },
56
+ };
57
+ //# sourceMappingURL=type-util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-util.js","sourceRoot":"","sources":["../src/type-util.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG;IACtB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,iBAAiB,EAAE,CAAC,OAAe,EAAE,CAAQ,EAAU,EAAE;QACvD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,eAAe,EAAE,CAAC,OAAe,EAAE,CAAQ,EAAS,EAAE;QACpD,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;IAC3B,CAAC;CACF,CAAA"}
@@ -0,0 +1,2 @@
1
+ export type AnyFunction<T> = (...args: any[]) => T;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/any-function/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/any-function/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export type AnyFunctionNoParams<T> = () => T;
2
+ //# sourceMappingURL=no-params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-params.d.ts","sourceRoot":"","sources":["../../../src/types/any-function/no-params.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,MAAM,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=no-params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-params.js","sourceRoot":"","sources":["../../../src/types/any-function/no-params.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export type AnyFunctionPromiseNoParams<T> = () => Promise<T>;
2
+ //# sourceMappingURL=promise-no-params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise-no-params.d.ts","sourceRoot":"","sources":["../../../src/types/any-function/promise-no-params.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,0BAA0B,CAAC,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=promise-no-params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise-no-params.js","sourceRoot":"","sources":["../../../src/types/any-function/promise-no-params.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export type AnyFunctionPromise<T> = (...args: any[]) => Promise<T>;
2
+ //# sourceMappingURL=promise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../src/types/any-function/promise.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=promise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise.js","sourceRoot":"","sources":["../../../src/types/any-function/promise.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,127 @@
1
+ {
2
+ "_moduleAliases": {
3
+ "src": "./lib"
4
+ },
5
+ "author": "Milos Bugarinovic <milos.bugarinovic@gmail.com>",
6
+ "bugs": {
7
+ "url": "https://github.com/beecode-rs/msh-util/issues"
8
+ },
9
+ "commitlint": {
10
+ "extends": [
11
+ "@commitlint/config-conventional"
12
+ ]
13
+ },
14
+ "config": {
15
+ "commitizen": {
16
+ "path": "node_modules/cz-conventional-changelog"
17
+ }
18
+ },
19
+ "dependencies": {
20
+ "date-fns": "2.29.3",
21
+ "joi": "17.8.4",
22
+ "lodash.clonedeep": "4.5.0",
23
+ "rxjs": "7.8.0"
24
+ },
25
+ "description": "",
26
+ "devDependencies": {
27
+ "@commitlint/cli": "17.4.4",
28
+ "@commitlint/config-conventional": "17.4.4",
29
+ "@commitlint/prompt": "17.4.4",
30
+ "@semantic-release/changelog": "6.0.2",
31
+ "@semantic-release/commit-analyzer": "9.0.2",
32
+ "@semantic-release/exec": "6.0.3",
33
+ "@semantic-release/git": "10.0.1",
34
+ "@semantic-release/github": "8.0.7",
35
+ "@semantic-release/release-notes-generator": "10.0.3",
36
+ "@types/jest": "29.4.4",
37
+ "@types/lodash.clonedeep": "4.5.7",
38
+ "@types/node": "18.15.3",
39
+ "@typescript-eslint/eslint-plugin": "5.55.0",
40
+ "@typescript-eslint/parser": "5.55.0",
41
+ "commitizen": "4.3.0",
42
+ "eslint": "8.36.0",
43
+ "eslint-config-prettier": "8.7.0",
44
+ "eslint-plugin-import": "2.27.5",
45
+ "eslint-plugin-no-loops": "0.3.0",
46
+ "eslint-plugin-no-only-tests": "3.1.0",
47
+ "eslint-plugin-prettier": "4.2.1",
48
+ "husky": "8.0.3",
49
+ "jest": "29.5.0",
50
+ "jest-extended": "3.2.4",
51
+ "lint-staged": "13.2.0",
52
+ "markdown-toc": "1.2.0",
53
+ "prettier": "2.8.4",
54
+ "rimraf": "4.4.0",
55
+ "semantic-release": "20.1.1",
56
+ "source-map-support": "0.5.21",
57
+ "ts-jest": "29.0.5",
58
+ "ts-node": "10.9.1",
59
+ "tsc-alias": "1.8.3",
60
+ "tsc-watch": "6.0.0",
61
+ "typedoc": "0.23.27",
62
+ "typedoc-plugin-markdown": "3.14.0",
63
+ "typescript": "4.9.5"
64
+ },
65
+ "engines": {
66
+ "node": "=18.15.0",
67
+ "npm": "=9.6.1"
68
+ },
69
+ "files": [
70
+ "lib",
71
+ "package-lock.json"
72
+ ],
73
+ "homepage": "https://github.com/beecode-rs/msh-util#readme",
74
+ "keywords": [],
75
+ "license": "mit",
76
+ "lint-staged": {
77
+ "src/**/*.{ts,tsx,js,jsx}": "eslint"
78
+ },
79
+ "main": "lib/index.js",
80
+ "name": "@beecode/msh-util",
81
+ "repository": {
82
+ "type": "git",
83
+ "url": "https://github.com/beecode-rs/msh-util.git"
84
+ },
85
+ "scripts": {
86
+ "audit:fix": "npx --yes npm-force-resolutions",
87
+ "build": "npm run clean && npm run tsc && npm run tsc:alias",
88
+ "build:on-success": "npm run tsc:alias",
89
+ "build:watch": "npm run tsc:watch -- --preserveWatchOutput --onSuccess \"npm run tsc:cleaner\" --onCompilationComplete \"npm run build:on-success\"",
90
+ "bump-version": "npm --no-git-tag-version version",
91
+ "clean": "rimraf ./lib/*",
92
+ "commit": "git-cz",
93
+ "doc:api": "npx typedoc",
94
+ "doc:toc": "npx markdown-toc -i ./README.md",
95
+ "docker:build": "docker build -f .docker/Dockerfile -t bc-msh-util .",
96
+ "docker:exec": "docker run --rm bc-msh-util",
97
+ "docker:exec:sh": "docker run --rm -it bc-msh-util sh",
98
+ "docker:rmi": "docker rmi bc-msh-util",
99
+ "eslint": "eslint . --ext .ts --quiet",
100
+ "eslint:fix": "npm run eslint -- --fix",
101
+ "initial-setup": "npm run initial-setup:husky && npm run initial-setup:git-config",
102
+ "initial-setup:git-config": "git config include.path ../.git-config",
103
+ "initial-setup:husky": "npx husky install",
104
+ "lint": "npm run eslint && npm run prettier",
105
+ "lint:fix": "npm run eslint:fix && npm run prettier:fix",
106
+ "pack": "npm pack --pack-destination=./packages",
107
+ "prettier": "prettier --check \"./src/**/*.{ts,json}\"",
108
+ "prettier:fix": "prettier --write \"./src/**/*.{ts,json}\"",
109
+ "semantic-release": "semantic-release",
110
+ "semantic-release:check": "npm run semantic-release -- --dry-run --no-ci",
111
+ "test": "npm run test:unit && npm run test:int ",
112
+ "test:int": "# jest --config=./test/jest.config.json",
113
+ "test:unit": "TZ=utc jest",
114
+ "test:unit:coverage": "npm run test:unit --coverage",
115
+ "test:unit:coverage:publish": "codecov",
116
+ "tsc": "tsc -p ./tsconfig-build.json",
117
+ "tsc:alias": "tsc-alias",
118
+ "tsc:check": "npm run tsc -- --noEmit",
119
+ "tsc:check:list-files": "npm run tsc:check -- --listFiles",
120
+ "tsc:cleaner": "ts-cleaner --dist lib",
121
+ "tsc:cleaner:watch": "npm run tsc:cleaner -- --watch",
122
+ "tsc:time": "npm run tsc -- --diagnostics",
123
+ "tsc:watch": "tsc-watch -p tsconfig-build.json"
124
+ },
125
+ "types": "lib/index.d.ts",
126
+ "version": "1.0.1-alpha"
127
+ }