Skip to content

Commit 9f6c548

Browse files
committed
Updated JSDoc and README, publisher is on npm now.
1 parent f9e35f5 commit 9f6c548

File tree

10 files changed

+809
-426
lines changed

10 files changed

+809
-426
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ This project adheres to [Semantic Versioning](https://semver.org) and follows th
66

77
---
88

9+
## [1.5.1] – 2025-04-06
10+
11+
### Added
12+
13+
- **@alphanull/publisher is on npm now!**
14+
15+
### Changed
16+
17+
- updated inline documentation
18+
- updated README.md
19+
920
## [1.5.0] – 2025-04-06
1021

1122
### Added

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
![License](https://img.shields.io/github/license/alphanull/publisher)
2-
![Version](https://img.shields.io/badge/version-1.5.0-blue)
2+
![Version](https://img.shields.io/badge/version-1.5.1-blue)
33
[![JSDoc](https://img.shields.io/badge/docs-JSDoc-blue)](./docs/publisher.md)
44
![Size](https://img.shields.io/badge/gzipped~2kb-brightgreen)
55

@@ -24,18 +24,15 @@ Whether you're building scalable web applications or complex front-end architect
2424

2525
## Installation
2626

27-
2827
### via NPM
2928

30-
**ATTN: Package is not on npm yet due to namespace clearance!**
31-
3229
```bash
33-
npm install @alphanull/publisher <<< not here yet!
30+
npm install @alphanull/publisher
3431
```
3532

3633
### via CDN
3734

38-
**Also, no CDN (yet)**
35+
**no CDN (yet)**
3936

4037
[Download latest version](https://??????) from ????????
4138

dist/publisher.min.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* Publisher – Javascript Pub/Sub library
33
* @license MIT
4-
* © 2013–2025 Frank Kudermann @ alphanull
4+
* © 2015–present Frank Kudermann @ alphanull
55
*/
6-
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).publisher={})}(this,(function(e){"use strict";const i={async:!0,handleExceptions:!1,lenientUnsubscribe:!1},n=new Map,o=new Map,t=new Map;let s=-1;function r(e,t,s){const r=t===Boolean(t)?t:s,c=void 0===r?i.lenientUnsubscribe:r,a=e=>{const i=n.get(e);if(void 0===i){if(!0===c)return;throw new Error(`Unsubscribe failed. Did not find subscriber for token: ${e}`)}l(i.topic.split("/"),i,o),n.delete(e)};if(void 0===e){if(!0===c)return;throw new Error("Unsubscribe failed. No Arguments specified.")}if(Array.isArray(e))e.forEach((e=>a(e)));else if(!isNaN(parseFloat(e))&&isFinite(e))a(e);else{if(void 0===t){if(!0===c)return;throw new Error(`Unsubscribe failed. No handler for topic based unsubscribe specified ${e}`)}for(const[,i]of n)if(i.handler===t&&i.topic===e){l(e.split("/"),i,o),n.delete(i.token);break}}}function c(e,o,t,s={}){if(!n.has(e.token))return;e.options.invocations>0&&(e.options.invocations-=1,e.options.invocations<=0&&r(e.token));const{handler:c}=e;if(!0!==s.handleExceptions&&!0!==i.handleExceptions)return c(t,o);try{return c(t,o)}catch(e){window.console&&window.console.error&&window.console.error("Exception while executing publish handler: ",e)}}function a(e,n,o={},t,s,r=[]){const c=t.get("subscribers")||new Map,d=t.get("topics");for(const[,e]of c){const{condition:t}=e.options;(void 0===t||"[object Function]"===Object.prototype.toString.call(t)&&!0===t(n,s))&&(e.position=r.push(e),e.priority=e.options.priority||0,e.async=Boolean(o.async||e.options.async||i.async))}if(e.length&&d){const i=d.get(e[0]),t=d.get("*");void 0===t&&void 0===i||(void 0!==t&&a(e.slice(1,e.length),n,o,t,s,r),void 0!==i&&a(e.slice(1,e.length),n,o,i,s,r),e.shift())}return r}function d(e,i,n){const[o]=e;void 0===n.get("topics")&&n.set("topics",new Map);const t=n.get("topics");let s=t.get(o);void 0===s&&(s=new Map,t.set(o,s)),e.length<2?(void 0===s.get("subscribers")&&s.set("subscribers",new Map),s.get("subscribers").set(i.token,i)):(e.shift(),d(e,i,s))}function l(e,i,n){const[o]=e,t=n.get("topics"),s=t.get(o),r=s.get("subscribers");e.length<2?(r.delete(i.token),0===r.size&&s.delete("subscribers")):(e.shift(),l(e,i,s)),s.has("topics")&&0===s.get("topics").size&&s.delete("topics"),0===t.get(o).size&&t.delete(o)}e.configure=function(e){if(!e)throw new Error("Publisher configure: no options specified");void 0!==e.async&&(i.async=e.async),void 0!==e.handleExceptions&&(i.handleExceptions=e.handleExceptions),void 0!==e.lenientUnsubscribe&&(i.lenientUnsubscribe=e.lenientUnsubscribe)},e.publish=function(e,n,s={}){if(!0===s.persist&&t.set(e,{data:n,options:s}),e.indexOf("*")>-1)throw new Error("Publish topic cannot contain any wildcards.");const r=a(e.split("/"),n,s,o,e);let d;r.sort(((e,i)=>e.priority===i.priority?e.position-i.position:e.priority>i.priority?-1:1));const l=void 0===s.async?i.async:s.async;for(;d=r.shift();)if(l)setTimeout(c.bind(null,d,e,n,s),0);else if(!1===c(d,e,n,s)&&!1!==s.cancelable)return!1},e.removePersistentMessage=function(e){t.delete(e)},e.subscribe=function(e,r,a={}){const l=s+=1;if(void 0===e)throw new Error('Subscribe failed - "undefined" Topic.');if(e.includes("undefined"))throw new Error(`Subscribe for '${e}' failed - found 'undefined' in topic, this is almost always an error: ${l}`);if(void 0===r)throw new Error(`Subscribe for '${e}' failed - "undefined" Handler`);const f={token:l,topic:e,handler:r,options:a};if(n.set(l,f),d(e.split("/"),f,o),!0!==a.persist)return l;const p=new RegExp(`^${e.replace("*","(.+)")}(/.+)?$`);for(const[e,n]of t){if(e.match(p)){if(void 0===n.options.async?i.async:n.options.async)setTimeout(c.bind(null,f,e,n.data,a),0);else if(!1===c(f,e,n.data,a)&&!0===a.cancelable)break}}return l},e.unsubscribe=r}));
6+
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).publisher={})}(this,(function(e){"use strict";let i=-1;const n={async:!0,handleExceptions:!1,lenientUnsubscribe:!1},o=new Map,t=new Map,s=new Map;function r(e,i,s){const r=i===Boolean(i)?i:s,c=void 0===r?n.lenientUnsubscribe:r,a=e=>{const i=o.get(e);if(void 0===i){if(!0===c)return;throw new Error(`Unsubscribe failed. Did not find subscriber for token: ${e}`)}l(i.topic.split("/"),i,t),o.delete(e)};if(void 0===e){if(!0===c)return;throw new Error("Unsubscribe failed. No Arguments specified.")}if(Array.isArray(e))e.forEach((e=>a(e)));else if(!isNaN(parseFloat(e))&&isFinite(e))a(e);else{if(void 0===i){if(!0===c)return;throw new Error(`Unsubscribe failed. No handler for topic based unsubscribe specified ${e}`)}for(const[,n]of o)if(n.handler===i&&n.topic===e){l(e.split("/"),n,t),o.delete(n.token);break}}}function c(e,i,t,s={}){if(!o.has(e.token))return;e.options.invocations>0&&(e.options.invocations-=1,e.options.invocations<=0&&r(e.token));const{handler:c}=e;if(!0!==s.handleExceptions&&!0!==n.handleExceptions)return c(t,i);try{return c(t,i)}catch(e){window.console&&window.console.error&&window.console.error("Exception while executing publish handler: ",e)}}function a(e,i,o={},t,s,r=[]){const c=t.get("subscribers")||new Map,d=t.get("topics");for(const[,e]of c){const{condition:t}=e.options;(void 0===t||"[object Function]"===Object.prototype.toString.call(t)&&!0===t(i,s))&&(e.position=r.push(e),e.priority=e.options.priority||0,e.async=Boolean(o.async||e.options.async||n.async))}if(e.length&&d){const n=d.get(e[0]),t=d.get("*");void 0===t&&void 0===n||(void 0!==t&&a(e.slice(1,e.length),i,o,t,s,r),void 0!==n&&a(e.slice(1,e.length),i,o,n,s,r),e.shift())}return r}function d(e,i,n){const[o]=e;void 0===n.get("topics")&&n.set("topics",new Map);const t=n.get("topics");let s=t.get(o);void 0===s&&(s=new Map,t.set(o,s)),e.length<2?(void 0===s.get("subscribers")&&s.set("subscribers",new Map),s.get("subscribers").set(i.token,i)):(e.shift(),d(e,i,s))}function l(e,i,n){const[o]=e,t=n.get("topics"),s=t.get(o),r=s.get("subscribers");e.length<2?(r.delete(i.token),0===r.size&&s.delete("subscribers")):(e.shift(),l(e,i,s)),s.has("topics")&&0===s.get("topics").size&&s.delete("topics"),0===t.get(o).size&&t.delete(o)}e.configure=function(e){if(!e)throw new Error("Publisher configure: no options specified");void 0!==e.async&&(n.async=e.async),void 0!==e.handleExceptions&&(n.handleExceptions=e.handleExceptions),void 0!==e.lenientUnsubscribe&&(n.lenientUnsubscribe=e.lenientUnsubscribe)},e.publish=function(e,i,o={}){if(!0===o.persist&&s.set(e,{data:i,options:o}),e.indexOf("*")>-1)throw new Error("Publish topic cannot contain any wildcards.");const r=a(e.split("/"),i,o,t,e);let d;r.sort(((e,i)=>e.priority===i.priority?e.position-i.position:e.priority>i.priority?-1:1));const l=void 0===o.async?n.async:o.async;for(;d=r.shift();)if(l)setTimeout(c.bind(null,d,e,i,o),0);else if(!1===c(d,e,i,o)&&!1!==o.cancelable)return!1;return!0},e.removePersistentMessage=function(e){s.delete(e)},e.subscribe=function(e,r,a={}){const l=i+=1;if(void 0===e)throw new Error('Subscribe failed - "undefined" Topic.');if(e.includes("undefined"))throw new Error(`Subscribe for '${e}' failed - found 'undefined' in topic, this is almost always an error: ${l}`);if(void 0===r)throw new Error(`Subscribe for '${e}' failed - "undefined" Handler`);const f={token:l,topic:e,handler:r,options:a};if(o.set(l,f),d(e.split("/"),f,t),!0!==a.persist)return l;const p=new RegExp(`^${e.replace("*","(.+)")}(/.+)?$`);for(const[e,i]of s){if(e.match(p)){if(void 0===i.options.async?n.async:i.options.async)setTimeout(c.bind(null,f,e,i.data,a),0);else if(!1===c(f,e,i.data,a)&&!0===a.cancelable)break}}return l},e.unsubscribe=r}));

dist/publisher.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)