@beecode/msh-util 1.2.0 → 2.0.0-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.
- package/{lib → dist}/array-util.d.ts +2 -2
- package/{lib → dist}/array-util.d.ts.map +1 -1
- package/dist/array-util.js +27 -0
- package/{lib → dist}/class-factory-pattern.d.ts.map +1 -1
- package/dist/class-factory-pattern.js +26 -0
- package/{lib → dist}/express/error-handler.d.ts.map +1 -1
- package/dist/express/error-handler.js +26 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/{lib → dist}/joi-util.d.ts.map +1 -1
- package/dist/joi-util.js +62 -0
- package/{lib → dist}/memoize-factory.d.ts +1 -1
- package/dist/memoize-factory.d.ts.map +1 -0
- package/dist/memoize-factory.js +24 -0
- package/{lib → dist}/object-util.d.ts.map +1 -1
- package/dist/object-util.js +115 -0
- package/dist/regex-util.js +12 -0
- package/{lib → dist}/single-threshold-promise.d.ts +1 -1
- package/dist/single-threshold-promise.d.ts.map +1 -0
- package/dist/single-threshold-promise.js +46 -0
- package/{lib → dist}/singleton/async.d.ts +1 -1
- package/dist/singleton/async.d.ts.map +1 -0
- package/dist/singleton/async.js +75 -0
- package/{lib → dist}/singleton/pattern.d.ts +1 -1
- package/dist/singleton/pattern.d.ts.map +1 -0
- package/dist/singleton/pattern.js +41 -0
- package/dist/string-util.js +18 -0
- package/dist/time-util.js +90 -0
- package/dist/time-zone.d.ts +467 -0
- package/dist/time-zone.d.ts.map +1 -0
- package/dist/time-zone.js +468 -0
- package/dist/timeout.js +17 -0
- package/dist/type-util.js +54 -0
- package/package.json +160 -99
- package/lib/array-util.js +0 -30
- package/lib/array-util.js.map +0 -1
- package/lib/class-factory-pattern.js +0 -30
- package/lib/class-factory-pattern.js.map +0 -1
- package/lib/express/error-handler.js +0 -28
- package/lib/express/error-handler.js.map +0 -1
- package/lib/index.d.ts +0 -14
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -30
- package/lib/index.js.map +0 -1
- package/lib/joi-util.js +0 -63
- package/lib/joi-util.js.map +0 -1
- package/lib/memoize-factory.d.ts.map +0 -1
- package/lib/memoize-factory.js +0 -28
- package/lib/memoize-factory.js.map +0 -1
- package/lib/object-util.js +0 -118
- package/lib/object-util.js.map +0 -1
- package/lib/regex-util.js +0 -15
- package/lib/regex-util.js.map +0 -1
- package/lib/single-threshold-promise.d.ts.map +0 -1
- package/lib/single-threshold-promise.js +0 -49
- package/lib/single-threshold-promise.js.map +0 -1
- package/lib/singleton/async.d.ts.map +0 -1
- package/lib/singleton/async.js +0 -78
- package/lib/singleton/async.js.map +0 -1
- package/lib/singleton/pattern.d.ts.map +0 -1
- package/lib/singleton/pattern.js +0 -45
- package/lib/singleton/pattern.js.map +0 -1
- package/lib/string-util.js +0 -21
- package/lib/string-util.js.map +0 -1
- package/lib/time-util.js +0 -97
- package/lib/time-util.js.map +0 -1
- package/lib/timeout.js +0 -21
- package/lib/timeout.js.map +0 -1
- package/lib/type-util.js +0 -57
- package/lib/type-util.js.map +0 -1
- package/lib/types/any-function/index.d.ts +0 -2
- package/lib/types/any-function/index.d.ts.map +0 -1
- package/lib/types/any-function/index.js +0 -3
- package/lib/types/any-function/index.js.map +0 -1
- package/lib/types/any-function/no-params.d.ts +0 -2
- package/lib/types/any-function/no-params.d.ts.map +0 -1
- package/lib/types/any-function/no-params.js +0 -3
- package/lib/types/any-function/no-params.js.map +0 -1
- package/lib/types/any-function/promise-no-params.d.ts +0 -2
- package/lib/types/any-function/promise-no-params.d.ts.map +0 -1
- package/lib/types/any-function/promise-no-params.js +0 -3
- package/lib/types/any-function/promise-no-params.js.map +0 -1
- package/lib/types/any-function/promise.d.ts +0 -2
- package/lib/types/any-function/promise.d.ts.map +0 -1
- package/lib/types/any-function/promise.js +0 -3
- package/lib/types/any-function/promise.js.map +0 -1
- /package/{lib → dist}/class-factory-pattern.d.ts +0 -0
- /package/{lib → dist}/express/error-handler.d.ts +0 -0
- /package/{lib → dist}/joi-util.d.ts +0 -0
- /package/{lib → dist}/object-util.d.ts +0 -0
- /package/{lib → dist}/regex-util.d.ts +0 -0
- /package/{lib → dist}/regex-util.d.ts.map +0 -0
- /package/{lib → dist}/string-util.d.ts +0 -0
- /package/{lib → dist}/string-util.d.ts.map +0 -0
- /package/{lib → dist}/time-util.d.ts +0 -0
- /package/{lib → dist}/time-util.d.ts.map +0 -0
- /package/{lib → dist}/timeout.d.ts +0 -0
- /package/{lib → dist}/timeout.d.ts.map +0 -0
- /package/{lib → dist}/type-util.d.ts +0 -0
- /package/{lib → dist}/type-util.d.ts.map +0 -0
package/package.json
CHANGED
|
@@ -1,129 +1,190 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"
|
|
2
|
+
"name": "@beecode/msh-util",
|
|
3
|
+
"version": "2.0.0-alpha",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"homepage": "https://github.com/beecode-rs/msh-util#readme",
|
|
6
7
|
"bugs": {
|
|
7
8
|
"url": "https://github.com/beecode-rs/msh-util/issues"
|
|
8
9
|
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/beecode-rs/msh-util.git"
|
|
13
|
+
},
|
|
14
|
+
"license": "mit",
|
|
15
|
+
"author": "Milos Bugarinovic <milos.bugarinovic@gmail.com> (https://milos.bugarinovic.com)",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"imports": {
|
|
18
|
+
"#src": "./src/index.js",
|
|
19
|
+
"#src/*": [
|
|
20
|
+
"./src/*.js",
|
|
21
|
+
"./src/*/index.js"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"require": "./lib/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./*": {
|
|
31
|
+
"import": [
|
|
32
|
+
"./dist/*.js",
|
|
33
|
+
"./dist/*/index.js"
|
|
34
|
+
],
|
|
35
|
+
"types": [
|
|
36
|
+
"./dist/*.d.ts",
|
|
37
|
+
"./dist/*/index.d.ts"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"./lib/*": {
|
|
41
|
+
"require": [
|
|
42
|
+
"./lib/*.js",
|
|
43
|
+
"./lib/*/index.js"
|
|
44
|
+
],
|
|
45
|
+
"types": [
|
|
46
|
+
"./lib/*.d.ts",
|
|
47
|
+
"./lib/*/index.d.ts"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"./package.json": "./package.json"
|
|
51
|
+
},
|
|
52
|
+
"main": "./lib/index.js",
|
|
53
|
+
"module": "./dist/index.js",
|
|
54
|
+
"types": "./dist/index.d.ts",
|
|
55
|
+
"files": [
|
|
56
|
+
"./dist",
|
|
57
|
+
"./lib"
|
|
58
|
+
],
|
|
59
|
+
"scripts": {
|
|
60
|
+
"babel": "npx babel --extensions .ts",
|
|
61
|
+
"build": "npm run clean && npm run tsc",
|
|
62
|
+
"build-cjs": "npm run clean-cjs && npm run tsc-cjs && npm run tsc-types && npm run tsc-types-alias && npm run fix-hybrid-lib-cjs",
|
|
63
|
+
"clean": "rimraf ./dist",
|
|
64
|
+
"clean-cjs": "rimraf ./lib",
|
|
65
|
+
"doc": "concurrently -c auto 'npm:doc:*'",
|
|
66
|
+
"doc:api": "npx typedoc",
|
|
67
|
+
"doc:toc": "npx markdown-toc -i ./README.md",
|
|
68
|
+
"docker-build": "docker build -f ./resource/docker/Dockerfile -t bc-msh-util ./",
|
|
69
|
+
"docker-rmi": "docker rmi bc-msh-util",
|
|
70
|
+
"docker-run-package-lock-update": "docker run --rm -v ./:/usr/app/ milosbugarinovic/msh-lib-base:node20.11.1-alpine3.19 npm i --package-lock-only",
|
|
71
|
+
"docker-run-sh": "docker run --rm -it bc-msh-util sh",
|
|
72
|
+
"fix-hybrid-lib-cjs": "mkdir -p ./lib && echo '{\"type\": \"commonjs\"}' > ./lib/package.json",
|
|
73
|
+
"init": "concurrently -c auto 'npm:init:*'",
|
|
74
|
+
"init:git-config": "git config include.path ./.git-config",
|
|
75
|
+
"init:husky": "npx husky install",
|
|
76
|
+
"jest": "NODE_OPTIONS=--experimental-vm-modules npx jest",
|
|
77
|
+
"lint": "npm run lint-prettier && npm run lint-eslint && npm run lint-json",
|
|
78
|
+
"lint-eslint": "eslint ./ --quiet",
|
|
79
|
+
"lint-eslint-fix": "npm run lint-eslint -- --fix",
|
|
80
|
+
"lint-fix": "npm run lint-prettier-fix && npm run lint-eslint-fix && npm run lint-json-fix",
|
|
81
|
+
"lint-json": "npm run lint-json-fix -- -c",
|
|
82
|
+
"lint-json-fix": "jsonsort * .*.json '!./test/node_modules' '!./resource' '!**/.env*' -t",
|
|
83
|
+
"lint-prettier": "prettier --check {**/*,*}.{js,jsx,ts,tsx}",
|
|
84
|
+
"lint-prettier-fix": "prettier --write {**/*,*}.{js,jsx,ts,tsx}",
|
|
85
|
+
"npm-bump-version": "npm --no-git-tag-version version",
|
|
86
|
+
"npm-lock-file-generate": "npm i --package-lock-only --prefix ./",
|
|
87
|
+
"npm-ncu-check": "npx ncu",
|
|
88
|
+
"npm-ncu-update": "npx ncu -u",
|
|
89
|
+
"npm-pack": "mkdir -p packages && npm pack --pack-destination=./packages",
|
|
90
|
+
"npm-semantic-release": "semantic-release",
|
|
91
|
+
"npm-semantic-release-check": "npm run npm-semantic-release -- --dry-run --no-ci",
|
|
92
|
+
"test": "concurrently -c auto 'npm:test:*'",
|
|
93
|
+
"test-coverage-unit": "npm run test:unit -- --coverage",
|
|
94
|
+
"test-coverage-unit-publish": "codecov",
|
|
95
|
+
"test:e2e": "npm run jest -- --config=./test/jest.config.ts",
|
|
96
|
+
"test:int": "npm run jest -- --config=./jest.config.int.ts",
|
|
97
|
+
"test:unit": "npm run jest -- --config=./jest.config.unit.ts",
|
|
98
|
+
"tsc": "tsc -p ./resource/tsconfig/esm.json",
|
|
99
|
+
"tsc-check": "npm run tsc -- --noEmit",
|
|
100
|
+
"tsc-cjs": "npm run babel -- --out-dir ./lib ./src",
|
|
101
|
+
"tsc-cleaner": "ts-cleaner --dist ./dist",
|
|
102
|
+
"tsc-cleaner-watch": "npm run tsc-cleaner -- --watch",
|
|
103
|
+
"tsc-time": "npm run tsc -- --diagnostics",
|
|
104
|
+
"tsc-types": "tsc -p ./resource/tsconfig/types.json",
|
|
105
|
+
"tsc-types-alias": "tsc-alias -p ./resource/tsconfig/types.json",
|
|
106
|
+
"tsc-watch": "npm run tsc -- -w --preserveWatchOutput",
|
|
107
|
+
"watch": "concurrently -c auto -n build,clean 'npm run tsc-watch' 'npm run tsc-cleaner-watch'"
|
|
108
|
+
},
|
|
9
109
|
"commitlint": {
|
|
10
110
|
"extends": [
|
|
11
111
|
"@commitlint/config-conventional"
|
|
12
112
|
]
|
|
13
113
|
},
|
|
114
|
+
"lint-staged": {
|
|
115
|
+
"**/*.json": [
|
|
116
|
+
"npm run lint-json"
|
|
117
|
+
],
|
|
118
|
+
"**/*.{ts,tsx,js,jsx}": [
|
|
119
|
+
"eslint",
|
|
120
|
+
"prettier --check"
|
|
121
|
+
]
|
|
122
|
+
},
|
|
14
123
|
"config": {
|
|
15
124
|
"commitizen": {
|
|
16
125
|
"path": "node_modules/cz-conventional-changelog"
|
|
17
126
|
}
|
|
18
127
|
},
|
|
19
128
|
"dependencies": {
|
|
20
|
-
"date-fns": "2.
|
|
21
|
-
"
|
|
129
|
+
"date-fns": "2.30.0",
|
|
130
|
+
"date-fns-tz": "2.0.1",
|
|
131
|
+
"joi": "17.12.2",
|
|
22
132
|
"lodash.clonedeep": "4.5.0",
|
|
23
|
-
"rxjs": "7.8.
|
|
133
|
+
"rxjs": "7.8.1"
|
|
24
134
|
},
|
|
25
|
-
"description": "",
|
|
26
135
|
"devDependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
136
|
+
"@babel/cli": "7.24.1",
|
|
137
|
+
"@babel/core": "7.24.4",
|
|
138
|
+
"@babel/plugin-proposal-decorators": "7.24.1",
|
|
139
|
+
"@babel/plugin-transform-modules-commonjs": "7.24.1",
|
|
140
|
+
"@babel/preset-env": "7.24.4",
|
|
141
|
+
"@babel/preset-typescript": "7.24.1",
|
|
142
|
+
"@commitlint/cli": "19.2.1",
|
|
143
|
+
"@commitlint/config-conventional": "19.1.0",
|
|
144
|
+
"@commitlint/prompt": "19.2.0",
|
|
145
|
+
"@jest/globals": "29.7.0",
|
|
30
146
|
"@semantic-release/changelog": "6.0.3",
|
|
31
|
-
"@semantic-release/commit-analyzer": "
|
|
147
|
+
"@semantic-release/commit-analyzer": "12.0.0",
|
|
32
148
|
"@semantic-release/exec": "6.0.3",
|
|
33
149
|
"@semantic-release/git": "10.0.1",
|
|
34
|
-
"@semantic-release/github": "
|
|
35
|
-
"@semantic-release/release-notes-generator": "
|
|
36
|
-
"@types/
|
|
37
|
-
"@types/
|
|
38
|
-
"@
|
|
39
|
-
"@typescript-eslint/
|
|
40
|
-
"@typescript-eslint/parser": "5.57.1",
|
|
150
|
+
"@semantic-release/github": "10.0.2",
|
|
151
|
+
"@semantic-release/release-notes-generator": "12.1.0",
|
|
152
|
+
"@types/lodash.clonedeep": "4.5.9",
|
|
153
|
+
"@types/node": "20.11.30",
|
|
154
|
+
"@typescript-eslint/eslint-plugin": "7.3.1",
|
|
155
|
+
"@typescript-eslint/parser": "7.3.1",
|
|
41
156
|
"commitizen": "4.3.0",
|
|
42
|
-
"
|
|
43
|
-
"eslint
|
|
44
|
-
"eslint-
|
|
45
|
-
"eslint-plugin-
|
|
157
|
+
"concurrently": "8.2.2",
|
|
158
|
+
"eslint": "8.57.0",
|
|
159
|
+
"eslint-config-prettier": "9.1.0",
|
|
160
|
+
"eslint-plugin-import": "2.29.1",
|
|
161
|
+
"eslint-plugin-jest": "27.9.0",
|
|
46
162
|
"eslint-plugin-no-loops": "0.3.0",
|
|
47
163
|
"eslint-plugin-no-only-tests": "3.1.0",
|
|
48
|
-
"eslint-plugin-prettier": "
|
|
164
|
+
"eslint-plugin-prettier": "5.1.3",
|
|
49
165
|
"eslint-plugin-sort-keys-fix": "1.1.2",
|
|
50
|
-
"husky": "
|
|
51
|
-
"jest": "29.
|
|
52
|
-
"jest-extended": "
|
|
53
|
-
"
|
|
166
|
+
"husky": "9.0.11",
|
|
167
|
+
"jest": "29.7.0",
|
|
168
|
+
"jest-extended": "4.0.2",
|
|
169
|
+
"jest-mock": "29.7.0",
|
|
170
|
+
"json-sort-cli": "4.0.2",
|
|
171
|
+
"lint-staged": "15.2.2",
|
|
54
172
|
"markdown-toc": "1.2.0",
|
|
55
|
-
"prettier": "2.
|
|
56
|
-
"rimraf": "
|
|
57
|
-
"semantic-release": "
|
|
173
|
+
"prettier": "3.2.5",
|
|
174
|
+
"rimraf": "5.0.5",
|
|
175
|
+
"semantic-release": "22.0.12",
|
|
58
176
|
"source-map-support": "0.5.21",
|
|
59
|
-
"ts-
|
|
60
|
-
"ts-
|
|
61
|
-
"
|
|
62
|
-
"tsc-
|
|
63
|
-
"
|
|
64
|
-
"typedoc
|
|
65
|
-
"
|
|
177
|
+
"ts-cleaner": "1.0.5",
|
|
178
|
+
"ts-jest": "29.1.2",
|
|
179
|
+
"ts-node": "10.9.2",
|
|
180
|
+
"tsc-alias": "1.8.8",
|
|
181
|
+
"tsc-watch": "6.0.4",
|
|
182
|
+
"typedoc": "0.25.12",
|
|
183
|
+
"typedoc-plugin-markdown": "3.17.1",
|
|
184
|
+
"typescript": "5.4.3"
|
|
66
185
|
},
|
|
67
186
|
"engines": {
|
|
68
|
-
"node": "
|
|
69
|
-
"npm": "
|
|
70
|
-
}
|
|
71
|
-
"files": [
|
|
72
|
-
"lib",
|
|
73
|
-
"package-lock.json"
|
|
74
|
-
],
|
|
75
|
-
"homepage": "https://github.com/beecode-rs/msh-util#readme",
|
|
76
|
-
"keywords": [],
|
|
77
|
-
"license": "mit",
|
|
78
|
-
"lint-staged": {
|
|
79
|
-
"src/**/*.{ts,tsx,js,jsx}": "eslint"
|
|
80
|
-
},
|
|
81
|
-
"main": "lib/index.js",
|
|
82
|
-
"name": "@beecode/msh-util",
|
|
83
|
-
"repository": {
|
|
84
|
-
"type": "git",
|
|
85
|
-
"url": "https://github.com/beecode-rs/msh-util.git"
|
|
86
|
-
},
|
|
87
|
-
"scripts": {
|
|
88
|
-
"audit:fix": "npx --yes npm-force-resolutions",
|
|
89
|
-
"build": "npm run clean && npm run tsc && npm run tsc:alias",
|
|
90
|
-
"build:on-success": "npm run tsc:alias",
|
|
91
|
-
"build:watch": "npm run tsc:watch --preserveWatchOutput --onSuccess 'npm run tsc:cleaner' --onCompilationComplete 'npm run build:on-success'",
|
|
92
|
-
"bump-version": "npm --no-git-tag-version version",
|
|
93
|
-
"clean": "rimraf ./lib/*",
|
|
94
|
-
"commit": "git-cz",
|
|
95
|
-
"doc:api": "npx typedoc",
|
|
96
|
-
"doc:toc": "npx markdown-toc -i README.md",
|
|
97
|
-
"docker:build": "docker build -f .docker/Dockerfile -t bc-msh-util .",
|
|
98
|
-
"docker:exec": "docker run --rm bc-msh-util",
|
|
99
|
-
"docker:exec:sh": "docker run --rm -it bc-msh-util sh",
|
|
100
|
-
"docker:rmi": "docker rmi bc-msh-util",
|
|
101
|
-
"eslint": "eslint . --quiet",
|
|
102
|
-
"eslint:fix": "npm run eslint --fix",
|
|
103
|
-
"initial-setup": "npm run initial-setup:husky && npm run initial-setup:git-config",
|
|
104
|
-
"initial-setup:git-config": "git config include.path ../.git-config",
|
|
105
|
-
"initial-setup:husky": "npx husky install",
|
|
106
|
-
"lint": "npm run prettier && npm run eslint",
|
|
107
|
-
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
|
|
108
|
-
"pack": "npm pack --pack-destination=./packages",
|
|
109
|
-
"prettier": "prettier --check {**/*,*}.{js,json,jsx,ts,tsx}",
|
|
110
|
-
"prettier:fix": "prettier --write {**/*,*}.{js,json,jsx,ts,tsx}",
|
|
111
|
-
"semantic-release": "semantic-release",
|
|
112
|
-
"semantic-release:check": "npm run semantic-release --dry-run --no-ci",
|
|
113
|
-
"test": "npm run test:unit && npm run test:int ",
|
|
114
|
-
"test:int": "# TZ=utc jest --config=./jest-int.config.js",
|
|
115
|
-
"test:unit": "TZ=utc jest --config=./jest-unit.config.js",
|
|
116
|
-
"test:unit:coverage": "npm run test:unit --coverage",
|
|
117
|
-
"test:unit:coverage:publish": "codecov",
|
|
118
|
-
"tsc": "tsc -p ./tsconfig-build.json",
|
|
119
|
-
"tsc:alias": "tsc-alias",
|
|
120
|
-
"tsc:check": "npm run tsc --noEmit",
|
|
121
|
-
"tsc:check:list-files": "npm run tsc:check --listFiles",
|
|
122
|
-
"tsc:cleaner": "ts-cleaner --dist lib",
|
|
123
|
-
"tsc:cleaner:watch": "npm run tsc:cleaner --watch",
|
|
124
|
-
"tsc:time": "npm run tsc --diagnostics",
|
|
125
|
-
"tsc:watch": "tsc-watch -p tsconfig-build.json"
|
|
126
|
-
},
|
|
127
|
-
"types": "lib/index.d.ts",
|
|
128
|
-
"version": "1.2.0"
|
|
187
|
+
"node": ">=14",
|
|
188
|
+
"npm": ">=6"
|
|
189
|
+
}
|
|
129
190
|
}
|
package/lib/array-util.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.arrayUtil = void 0;
|
|
4
|
-
exports.arrayUtil = {
|
|
5
|
-
/**
|
|
6
|
-
* Check if array element is not empty
|
|
7
|
-
* @template T
|
|
8
|
-
* @param {T | null | undefined} value
|
|
9
|
-
* @return {value is T}
|
|
10
|
-
* @example
|
|
11
|
-
* const notEmptyArray = [0, 1, 2, null, undefined, ''].filter(arrayUtil.notEmpty))
|
|
12
|
-
* console.log(notEmptyArray)// [0, 1, 2, '']
|
|
13
|
-
*/
|
|
14
|
-
notEmpty: (value) => {
|
|
15
|
-
return value !== null && value !== undefined;
|
|
16
|
-
},
|
|
17
|
-
/**
|
|
18
|
-
* Check if array element is not falsy
|
|
19
|
-
* @template T
|
|
20
|
-
* @param {T | null | undefined} value
|
|
21
|
-
* @return {value is T}
|
|
22
|
-
* @example
|
|
23
|
-
* const notFalsyArray = [0, 1, 2, null, undefined, ''].filter(arrayUtil.notFalsy))
|
|
24
|
-
* console.log(notFalsyArray)// [1, 2]
|
|
25
|
-
*/
|
|
26
|
-
notFalsy: (value) => {
|
|
27
|
-
return !!value;
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=array-util.js.map
|
package/lib/array-util.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array-util.js","sourceRoot":"","sources":["../src/array-util.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG;IACxB;;;;;;;;OAQG;IACH,QAAQ,EAAE,CAAI,KAA2B,EAAc,EAAE;QACxD,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAA;IAC7C,CAAC;IACD;;;;;;;;OAQG;IACH,QAAQ,EAAE,CAAI,KAA2B,EAAc,EAAE;QACxD,OAAO,CAAC,CAAC,KAAK,CAAA;IACf,CAAC;CACD,CAAA"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.classFactoryPattern = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* This is a wrapper that easily converts class constructor call (`new className(..constructorParams)`) into function call (`classNameFactory(..constructorParams)`)
|
|
6
|
-
* @param {C} classType
|
|
7
|
-
* @template C
|
|
8
|
-
* @return {(...args: ConstructorParameters<C>) => InstanceType<C>}
|
|
9
|
-
* @example
|
|
10
|
-
* export class SomeClass {
|
|
11
|
-
* protected _a: string
|
|
12
|
-
*
|
|
13
|
-
* constructor(params: { a: string }) {
|
|
14
|
-
* const { a } = params
|
|
15
|
-
* this._a = a
|
|
16
|
-
* }
|
|
17
|
-
* }
|
|
18
|
-
*
|
|
19
|
-
* export const someClassFactory = classFactoryPattern(SomeClass)
|
|
20
|
-
*
|
|
21
|
-
* // using
|
|
22
|
-
* const someClassInstance = someClassFactory({ a: 'test' })
|
|
23
|
-
*/
|
|
24
|
-
const classFactoryPattern = (classType) => {
|
|
25
|
-
return (...args) => {
|
|
26
|
-
return new classType(...args);
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
exports.classFactoryPattern = classFactoryPattern;
|
|
30
|
-
//# sourceMappingURL=class-factory-pattern.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"class-factory-pattern.js","sourceRoot":"","sources":["../src/class-factory-pattern.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACI,MAAM,mBAAmB,GAAG,CAClC,SAAY,EAC+C,EAAE;IAC7D,OAAO,CAAC,GAAG,IAA8B,EAAmB,EAAE;QAC7D,OAAO,IAAI,SAAS,CAAC,GAAG,IAAI,CAAoB,CAAA;IACjD,CAAC,CAAA;AACF,CAAC,CAAA;AANY,QAAA,mBAAmB,uBAM/B"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.expressErrorHandler = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Wrap async express http request end return promise or call next on catch
|
|
6
|
-
* @param _target
|
|
7
|
-
* @param _key
|
|
8
|
-
* @param descriptor
|
|
9
|
-
* @example
|
|
10
|
-
* export class RootController {
|
|
11
|
-
* /@expressErrorHandler
|
|
12
|
-
* async login(req: Request, res: Response): Promise<void> {
|
|
13
|
-
* const { username, password } = validationUtil().sanitize(req.body, postLoginBodySchema)
|
|
14
|
-
* const result = await authorizationUseCase.login({ username, password })
|
|
15
|
-
* res.json(result)
|
|
16
|
-
* }
|
|
17
|
-
* }
|
|
18
|
-
*/
|
|
19
|
-
const expressErrorHandler = (_target, _key, descriptor) => {
|
|
20
|
-
const originalMethod = descriptor.value;
|
|
21
|
-
descriptor.value = function () {
|
|
22
|
-
const next = arguments[2]; // eslint-disable-line prefer-rest-params
|
|
23
|
-
return Promise.resolve(originalMethod.apply(this, arguments)).catch(next); // eslint-disable-line prefer-rest-params
|
|
24
|
-
};
|
|
25
|
-
return descriptor;
|
|
26
|
-
};
|
|
27
|
-
exports.expressErrorHandler = expressErrorHandler;
|
|
28
|
-
//# sourceMappingURL=error-handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/express/error-handler.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACI,MAAM,mBAAmB,GAAG,CAAC,OAAY,EAAE,IAAY,EAAE,UAAwC,EAAO,EAAE;IAChH,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAA;IACvC,UAAU,CAAC,KAAK,GAAG;QAClB,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA,CAAC,yCAAyC;QAEnE,OAAO,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA,CAAC,yCAAyC;IACpH,CAAC,CAAA;IAED,OAAO,UAAU,CAAA;AAClB,CAAC,CAAA;AATY,QAAA,mBAAmB,uBAS/B"}
|
package/lib/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * from './express/error-handler';
|
|
2
|
-
export * from './singleton/async';
|
|
3
|
-
export * from './singleton/pattern';
|
|
4
|
-
export * from './class-factory-pattern';
|
|
5
|
-
export * from './joi-util';
|
|
6
|
-
export * from './memoize-factory';
|
|
7
|
-
export * from './object-util';
|
|
8
|
-
export * from './regex-util';
|
|
9
|
-
export * from './single-threshold-promise';
|
|
10
|
-
export * from './string-util';
|
|
11
|
-
export * from './time-util';
|
|
12
|
-
export * from './timeout';
|
|
13
|
-
export * from './type-util';
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AAEzC,cAAc,qBAAqB,CAAA;AAEnC,cAAc,uBAAuB,CAAA;AAErC,cAAc,2BAA2B,CAAA;AAEzC,cAAc,cAAc,CAAA;AAE5B,cAAc,qBAAqB,CAAA;AAEnC,cAAc,iBAAiB,CAAA;AAE/B,cAAc,gBAAgB,CAAA;AAE9B,cAAc,8BAA8B,CAAA;AAE5C,cAAc,iBAAiB,CAAA;AAE/B,cAAc,eAAe,CAAA;AAE7B,cAAc,aAAa,CAAA;AAE3B,cAAc,eAAe,CAAA"}
|
package/lib/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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("./express/error-handler"), exports);
|
|
18
|
-
__exportStar(require("./singleton/async"), exports);
|
|
19
|
-
__exportStar(require("./singleton/pattern"), exports);
|
|
20
|
-
__exportStar(require("./class-factory-pattern"), exports);
|
|
21
|
-
__exportStar(require("./joi-util"), exports);
|
|
22
|
-
__exportStar(require("./memoize-factory"), exports);
|
|
23
|
-
__exportStar(require("./object-util"), exports);
|
|
24
|
-
__exportStar(require("./regex-util"), exports);
|
|
25
|
-
__exportStar(require("./single-threshold-promise"), exports);
|
|
26
|
-
__exportStar(require("./string-util"), exports);
|
|
27
|
-
__exportStar(require("./time-util"), exports);
|
|
28
|
-
__exportStar(require("./timeout"), exports);
|
|
29
|
-
__exportStar(require("./type-util"), exports);
|
|
30
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAAyC;AAEzC,sDAAmC;AAEnC,wDAAqC;AAErC,4DAAyC;AAEzC,+CAA4B;AAE5B,sDAAmC;AAEnC,kDAA+B;AAE/B,iDAA8B;AAE9B,+DAA4C;AAE5C,kDAA+B;AAE/B,gDAA6B;AAE7B,8CAA2B;AAE3B,gDAA6B"}
|
package/lib/joi-util.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JoiUtil = exports.ErrorWithPayload = void 0;
|
|
4
|
-
class ErrorWithPayload extends Error {
|
|
5
|
-
constructor(message, payload) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.payload = payload;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.ErrorWithPayload = ErrorWithPayload;
|
|
11
|
-
/**
|
|
12
|
-
* This is a simple wrapper around Joi validation with two functions exposed validate and sanitize. If object is not valid function throws an error.
|
|
13
|
-
* @example
|
|
14
|
-
* type SomeType = {
|
|
15
|
-
* a: string
|
|
16
|
-
* b: number
|
|
17
|
-
* }
|
|
18
|
-
* const someSchema = Joi.object<SomeType>().keys({
|
|
19
|
-
* a: Joi.string().required(),
|
|
20
|
-
* b: Joi.number().required(),
|
|
21
|
-
* }).required()
|
|
22
|
-
*
|
|
23
|
-
* const joiUtil = new JoiUtil()
|
|
24
|
-
*
|
|
25
|
-
* // using
|
|
26
|
-
* const invalidObject = joiUtil.validate({}, someSchema) // validate throws an error
|
|
27
|
-
* const validObject = joiUtil.validate({ a: 'a', b: 1 }, someSchema)
|
|
28
|
-
*/
|
|
29
|
-
class JoiUtil {
|
|
30
|
-
/**
|
|
31
|
-
* Validate and clean object
|
|
32
|
-
* @template T
|
|
33
|
-
* @template Joi
|
|
34
|
-
* @param {any} objectToValidate
|
|
35
|
-
* @param {Joi.Schema | Joi.ObjectSchema<T>} schema
|
|
36
|
-
* @param {validationOptions} [validationOptions]
|
|
37
|
-
* @returns {T} expected object after validation
|
|
38
|
-
*/
|
|
39
|
-
sanitize(objectToValidate, schema, validationOptions) {
|
|
40
|
-
return this._validate(objectToValidate, schema, Object.assign(Object.assign({}, validationOptions), { stripUnknown: true }));
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Only validate properties specified in validation schema
|
|
44
|
-
* @template T
|
|
45
|
-
* @template Joi
|
|
46
|
-
* @param {any} objectToValidate
|
|
47
|
-
* @param {Joi.Schema | Joi.ObjectSchema<T>} schema
|
|
48
|
-
* @param {validationOptions} [validationOptions]
|
|
49
|
-
* @returns {T} expected object after validation
|
|
50
|
-
*/
|
|
51
|
-
validate(objectToValidate, schema, validationOptions) {
|
|
52
|
-
return this._validate(objectToValidate, schema, validationOptions);
|
|
53
|
-
}
|
|
54
|
-
_validate(objectToValidate, schema, validationOptions) {
|
|
55
|
-
const { error: validationError, value } = schema.validate(objectToValidate, validationOptions);
|
|
56
|
-
if (validationError) {
|
|
57
|
-
throw new ErrorWithPayload(validationError.message.split('"').join("'"), validationError);
|
|
58
|
-
}
|
|
59
|
-
return value;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.JoiUtil = JoiUtil;
|
|
63
|
-
//# sourceMappingURL=joi-util.js.map
|
package/lib/joi-util.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"joi-util.js","sourceRoot":"","sources":["../src/joi-util.ts"],"names":[],"mappings":";;;AAEA,MAAa,gBAAoB,SAAQ,KAAK;IAG7C,YAAY,OAAe,EAAE,OAAU;QACtC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACvB,CAAC;CACD;AAPD,4CAOC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,OAAO;IACnB;;;;;;;;OAQG;IACH,QAAQ,CAAI,gBAAqB,EAAE,MAAgC,EAAE,iBAAqC;QACzG,OAAO,IAAI,CAAC,SAAS,CAAI,gBAAgB,EAAE,MAAM,kCAAO,iBAAiB,KAAE,YAAY,EAAE,IAAI,IAAG,CAAA;IACjG,CAAC;IAED;;;;;;;;OAQG;IACH,QAAQ,CAAI,gBAAqB,EAAE,MAAgC,EAAE,iBAAqC;QACzG,OAAO,IAAI,CAAC,SAAS,CAAI,gBAAgB,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAA;IACtE,CAAC;IAES,SAAS,CAAI,gBAAqB,EAAE,MAAgC,EAAE,iBAAqC;QACpH,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,CAAA;QAC9F,IAAI,eAAe,EAAE;YACpB,MAAM,IAAI,gBAAgB,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,eAAe,CAAC,CAAA;SACzF;QAED,OAAO,KAAU,CAAA;IAClB,CAAC;CACD;AAnCD,0BAmCC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memoize-factory.d.ts","sourceRoot":"","sources":["../src/memoize-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,kDAW1B,CAAA"}
|
package/lib/memoize-factory.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.memoizeFactory = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* This is a simple implementation of memoize function that caches result against the parameter passed that are passed to the
|
|
6
|
-
* function so it never runs the same calculation twice.
|
|
7
|
-
* @template F
|
|
8
|
-
* @template R
|
|
9
|
-
* @param {F} factoryFn
|
|
10
|
-
* @return {F: AnyFunction<R>}
|
|
11
|
-
* @example
|
|
12
|
-
* export const sumTwoNumbersMemoize = memoizeFactory((a:number, b:number): number => a + b)
|
|
13
|
-
*
|
|
14
|
-
* // using
|
|
15
|
-
* sumTwoNumbersMemoize(5 + 10) // 15
|
|
16
|
-
*/
|
|
17
|
-
const memoizeFactory = (factoryFn) => {
|
|
18
|
-
const cache = {};
|
|
19
|
-
return ((...args) => {
|
|
20
|
-
const key = JSON.stringify(args);
|
|
21
|
-
if (key in cache) {
|
|
22
|
-
return cache[key];
|
|
23
|
-
}
|
|
24
|
-
return (cache[key] = factoryFn(...args));
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
exports.memoizeFactory = memoizeFactory;
|
|
28
|
-
//# sourceMappingURL=memoize-factory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memoize-factory.js","sourceRoot":"","sources":["../src/memoize-factory.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;GAYG;AACI,MAAM,cAAc,GAAG,CAA8B,SAAY,EAAK,EAAE;IAC9E,MAAM,KAAK,GAAuB,EAAE,CAAA;IAEpC,OAAO,CAAC,CAAC,GAAG,IAAmB,EAAK,EAAE;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QAChC,IAAI,GAAG,IAAI,KAAK,EAAE;YACjB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAA;SACjB;QAED,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACzC,CAAC,CAAM,CAAA;AACR,CAAC,CAAA;AAXY,QAAA,cAAc,kBAW1B"}
|