Skip to content

Commit

Permalink
static function Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciak committed Feb 21, 2019
1 parent 6b5747b commit 0359e33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ var JResponse = /** @class */ (function () {
throw new Error("'error' field must be Array (if set)");
}
var response = { success: true, count: 0, data: [], errors: [] };
if ((Array.isArray(errors) && errors.length > 0) || errors !== null) {
if ((Array.isArray(errors) && errors.length > 0) || (!Array.isArray(errors) && errors !== null)) {
response.success = false;
response.errors = errors;
}
if ((Array.isArray(data) && data.length > 0) || data !== null) {
if ((Array.isArray(data) && data.length > 0) || (!Array.isArray(data) && data !== null)) {
response.data = data;
response.count = response.data.length;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export class JResponse {
throw new Error("'error' field must be Array (if set)");
}
const response: any = {success: true, count: 0, data: [], errors: []};
if ((Array.isArray(errors) && errors.length > 0) || errors !== null) {
if ((Array.isArray(errors) && errors.length > 0) || (!Array.isArray(errors) && errors !== null)) {
response.success = false;
response.errors = errors;
}
if ((Array.isArray(data) && data.length > 0) || data !== null) {
if ((Array.isArray(data) && data.length > 0) || (!Array.isArray(data) && data !== null)) {
response.data = data;
response.count = response.data.length;
}
Expand Down

0 comments on commit 0359e33

Please sign in to comment.