From e59eeed4af49501d925a798c4702088728af630e Mon Sep 17 00:00:00 2001 From: umang Date: Tue, 22 Feb 2022 17:44:11 +0530 Subject: [PATCH] ref #29, added bind to function --- dist/index.js | 9 ++++++--- package.json | 10 +++++++--- src/index.js | 8 ++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/dist/index.js b/dist/index.js index d2e0e14..baf158e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -53,7 +53,10 @@ var jsLogger = /*#__PURE__*/function () { if (this.interval) return; this.interval = setInterval(function () { - return _this.ajaxCall(); + //FIXME: replace with one function for bind and also calling + _this.ajaxCall.bind(_this); + + _this.ajaxCall(); }, this.timeInterval); } }, { @@ -244,8 +247,8 @@ var jsLogger = /*#__PURE__*/function () { } if (!pending_logs || pending_logs === 0) { - this.isAjaxCompleted = true; - this.endCheck(); + this.isAjaxCompleted = true; //this.endCheck(); + return; } diff --git a/package.json b/package.json index b685e88..bde5c11 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { - "name": "jslogger", - "version": "0.0.1", + "name": "@nudjur/js-logger", + "version": "0.0.4", "description": "To add structured logs in your node project", "main": "dist/index.js", "directories": { "example": "example" }, + "registry-url": "https://registry.npmjs.org/", "scripts": { "build": "npx babel src --out-dir dist", "test": "echo \"Error: no test specified\" && exit 1" @@ -28,5 +29,8 @@ "@babel/cli": "^7.15.7", "@babel/core": "^7.15.8", "@babel/preset-env": "^7.15.8" - } + }, + "keywords": [ + "js-logger" + ] } diff --git a/src/index.js b/src/index.js index 041a6b0..bc8762e 100644 --- a/src/index.js +++ b/src/index.js @@ -24,7 +24,11 @@ class jsLogger { startCheck() { if (this.interval) return; - this.interval = setInterval(() => this.ajaxCall(), this.timeInterval); + this.interval = setInterval(() => { + //FIXME: replace with one function for bind and also calling + this.ajaxCall.bind(this); + this.ajaxCall(); + }, this.timeInterval); } endCheck() { if (!this.interval) return; @@ -211,7 +215,7 @@ class jsLogger { if (!pending_logs || pending_logs === 0) { this.isAjaxCompleted = true; - this.endCheck(); + //this.endCheck(); return; }