Socket
Socket
Sign inDemoInstall

notifications-library

Package Overview
Dependencies
1
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.2.1

50

dist/notifications-library.cjs.development.js

@@ -300,11 +300,10 @@ 'use strict';

if (_this4.config) {
var body = JSON.stringify({
readAt: Date.now()
});
return Promise.resolve(fetch(_this4.config.updateUrl + "/" + id, {
method: 'PUT',
method: 'PATCH',
headers: {
'Content-Type': 'application/json'
},
body: body
body: JSON.stringify({
readAt: Date.now()
})
})).then(function (response) {

@@ -324,26 +323,7 @@ if (!response.ok) {

try {
var _temp10 = function _temp10(_result5) {
if (_exit5) return _result5;
_this5.notificationsList.forEach(function (notification) {
if (!notification.readAt) {
notification.readAt = Date.now();
} else {
throw new Error('All the notifications are marked as read');
}
});
};
var _exit5 = false;
var _this5 = this;
var _temp9 = function () {
if (_this5.config) {
return Promise.resolve(fetch("" + _this5.config.updateUrl, {
method: 'PUT'
})).then(function (response) {
if (!response.ok) {
throw new Error(response.statusText);
}
});
}
}();
return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(_temp10) : _temp10(_temp9));
var _temp9 = _forOf(_this5.notificationsList, function (notification) {
return Promise.resolve(_this5.markNotificationAsRead(notification.id)).then(function () {});
});
return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function () {}) : void 0);
} catch (e) {

@@ -355,4 +335,4 @@ return Promise.reject(e);

try {
var _temp12 = function _temp12(_result6) {
if (_exit6) return _result6;
var _temp11 = function _temp11(_result5) {
if (_exit5) return _result5;
_this6.notificationsList = _this6.notificationsList.filter(function (notification) {

@@ -362,3 +342,3 @@ return notification.id !== id;

};
var _exit6 = false;
var _exit5 = false;
var _this6 = this;

@@ -368,3 +348,3 @@ if (!id) {

}
var _temp11 = function () {
var _temp10 = function () {
if (_this6.config) {

@@ -380,3 +360,3 @@ return Promise.resolve(fetch(_this6.config.updateUrl + "/" + id, {

}();
return Promise.resolve(_temp11 && _temp11.then ? _temp11.then(_temp12) : _temp12(_temp11));
return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(_temp11) : _temp11(_temp10));
} catch (e) {

@@ -389,6 +369,6 @@ return Promise.reject(e);

var _this7 = this;
var _temp13 = _forOf(_this7.notificationsList, function (notification) {
var _temp12 = _forOf(_this7.notificationsList, function (notification) {
return Promise.resolve(_this7.deleteNotificationByID(notification.id)).then(function () {});
});
return Promise.resolve(_temp13 && _temp13.then ? _temp13.then(function () {}) : void 0);
return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(function () {}) : void 0);
} catch (e) {

@@ -395,0 +375,0 @@ return Promise.reject(e);

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("uuid");const n=function(){function t(){}return t.prototype.then=function(n,e){const i=new t,o=this.s;if(o){const t=1&o?n:e;if(t){try{r(i,1,t(this.v))}catch(t){r(i,2,t)}return i}return this}return this.o=function(t){try{const o=t.v;1&t.s?r(i,1,n?n(o):o):e?r(i,1,e(o)):r(i,2,o)}catch(t){r(i,2,t)}},i},t}();function r(t,e,i){if(!t.s){if(i instanceof n){if(!i.s)return void(i.o=r.bind(null,t,e));1&e&&(e=i.s),i=i.v}if(i&&i.then)return void i.then(r.bind(null,t,e),r.bind(null,t,2));t.s=e,t.v=i;const o=t.o;o&&o(t)}}function e(t){return t instanceof n&&1&t.s}const i="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator"))),exports.NotificationCenter=function(){function o(){this.notificationsList=[],this.subscribers=[],this.notificationSender="defaultSender"}var f=o.prototype;return f.setConfig=function(t){this.config=t},f.getConfig=function(){return this.config},f.setSender=function(t){this.notificationSender=t},f.addSubscriber=function(t){this.subscribers.push(t)},f.notifySubscribers=function(t){this.subscribers.forEach((function(n){return n(t)}))},f.getAllNotifications=function(){try{var t=function(t){return n?t:r.notificationsList},n=!1,r=this,e=function(){if(r.config)return Promise.resolve(fetch(r.config.fetchUrl)).then((function(t){if(!t.ok)throw new Error(t.statusText);return Promise.resolve(t.json()).then((function(t){r.notificationsList=t}))}))}();return Promise.resolve(e&&e.then?e.then(t):t(e))}catch(t){return Promise.reject(t)}},f.getNotificationByID=function(t){try{var n=function(n){if(r)return n;var i=e.notificationsList.find((function(n){return n.id===t}))||null;if(i)return i;throw new Error("Notification not found")},r=!1,e=this,i=function(){if(e.config)return Promise.resolve(fetch(e.config.fetchUrl+"/"+t)).then((function(t){if(!t.ok)throw new Error(t.statusText)}))}();return Promise.resolve(i&&i.then?i.then(n):n(i))}catch(t){return Promise.reject(t)}},f.sendNotification=function(n){try{var r=function(t){return e?t:(i.notificationsList.push(o),i.notifySubscribers(o),o)},e=!1,i=this,o={id:t.v4(),data:n,sender:i.notificationSender,createdAt:Date.now(),readAt:void 0},f=function(){if(i.config)return Promise.resolve(fetch(i.config.createUrl,{method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})).then((function(t){if(!t.ok)throw new Error(t.statusText)}))}();return Promise.resolve(f&&f.then?f.then(r):r(f))}catch(t){return Promise.reject(t)}},f.markNotificationAsRead=function(t){try{var n=function(n){if(r)return n;var i=e.notificationsList.find((function(n){return n.id===t}));if(!i)throw new Error("Notification not found");i.readAt=Date.now(),e.notifySubscribers(i)},r=!1,e=this,i=function(){if(e.config){var n=JSON.stringify({readAt:Date.now()});return Promise.resolve(fetch(e.config.updateUrl+"/"+t,{method:"PUT",headers:{"Content-Type":"application/json"},body:n})).then((function(t){if(!t.ok)throw new Error(t.statusText)}))}}();return Promise.resolve(i&&i.then?i.then(n):n(i))}catch(t){return Promise.reject(t)}},f.markAllAsRead=function(){try{var t=function(t){if(n)return t;r.notificationsList.forEach((function(t){if(t.readAt)throw new Error("All the notifications are marked as read");t.readAt=Date.now()}))},n=!1,r=this,e=function(){if(r.config)return Promise.resolve(fetch(""+r.config.updateUrl,{method:"PUT"})).then((function(t){if(!t.ok)throw new Error(t.statusText)}))}();return Promise.resolve(e&&e.then?e.then(t):t(e))}catch(t){return Promise.reject(t)}},f.deleteNotificationByID=function(t){try{var n=function(n){if(r)return n;e.notificationsList=e.notificationsList.filter((function(n){return n.id!==t}))},r=!1,e=this;if(!t)throw new Error("Invalid ID");var i=function(){if(e.config)return Promise.resolve(fetch(e.config.updateUrl+"/"+t,{method:"DELETE"})).then((function(t){if(!t.ok)throw new Error(t.statusText)}))}();return Promise.resolve(i&&i.then?i.then(n):n(i))}catch(t){return Promise.reject(t)}},f.deleteAllNotifications=function(){try{var t=this,o=function(t,o,f){if("function"==typeof t[i]){var c,s,u,a=t[i]();if(function t(i){try{for(;!(c=a.next()).done;)if((i=o(c.value))&&i.then){if(!e(i))return void i.then(t,u||(u=r.bind(null,s=new n,2)));i=i.v}s?r(s,1,i):s=i}catch(t){r(s||(s=new n),2,t)}}(),a.return){var h=function(t){try{c.done||a.return()}catch(t){}return t};if(s&&s.then)return s.then(h,(function(t){throw h(t)}));h()}return s}if(!("length"in t))throw new TypeError("Object is not iterable");for(var l=[],d=0;d<t.length;d++)l.push(t[d]);return function(t,i,o){var f,c,s=-1;return function o(u){try{for(;++s<t.length;)if((u=i(s))&&u.then){if(!e(u))return void u.then(o,c||(c=r.bind(null,f=new n,2)));u=u.v}f?r(f,1,u):f=u}catch(t){r(f||(f=new n),2,t)}}(),f}(l,(function(t){return o(l[t])}))}(t.notificationsList,(function(n){return Promise.resolve(t.deleteNotificationByID(n.id)).then((function(){}))}));return Promise.resolve(o&&o.then?o.then((function(){})):void 0)}catch(t){return Promise.reject(t)}},o}();
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("uuid");const n=function(){function t(){}return t.prototype.then=function(n,r){const i=new t,o=this.s;if(o){const t=1&o?n:r;if(t){try{e(i,1,t(this.v))}catch(t){e(i,2,t)}return i}return this}return this.o=function(t){try{const o=t.v;1&t.s?e(i,1,n?n(o):o):r?e(i,1,r(o)):e(i,2,o)}catch(t){e(i,2,t)}},i},t}();function e(t,r,i){if(!t.s){if(i instanceof n){if(!i.s)return void(i.o=e.bind(null,t,r));1&r&&(r=i.s),i=i.v}if(i&&i.then)return void i.then(e.bind(null,t,r),e.bind(null,t,2));t.s=r,t.v=i;const o=t.o;o&&o(t)}}function r(t){return t instanceof n&&1&t.s}const i="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function o(t,o,c){if("function"==typeof t[i]){var f,s,u,a=t[i]();if(function t(i){try{for(;!((f=a.next()).done||c&&c());)if((i=o(f.value))&&i.then){if(!r(i))return void i.then(t,u||(u=e.bind(null,s=new n,2)));i=i.v}s?e(s,1,i):s=i}catch(t){e(s||(s=new n),2,t)}}(),a.return){var h=function(t){try{f.done||a.return()}catch(t){}return t};if(s&&s.then)return s.then(h,(function(t){throw h(t)}));h()}return s}if(!("length"in t))throw new TypeError("Object is not iterable");for(var l=[],d=0;d<t.length;d++)l.push(t[d]);return function(t,i,o){var c,f,s=-1;return function u(a){try{for(;++s<t.length&&(!o||!o());)if((a=i(s))&&a.then){if(!r(a))return void a.then(u,f||(f=e.bind(null,c=new n,2)));a=a.v}c?e(c,1,a):c=a}catch(t){e(c||(c=new n),2,t)}}(),c}(l,(function(t){return o(l[t])}),c)}"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator"))),exports.NotificationCenter=function(){function n(){this.notificationsList=[],this.subscribers=[],this.notificationSender="defaultSender"}var e=n.prototype;return e.setConfig=function(t){this.config=t},e.getConfig=function(){return this.config},e.setSender=function(t){this.notificationSender=t},e.addSubscriber=function(t){this.subscribers.push(t)},e.notifySubscribers=function(t){this.subscribers.forEach((function(n){return n(t)}))},e.getAllNotifications=function(){try{var t=function(t){return n?t:e.notificationsList},n=!1,e=this,r=function(){if(e.config)return Promise.resolve(fetch(e.config.fetchUrl)).then((function(t){if(!t.ok)throw new Error(t.statusText);return Promise.resolve(t.json()).then((function(t){e.notificationsList=t}))}))}();return Promise.resolve(r&&r.then?r.then(t):t(r))}catch(t){return Promise.reject(t)}},e.getNotificationByID=function(t){try{var n=function(n){if(e)return n;var i=r.notificationsList.find((function(n){return n.id===t}))||null;if(i)return i;throw new Error("Notification not found")},e=!1,r=this,i=function(){if(r.config)return Promise.resolve(fetch(r.config.fetchUrl+"/"+t)).then((function(t){if(!t.ok)throw new Error(t.statusText)}))}();return Promise.resolve(i&&i.then?i.then(n):n(i))}catch(t){return Promise.reject(t)}},e.sendNotification=function(n){try{var e=function(t){return r?t:(i.notificationsList.push(o),i.notifySubscribers(o),o)},r=!1,i=this,o={id:t.v4(),data:n,sender:i.notificationSender,createdAt:Date.now(),readAt:void 0},c=function(){if(i.config)return Promise.resolve(fetch(i.config.createUrl,{method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})).then((function(t){if(!t.ok)throw new Error(t.statusText)}))}();return Promise.resolve(c&&c.then?c.then(e):e(c))}catch(t){return Promise.reject(t)}},e.markNotificationAsRead=function(t){try{var n=function(n){if(e)return n;var i=r.notificationsList.find((function(n){return n.id===t}));if(!i)throw new Error("Notification not found");i.readAt=Date.now(),r.notifySubscribers(i)},e=!1,r=this,i=function(){if(r.config)return Promise.resolve(fetch(r.config.updateUrl+"/"+t,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({readAt:Date.now()})})).then((function(t){if(!t.ok)throw new Error(t.statusText)}))}();return Promise.resolve(i&&i.then?i.then(n):n(i))}catch(t){return Promise.reject(t)}},e.markAllAsRead=function(){try{var t=this,n=o(t.notificationsList,(function(n){return Promise.resolve(t.markNotificationAsRead(n.id)).then((function(){}))}));return Promise.resolve(n&&n.then?n.then((function(){})):void 0)}catch(t){return Promise.reject(t)}},e.deleteNotificationByID=function(t){try{var n=function(n){if(e)return n;r.notificationsList=r.notificationsList.filter((function(n){return n.id!==t}))},e=!1,r=this;if(!t)throw new Error("Invalid ID");var i=function(){if(r.config)return Promise.resolve(fetch(r.config.updateUrl+"/"+t,{method:"DELETE"})).then((function(t){if(!t.ok)throw new Error(t.statusText)}))}();return Promise.resolve(i&&i.then?i.then(n):n(i))}catch(t){return Promise.reject(t)}},e.deleteAllNotifications=function(){try{var t=this,n=o(t.notificationsList,(function(n){return Promise.resolve(t.deleteNotificationByID(n.id)).then((function(){}))}));return Promise.resolve(n&&n.then?n.then((function(){})):void 0)}catch(t){return Promise.reject(t)}},n}();
//# sourceMappingURL=notifications-library.cjs.production.min.js.map

@@ -296,11 +296,10 @@ import { v4 } from 'uuid';

if (_this4.config) {
var body = JSON.stringify({
readAt: Date.now()
});
return Promise.resolve(fetch(_this4.config.updateUrl + "/" + id, {
method: 'PUT',
method: 'PATCH',
headers: {
'Content-Type': 'application/json'
},
body: body
body: JSON.stringify({
readAt: Date.now()
})
})).then(function (response) {

@@ -320,26 +319,7 @@ if (!response.ok) {

try {
var _temp10 = function _temp10(_result5) {
if (_exit5) return _result5;
_this5.notificationsList.forEach(function (notification) {
if (!notification.readAt) {
notification.readAt = Date.now();
} else {
throw new Error('All the notifications are marked as read');
}
});
};
var _exit5 = false;
var _this5 = this;
var _temp9 = function () {
if (_this5.config) {
return Promise.resolve(fetch("" + _this5.config.updateUrl, {
method: 'PUT'
})).then(function (response) {
if (!response.ok) {
throw new Error(response.statusText);
}
});
}
}();
return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(_temp10) : _temp10(_temp9));
var _temp9 = _forOf(_this5.notificationsList, function (notification) {
return Promise.resolve(_this5.markNotificationAsRead(notification.id)).then(function () {});
});
return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function () {}) : void 0);
} catch (e) {

@@ -351,4 +331,4 @@ return Promise.reject(e);

try {
var _temp12 = function _temp12(_result6) {
if (_exit6) return _result6;
var _temp11 = function _temp11(_result5) {
if (_exit5) return _result5;
_this6.notificationsList = _this6.notificationsList.filter(function (notification) {

@@ -358,3 +338,3 @@ return notification.id !== id;

};
var _exit6 = false;
var _exit5 = false;
var _this6 = this;

@@ -364,3 +344,3 @@ if (!id) {

}
var _temp11 = function () {
var _temp10 = function () {
if (_this6.config) {

@@ -376,3 +356,3 @@ return Promise.resolve(fetch(_this6.config.updateUrl + "/" + id, {

}();
return Promise.resolve(_temp11 && _temp11.then ? _temp11.then(_temp12) : _temp12(_temp11));
return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(_temp11) : _temp11(_temp10));
} catch (e) {

@@ -385,6 +365,6 @@ return Promise.reject(e);

var _this7 = this;
var _temp13 = _forOf(_this7.notificationsList, function (notification) {
var _temp12 = _forOf(_this7.notificationsList, function (notification) {
return Promise.resolve(_this7.deleteNotificationByID(notification.id)).then(function () {});
});
return Promise.resolve(_temp13 && _temp13.then ? _temp13.then(function () {}) : void 0);
return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(function () {}) : void 0);
} catch (e) {

@@ -391,0 +371,0 @@ return Promise.reject(e);

{
"version": "0.2.0",
"version": "0.2.1",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -96,11 +96,10 @@ import {

if (this.config) {
const body = JSON.stringify({
readAt: Date.now(),
});
const response = await fetch(`${this.config.updateUrl}/${id}`, {
method: 'PUT',
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: body,
body: JSON.stringify({
readAt: Date.now(),
}),
});

@@ -123,17 +122,5 @@ if (!response.ok) {

async markAllAsRead(): Promise<void> {
if (this.config) {
const response = await fetch(`${this.config.updateUrl}`, {
method: 'PUT',
});
if (!response.ok) {
throw new Error(response.statusText);
}
for (const notification of this.notificationsList) {
await this.markNotificationAsRead(notification.id);
}
this.notificationsList.forEach(notification => {
if (!notification.readAt) {
notification.readAt = Date.now();
} else {
throw new Error('All the notifications are marked as read');
}
});
}

@@ -140,0 +127,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc