From 0359e3382facb98a328234249a98aac0c48881c2 Mon Sep 17 00:00:00 2001 From: Ciak Date: Thu, 21 Feb 2019 16:06:49 +0100 Subject: [PATCH] static function Fix --- dist/index.js | 4 ++-- lib/index.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index d21e264..e6b623c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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; } diff --git a/lib/index.ts b/lib/index.ts index 0825906..efd984b 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -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; }