@eleven-am/pondsocket 0.1.9 → 0.1.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
@@ -1,71 +1,53 @@
1
1
  "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
2
  Object.defineProperty(exports, "__esModule", { value: true });
19
3
  exports.BaseClass = void 0;
20
- var BaseClass = /** @class */ (function () {
21
- function BaseClass() {
22
- }
4
+ class BaseClass {
23
5
  /**
24
6
  * @desc checks if the pattern is matchable
25
7
  * @param pattern - the pattern to check
26
8
  */
27
- BaseClass.isPatternMatchable = function (pattern) {
9
+ static isPatternMatchable(pattern) {
28
10
  return typeof pattern === 'string' && pattern.includes(':');
29
- };
11
+ }
30
12
  /**
31
13
  * @desc compares string to string | regex
32
14
  * @param string - the string to compare to the pattern
33
15
  * @param pattern - the pattern to compare to the string
34
16
  */
35
- BaseClass.prototype.compareStringToPattern = function (string, pattern) {
17
+ compareStringToPattern(string, pattern) {
36
18
  if (typeof pattern === 'string')
37
19
  return string.split('?')[0] === pattern;
38
20
  else
39
21
  return pattern.test(string);
40
- };
22
+ }
41
23
  /**
42
24
  * @desc Checks if the given object is empty
43
25
  * @param obj - the object to check
44
26
  */
45
- BaseClass.prototype.isObjectEmpty = function (obj) {
27
+ isObjectEmpty(obj) {
46
28
  return Object.keys(obj).length === 0;
47
- };
29
+ }
48
30
  /**
49
31
  * @desc Generates a pond request resolver object
50
32
  * @param path - the path to resolve
51
33
  * @param address - the address to resolve
52
34
  */
53
- BaseClass.prototype.generateEventRequest = function (path, address) {
54
- var match = this._matchStringToPattern(address, path);
35
+ generateEventRequest(path, address) {
36
+ const match = this._matchStringToPattern(address, path);
55
37
  if (match)
56
38
  return {
57
39
  params: match, query: this._parseQueries(address), address: address
58
40
  };
59
41
  return null;
60
- };
42
+ }
61
43
  /**
62
44
  * @desc Compares if two objects are equal
63
45
  * @param obj1 - the first object
64
46
  * @param obj2 - the second object
65
47
  */
66
- BaseClass.prototype.areEqual = function (obj1, obj2) {
48
+ areEqual(obj1, obj2) {
67
49
  return JSON.stringify(obj1) === JSON.stringify(obj2);
68
- };
50
+ }
69
51
  /**
70
52
  * @desc Creates an object from the params of a path
71
53
  * @param path - the path to create the object from
@@ -74,17 +56,17 @@ var BaseClass = /** @class */ (function () {
74
56
  * /api/id?name=abc should return { name: 'abc' }
75
57
  * /api/id?name=abc&age=123 should return { name: 'abc', age: '123' }
76
58
  */
77
- BaseClass.prototype._parseQueries = function (path) {
78
- var obj = {};
79
- var params = path.split('?')[1];
59
+ _parseQueries(path) {
60
+ const obj = {};
61
+ const params = path.split('?')[1];
80
62
  if (params) {
81
- params.split('&').forEach(function (param) {
82
- var _a = __read(param.split('='), 2), key = _a[0], value = _a[1];
63
+ params.split('&').forEach(param => {
64
+ const [key, value] = param.split('=');
83
65
  obj[key] = value;
84
66
  });
85
67
  }
86
68
  return obj;
87
- };
69
+ }
88
70
  /**
89
71
  * @desc Returns the {key: value} matches of a string
90
72
  * @param string - the string to create the regex from
@@ -96,35 +78,34 @@ var BaseClass = /** @class */ (function () {
96
78
  * hello:id should match hello:123 and return { id: 123 }
97
79
  * @private
98
80
  */
99
- BaseClass.prototype._matchString = function (string, pattern) {
100
- var replace = pattern.replace(/:[^/]+/g, '([^/]+)');
101
- var regExp = new RegExp("^".concat(replace, "$"));
102
- var matches = string.split('?')[0].match(regExp);
81
+ _matchString(string, pattern) {
82
+ const replace = pattern.replace(/:[^/]+/g, '([^/]+)');
83
+ const regExp = new RegExp(`^${replace}$`);
84
+ const matches = string.split('?')[0].match(regExp);
103
85
  if (matches) {
104
- var keys = pattern.match(/:[^/]+/g);
86
+ const keys = pattern.match(/:[^/]+/g);
105
87
  if (keys) {
106
- var obj_1 = {};
107
- keys.forEach(function (key, index) {
108
- obj_1[key.replace(':', '')] = matches[index + 1].replace(/\?.*$/, '');
88
+ const obj = {};
89
+ keys.forEach((key, index) => {
90
+ obj[key.replace(':', '')] = matches[index + 1].replace(/\?.*$/, '');
109
91
  });
110
- return obj_1;
92
+ return obj;
111
93
  }
112
94
  }
113
95
  return null;
114
- };
96
+ }
115
97
  /**
116
98
  * @desc matches a string to a pattern and returns its params if any
117
99
  * @param string - the string to match
118
100
  * @param pattern - the pattern to match to
119
101
  */
120
- BaseClass.prototype._matchStringToPattern = function (string, pattern) {
102
+ _matchStringToPattern(string, pattern) {
121
103
  if (BaseClass.isPatternMatchable(pattern))
122
104
  return this._matchString(string, pattern);
123
- var valid = this.compareStringToPattern(string, pattern);
105
+ const valid = this.compareStringToPattern(string, pattern);
124
106
  if (valid)
125
107
  return {};
126
108
  return null;
127
- };
128
- return BaseClass;
129
- }());
109
+ }
110
+ }
130
111
  exports.BaseClass = BaseClass;
@@ -1,31 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var baseClass_1 = require("./baseClass");
4
- describe('BaseClass', function () {
5
- var baseClass = new baseClass_1.BaseClass();
6
- it('should return true when object is empty', function () {
3
+ const baseClass_1 = require("./baseClass");
4
+ describe('BaseClass', () => {
5
+ const baseClass = new baseClass_1.BaseClass();
6
+ it('should return true when object is empty', () => {
7
7
  expect(baseClass.isObjectEmpty({})).toBe(true);
8
8
  });
9
- it('should return false when object is not empty', function () {
9
+ it('should return false when object is not empty', () => {
10
10
  expect(baseClass.isObjectEmpty({ test: 5 })).toBe(false);
11
11
  });
12
- it('should return true if a string matches a regex | string', function () {
13
- var regex = new RegExp(/^test/);
12
+ it('should return true if a string matches a regex | string', () => {
13
+ const regex = new RegExp(/^test/);
14
14
  expect(baseClass.compareStringToPattern('test', regex)).toBe(true);
15
- var string = 'test';
15
+ const string = 'test';
16
16
  expect(baseClass.compareStringToPattern('test', string)).toBe(true);
17
17
  });
18
- it('should return false if a string does not match a regex | string', function () {
19
- var regex = new RegExp(/^test$/);
18
+ it('should return false if a string does not match a regex | string', () => {
19
+ const regex = new RegExp(/^test$/);
20
20
  expect(baseClass.compareStringToPattern('test2', regex)).toBe(false);
21
- var string = 'test';
21
+ const string = 'test';
22
22
  expect(baseClass.compareStringToPattern('test2', string)).toBe(false);
23
23
  });
24
- it('should return the params of a string matching the pattern', function () {
25
- var pattern = '/test/:id';
26
- var secondPattern = '/test/:id/:id2';
27
- var string = '/test/5';
28
- var secondString = '/test/5/6';
24
+ it('should return the params of a string matching the pattern', () => {
25
+ const pattern = '/test/:id';
26
+ const secondPattern = '/test/:id/:id2';
27
+ const string = '/test/5';
28
+ const secondString = '/test/5/6';
29
29
  expect(baseClass['_matchString'](string, pattern)).toEqual({ id: '5' });
30
30
  expect(baseClass['_matchString'](secondString, secondPattern)).toEqual({ id: '5', id2: '6' });
31
31
  // this function fails if the pattern is not a string or regex
@@ -33,41 +33,41 @@ describe('BaseClass', function () {
33
33
  // But will return null if the string is smaller than the pattern
34
34
  expect(baseClass['_matchString'](string, secondPattern)).toEqual(null);
35
35
  //it should also match patterns without the slash
36
- var thirdPattern = 'test:id';
37
- var thirdString = 'test5';
36
+ const thirdPattern = 'test:id';
37
+ const thirdString = 'test5';
38
38
  expect(baseClass['_matchString'](thirdString, thirdPattern)).toEqual({ id: '5' });
39
39
  });
40
- it('should return the query of string', function () {
41
- var string = '/test/5?test=5';
42
- var secondString = '/test/5?test=5&test2=6';
40
+ it('should return the query of string', () => {
41
+ const string = '/test/5?test=5';
42
+ const secondString = '/test/5?test=5&test2=6';
43
43
  expect(baseClass['_parseQueries'](string)).toEqual({ test: '5' });
44
44
  expect(baseClass['_parseQueries'](secondString)).toEqual({ test: '5', test2: '6' });
45
45
  });
46
- it('should return true if an object matches another object', function () {
47
- var object = { test: 5 };
48
- var secondObject = { test: 5, test2: 6 };
46
+ it('should return true if an object matches another object', () => {
47
+ const object = { test: 5 };
48
+ const secondObject = { test: 5, test2: 6 };
49
49
  expect(baseClass.areEqual(object, object)).toBe(true);
50
50
  expect(baseClass.areEqual(object, secondObject)).toBe(false);
51
51
  });
52
- it('should return null if the string does not match the pattern', function () {
53
- var pattern = 'pondSocket';
54
- var string = '/test2/5';
52
+ it('should return null if the string does not match the pattern', () => {
53
+ const pattern = 'pondSocket';
54
+ const string = '/test2/5';
55
55
  expect(baseClass['_matchStringToPattern'](string, pattern)).toBe(null);
56
56
  });
57
- it('should return the params of a string matching the pattern', function () {
58
- var pattern = 'pondSocket';
59
- var string = 'pondSocket';
57
+ it('should return the params of a string matching the pattern', () => {
58
+ const pattern = 'pondSocket';
59
+ const string = 'pondSocket';
60
60
  expect(baseClass['_matchStringToPattern'](string, pattern)).toEqual({});
61
61
  });
62
- it('should generateEventRequest', function () {
63
- var pattern = 'pondSocket:test';
64
- var string = 'pondSockethello?test=5&test2=6';
62
+ it('should generateEventRequest', () => {
63
+ const pattern = 'pondSocket:test';
64
+ const string = 'pondSockethello?test=5&test2=6';
65
65
  expect(baseClass.generateEventRequest(pattern, string)).toEqual({
66
66
  address: string,
67
67
  params: { test: 'hello' },
68
68
  query: { test: '5', test2: '6' }
69
69
  });
70
- var unMatchingString = 'pondXocket2hello?test=5&test2=6';
70
+ const unMatchingString = 'pondXocket2hello?test=5&test2=6';
71
71
  expect(baseClass.generateEventRequest(pattern, unMatchingString)).toEqual(null);
72
72
  });
73
73
  });
@@ -1,121 +1,60 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- var __values = (this && this.__values) || function(o) {
29
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
30
- if (m) return m.call(o);
31
- if (o && typeof o.length === "number") return {
32
- next: function () {
33
- if (o && i >= o.length) o = void 0;
34
- return { value: o && o[i++], done: !o };
35
- }
36
- };
37
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
38
- };
39
2
  Object.defineProperty(exports, "__esModule", { value: true });
40
3
  exports.PondBase = void 0;
41
- var pubSub_1 = require("./pubSub");
42
- var simpleBase_1 = require("./simpleBase");
43
- var enums_1 = require("./enums");
44
- var PondBase = /** @class */ (function (_super) {
45
- __extends(PondBase, _super);
46
- function PondBase() {
47
- var _this = this;
48
- var broadcast = new pubSub_1.Broadcast();
49
- _this = _super.call(this, function (data) { return broadcast.publish(data); }) || this;
50
- _this._broadcast = broadcast;
51
- return _this;
4
+ const pubSub_1 = require("./pubSub");
5
+ const simpleBase_1 = require("./simpleBase");
6
+ const enums_1 = require("./enums");
7
+ class PondBase extends simpleBase_1.SimpleBase {
8
+ constructor() {
9
+ const broadcast = new pubSub_1.Broadcast();
10
+ super((data) => broadcast.publish(data));
11
+ this._broadcast = broadcast;
12
+ }
13
+ /**
14
+ * @des Generate a key for a new document
15
+ */
16
+ get _nanoid() {
17
+ let id = '';
18
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
19
+ for (let i = 0; i < 21; i++) {
20
+ id += chars.charAt(Math.floor(Math.random() * chars.length));
21
+ }
22
+ return id;
52
23
  }
53
- Object.defineProperty(PondBase.prototype, "_nanoid", {
54
- /**
55
- * @des Generate a key for a new document
56
- */
57
- get: function () {
58
- var id = '';
59
- var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
60
- for (var i = 0; i < 21; i++) {
61
- id += chars.charAt(Math.floor(Math.random() * chars.length));
62
- }
63
- return id;
64
- },
65
- enumerable: false,
66
- configurable: true
67
- });
68
24
  /**
69
25
  * @desc Subscribe to the database
70
26
  * @param handler - The handler to call when the database is updated
71
27
  */
72
- PondBase.prototype.subscribe = function (handler) {
73
- var _this = this;
74
- return this._broadcast.subscribe(function (data) {
75
- var change = enums_1.PondBaseActions.UPDATE_IN_POND;
28
+ subscribe(handler) {
29
+ return this._broadcast.subscribe((data) => {
30
+ let change = enums_1.PondBaseActions.UPDATE_IN_POND;
76
31
  if (data.oldValue === null)
77
32
  change = enums_1.PondBaseActions.ADD_TO_POND;
78
33
  else if (data.currentValue === null)
79
34
  change = enums_1.PondBaseActions.REMOVE_FROM_POND;
80
- handler(Object.values(_this._getDB()), data.currentValue || data.oldValue, change);
35
+ handler(Object.values(this._getDB()), data.currentValue || data.oldValue, change);
81
36
  });
82
- };
37
+ }
83
38
  /**
84
39
  * @desc Add a document to the database
85
40
  * @param doc - The document to add
86
41
  */
87
- PondBase.prototype.addDoc = function (doc) {
88
- return _super.prototype.set.call(this, this._nanoid, doc);
89
- };
42
+ addDoc(doc) {
43
+ return super.set(this._nanoid, doc);
44
+ }
90
45
  /**
91
46
  * @desc Left join two ponds on a key on this pond and a foreign key on the other pond
92
47
  * @param pond - The pond to join with
93
48
  * @param key - The key to join on
94
49
  * @param foreignKey - The foreign key to join on
95
50
  */
96
- PondBase.prototype.leftJoin = function (pond, key, foreignKey) {
97
- var e_1, _a;
98
- var newPond = new PondBase();
99
- var _loop_1 = function (doc) {
100
- var _d;
101
- var foreignDoc = pond.find(function (d) { return d[foreignKey] === doc.doc[key]; });
102
- newPond.set(doc.id, __assign(__assign({}, doc.doc), (_d = {}, _d[key] = (foreignDoc === null || foreignDoc === void 0 ? void 0 : foreignDoc.doc) || null, _d)));
103
- };
104
- try {
105
- for (var _b = __values(this), _c = _b.next(); !_c.done; _c = _b.next()) {
106
- var doc = _c.value;
107
- _loop_1(doc);
108
- }
109
- }
110
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
111
- finally {
112
- try {
113
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
114
- }
115
- finally { if (e_1) throw e_1.error; }
51
+ leftJoin(pond, key, foreignKey) {
52
+ const newPond = new PondBase();
53
+ for (const doc of this) {
54
+ const foreignDoc = pond.find((d) => d[foreignKey] === doc.doc[key]);
55
+ newPond.set(doc.id, Object.assign(Object.assign({}, doc.doc), { [key]: (foreignDoc === null || foreignDoc === void 0 ? void 0 : foreignDoc.doc) || null }));
116
56
  }
117
57
  return newPond;
118
- };
119
- return PondBase;
120
- }(simpleBase_1.SimpleBase));
58
+ }
59
+ }
121
60
  exports.PondBase = PondBase;
@@ -1,129 +1,101 @@
1
1
  "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
- if (ar || !(i in from)) {
21
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
- ar[i] = from[i];
23
- }
24
- }
25
- return to.concat(ar || Array.prototype.slice.call(from));
26
- };
27
2
  Object.defineProperty(exports, "__esModule", { value: true });
28
- var pondBase_1 = require("./pondBase");
29
- var enums_1 = require("./enums");
30
- describe('PondBase', function () {
31
- it('should be able to take in a subscriber', function () {
32
- var base = new pondBase_1.PondBase();
3
+ const pondBase_1 = require("./pondBase");
4
+ const enums_1 = require("./enums");
5
+ describe('PondBase', () => {
6
+ it('should be able to take in a subscriber', () => {
7
+ const base = new pondBase_1.PondBase();
33
8
  expect(base['_broadcast']['_subscribers'].size).toBe(0);
34
- var mockSubscriber = jest.fn();
9
+ const mockSubscriber = jest.fn();
35
10
  base.subscribe(mockSubscriber);
36
11
  expect(base['_broadcast']['_subscribers'].size).toBe(1);
37
12
  });
38
- it('should be able to remove a subscriber', function () {
39
- var base = new pondBase_1.PondBase();
13
+ it('should be able to remove a subscriber', () => {
14
+ const base = new pondBase_1.PondBase();
40
15
  expect(base['_broadcast']['_subscribers'].size).toBe(0);
41
- var mockSubscriber = jest.fn();
42
- var subscription = base.subscribe(mockSubscriber);
16
+ const mockSubscriber = jest.fn();
17
+ const subscription = base.subscribe(mockSubscriber);
43
18
  expect(base['_broadcast']['_subscribers'].size).toBe(1);
44
19
  subscription.unsubscribe();
45
20
  expect(base['_broadcast']['_subscribers'].size).toBe(0);
46
21
  });
47
- it('should fire the subscriber when a document is added', function () {
48
- var base = new pondBase_1.PondBase();
49
- var mockSubscriber = jest.fn();
22
+ it('should fire the subscriber when a document is added', () => {
23
+ const base = new pondBase_1.PondBase();
24
+ const mockSubscriber = jest.fn();
50
25
  base.subscribe(mockSubscriber);
51
26
  base.set('test', { name: 'test' });
52
27
  expect(mockSubscriber).toBeCalled();
53
28
  expect(mockSubscriber).toBeCalledWith([{ name: "test" }], { name: "test" }, enums_1.PondBaseActions.ADD_TO_POND);
54
29
  });
55
- it('should fire the subscriber when a document is removed', function () {
56
- var base = new pondBase_1.PondBase();
57
- var mockSubscriber = jest.fn();
30
+ it('should fire the subscriber when a document is removed', () => {
31
+ const base = new pondBase_1.PondBase();
32
+ const mockSubscriber = jest.fn();
58
33
  base.subscribe(mockSubscriber);
59
- var data = base.set('test', { name: 'test' });
34
+ const data = base.set('test', { name: 'test' });
60
35
  expect(mockSubscriber).toBeCalledWith([{ name: "test" }], { name: "test" }, enums_1.PondBaseActions.ADD_TO_POND);
61
36
  mockSubscriber.mockClear();
62
37
  data.removeDoc();
63
38
  expect(mockSubscriber).toBeCalledWith([], { name: "test" }, enums_1.PondBaseActions.REMOVE_FROM_POND);
64
39
  });
65
- it('should fire the subscriber when a document is updated', function () {
66
- var base = new pondBase_1.PondBase();
67
- var mockSubscriber = jest.fn();
40
+ it('should fire the subscriber when a document is updated', () => {
41
+ const base = new pondBase_1.PondBase();
42
+ const mockSubscriber = jest.fn();
68
43
  base.subscribe(mockSubscriber);
69
- var data = base.set('test', { name: 'test' });
44
+ const data = base.set('test', { name: 'test' });
70
45
  expect(mockSubscriber).toBeCalledWith([{ name: "test" }], { name: "test" }, enums_1.PondBaseActions.ADD_TO_POND);
71
46
  mockSubscriber.mockClear();
72
47
  data.updateDoc({ name: 'test2' });
73
48
  expect(mockSubscriber).toBeCalledWith([{ name: "test2" }], { name: "test2" }, enums_1.PondBaseActions.UPDATE_IN_POND);
74
49
  });
75
- it('should add a document to the database', function () {
50
+ it('should add a document to the database', () => {
76
51
  var _a, _b;
77
- var base = new pondBase_1.PondBase();
78
- var data = base.addDoc({ name: 'test' });
52
+ const base = new pondBase_1.PondBase();
53
+ const data = base.addDoc({ name: 'test' });
79
54
  expect(data.id).toBeDefined();
80
55
  expect((_a = base.get(data.id)) === null || _a === void 0 ? void 0 : _a.doc).toEqual(data.doc);
81
56
  expect((_b = base.get(data.id)) === null || _b === void 0 ? void 0 : _b.doc).toEqual({ name: 'test' });
82
57
  });
83
- it('should left join with another pond', function () {
84
- var owners = new pondBase_1.PondBase();
85
- var pets = new pondBase_1.PondBase();
58
+ it('should left join with another pond', () => {
59
+ const owners = new pondBase_1.PondBase();
60
+ const pets = new pondBase_1.PondBase();
86
61
  owners.addDoc({ name: 'test', age: 10 });
87
62
  owners.set('test2', { name: 'test2', age: 12 });
88
63
  pets.addDoc({ name: 'test', owner: 'test' });
89
64
  pets.addDoc({ name: 'test2', owner: 'test2' });
90
65
  pets.set('test3', { name: 'test3', owner: 'test3' });
91
- var joined = pets.leftJoin(owners, 'owner', 'name');
92
- expect(__spreadArray([], __read(joined), false).map(function (_a) {
93
- var doc = _a.doc;
94
- return doc;
95
- })).toEqual([
66
+ const joined = pets.leftJoin(owners, 'owner', 'name');
67
+ expect([...joined].map(({ doc }) => doc)).toEqual([
96
68
  { name: 'test', owner: { name: 'test', age: 10 } },
97
69
  { name: 'test2', owner: { name: 'test2', age: 12 } },
98
70
  { name: 'test3', owner: null }
99
71
  ]);
100
72
  });
101
- it('should be able to get the keys', function () {
102
- var base = new pondBase_1.PondBase();
73
+ it('should be able to get the keys', () => {
74
+ const base = new pondBase_1.PondBase();
103
75
  base.set('test', { name: 'test' });
104
76
  base.set('test2', { name: 'test2' });
105
77
  expect(base.keys).toEqual(['test', 'test2']);
106
78
  });
107
- it('should be able to get the values', function () {
108
- var base = new pondBase_1.PondBase();
79
+ it('should be able to get the values', () => {
80
+ const base = new pondBase_1.PondBase();
109
81
  base.addDoc({ name: 'test' });
110
82
  base.set('test2', { name: 'test2' });
111
83
  expect(base.values).toEqual([{ name: 'test' }, { name: 'test2' }]);
112
84
  });
113
- it('should be able to upsert a document', function () {
85
+ it('should be able to upsert a document', () => {
114
86
  var _a, _b;
115
- var base = new pondBase_1.PondBase();
87
+ const base = new pondBase_1.PondBase();
116
88
  base.upsert('test', { name: 'test' });
117
89
  expect((_a = base.get('test')) === null || _a === void 0 ? void 0 : _a.doc).toEqual({ name: 'test' });
118
90
  base.upsert('test', { name: 'test2' });
119
91
  expect((_b = base.get('test')) === null || _b === void 0 ? void 0 : _b.doc).toEqual({ name: 'test2' });
120
92
  });
121
- it('should be able to getOrCreate a document with a function', function () {
93
+ it('should be able to getOrCreate a document with a function', () => {
122
94
  var _a, _b;
123
- var base = new pondBase_1.PondBase();
124
- base.getOrCreate('test', function () { return ({ name: 'test' }); });
95
+ const base = new pondBase_1.PondBase();
96
+ base.getOrCreate('test', () => ({ name: 'test' }));
125
97
  expect((_a = base.get('test')) === null || _a === void 0 ? void 0 : _a.doc).toEqual({ name: 'test' });
126
- base.getOrCreate('test', function () { return ({ name: 'test2' }); });
98
+ base.getOrCreate('test', () => ({ name: 'test2' }));
127
99
  expect((_b = base.get('test')) === null || _b === void 0 ? void 0 : _b.doc).toEqual({ name: 'test' });
128
100
  });
129
101
  });
@@ -4,11 +4,6 @@ export declare class Subscription {
4
4
 
5
5
  export declare class Broadcast<T, A> {
6
6
 
7
- /**
8
- * @desc Gets the number of subscribers
9
- */
10
- get subscriberCount(): number;
11
-
12
7
  /**
13
8
  * @desc Subscribe to the broadcast
14
9
  * @param handler - The handler to call when the broadcast is published
@@ -35,17 +30,21 @@ export declare class Subject<T, A> extends Broadcast<T, A> {
35
30
  */
36
31
  get value(): T;
37
32
 
33
+ /**
34
+ * @desc Get the list of observers
35
+ * @returns The list of observers
36
+ */
37
+ get observers(): Set<(data: T) => Anything<A>>;
38
+
38
39
  /**
39
40
  * @desc Subscribe to the subject
40
- * @param handler - The handler to call when the subject is published
41
41
  */
42
42
  subscribe(handler: (data: T) => A): Subscription;
43
43
 
44
44
  /**
45
45
  * @desc Publish to the subject
46
- * @param data - The data to publish
47
46
  */
48
- publish(data: T): A | undefined;
47
+ publish(data: T): Anything<A>;
49
48
  }
50
49
 
51
50
  export declare class EventPubSub<T, A> {
@@ -55,7 +54,7 @@ export declare class EventPubSub<T, A> {
55
54
  * @param event - The event to subscribe to
56
55
  * @param handler - The handler to call when the event subject is published
57
56
  */
58
- subscribe(event: string, handler: (data: T) => A): Subscription;
57
+ subscribe(event: string, handler: (data: T) => Anything<A>): Subscription;
59
58
 
60
59
  /**
61
60
  * @desc Publish to the event subject