@vandeurenglenn/little-pubsub 1.3.0 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -66,11 +66,11 @@ pubsub.unsubscribe('event-name', data => {
66
66
  pubsub.publish('event-name', 'data')
67
67
  ```
68
68
 
69
- #### isLittlePubSub
69
+ <!-- #### isLittlePubSub
70
70
  `instance`: instance to check<br>
71
71
  ```js
72
72
  const LittlePubSub = require('little-pubsub')
73
73
  const pubsub = new LittlePubSub()
74
74
 
75
75
  LittlePubSub.isLittlePubSub(pubsub)
76
- ```
76
+ ``` -->
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
- /* @vandeurenglenn/little-pubsub version 1.2.3 */
1
+ /* @vandeurenglenn/little-pubsub version 1.3.0 */
2
2
  'use strict';
3
3
 
4
- const ENVIRONMENT = {version: '1.2.3', production: true};
4
+ const ENVIRONMENT = {version: '1.3.0', production: true};
5
5
 
6
6
  class LittlePubSub {
7
7
 
@@ -38,9 +38,9 @@ class LittlePubSub {
38
38
  if (this.subscribers[event]) {
39
39
  const index = this.subscribers[event].handlers.indexOf(handler.bind(context));
40
40
  this.subscribers[event].handlers.splice(index);
41
- if (this.subscribers[event].handlers.length === 0) delete this.subscribers[event];
41
+ if (this.subscribers[event].handlers.length === 0) delete this.subscribers[event];
42
42
  }
43
-
43
+
44
44
  }
45
45
 
46
46
  /**
@@ -50,10 +50,10 @@ class LittlePubSub {
50
50
  publish(event, change) {
51
51
  if (this.subscribers[event]) {
52
52
  if (this.verbose || this.subscribers[event].value !== change) {
53
+ this.subscribers[event].value = change;
53
54
  this.subscribers[event].handlers.forEach(handler => {
54
55
  handler(change, this.subscribers[event].value);
55
56
  });
56
- this.subscribers[event].value = change;
57
57
  }
58
58
  }
59
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vandeurenglenn/little-pubsub",
3
- "version": "1.3.0",
3
+ "version": "1.3.3",
4
4
  "description": "Publish & Subscribe",
5
5
  "main": "index.js",
6
6
  "module": "src/index.js",
package/src/index.js CHANGED
@@ -33,9 +33,9 @@ export default class LittlePubSub {
33
33
  if (this.subscribers[event]) {
34
34
  const index = this.subscribers[event].handlers.indexOf(handler.bind(context));
35
35
  this.subscribers[event].handlers.splice(index);
36
- if (this.subscribers[event].handlers.length === 0) delete this.subscribers[event];
36
+ if (this.subscribers[event].handlers.length === 0) delete this.subscribers[event];
37
37
  }
38
-
38
+
39
39
  }
40
40
 
41
41
  /**
@@ -45,10 +45,10 @@ export default class LittlePubSub {
45
45
  publish(event, change) {
46
46
  if (this.subscribers[event]) {
47
47
  if (this.verbose || this.subscribers[event].value !== change) {
48
+ this.subscribers[event].value = change;
48
49
  this.subscribers[event].handlers.forEach(handler => {
49
50
  handler(change, this.subscribers[event].value)
50
51
  })
51
- this.subscribers[event].value = change;
52
52
  }
53
53
  }
54
54
  }
package/test.js CHANGED
@@ -18,8 +18,8 @@ test('pubsub is defined', tape => {
18
18
  tape.ok(Boolean(Object.keys(pubsub.subscribers).length === 0))
19
19
  })
20
20
 
21
- test('classIs', tape => {
22
- tape.plan(1)
23
- tape.ok(PubSub.isLittlePubSub(pubsub))
24
- })
21
+ // test('classIs', tape => {
22
+ // tape.plan(1)
23
+ // tape.ok(PubSub.isLittlePubSub(pubsub))
24
+ // })
25
25
  });