bootpress 7.0.0 → 7.1.0
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/README.md +2 -1
- package/helpers/index.js +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -128,7 +128,8 @@ const LogService = new LogServiceImpl();
|
|
|
128
128
|
|
|
129
129
|
app.get("/logs", LogService.findAll() as RequestHandler)
|
|
130
130
|
```
|
|
131
|
-
|
|
131
|
+
## v7.1.0 Release Notes:
|
|
132
|
+
- getOrThrow: Throws specified error when value is an empty array too.
|
|
132
133
|
## v7.0.0 Release Notes:
|
|
133
134
|
|
|
134
135
|
### Deprecated helper methods:
|
package/helpers/index.js
CHANGED
|
@@ -3,13 +3,17 @@ const { HttpError } = require("../types");
|
|
|
3
3
|
const allowedPrimitives = ["string", "number", "boolean", "integer"];
|
|
4
4
|
|
|
5
5
|
function getOrThrow(data, error) {
|
|
6
|
-
if (data === null || data === undefined) {
|
|
6
|
+
if (data === null || data === undefined || isEmptyArray(data)) {
|
|
7
7
|
throw error;
|
|
8
8
|
} else {
|
|
9
9
|
return data;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
function isEmptyArray(x){
|
|
14
|
+
return Array.isArray(x) && x.length < 1;
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
function getOrElse(data, defaultValue) {
|
|
14
18
|
if (data === null || data === undefined) {
|
|
15
19
|
return defaultValue;
|