@ivan-angelkoski/counter 1.0.7 → 1.0.9

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/dist/index.cjs CHANGED
@@ -13,7 +13,10 @@ var Counter = class {
13
13
  };
14
14
  }
15
15
  notify() {
16
- for (const listener of this.listeners) listener({ count: this.count });
16
+ for (const listener of this.listeners) listener(this.getState());
17
+ }
18
+ getState() {
19
+ return { count: this.count };
17
20
  }
18
21
  increment(amount = 1) {
19
22
  this.count += amount;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["type State = {\n count: number;\n};\n\ntype Listener = (state: State) => void;\n\nexport class Counter {\n private count: number = 0;\n\n listeners: Set<Listener> = new Set();\n\n constructor() {\n this.count = 0;\n }\n\n subscribe(listener: Listener) {\n this.listeners.add(listener);\n\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n notify() {\n for (const listener of this.listeners) {\n listener({ count: this.count });\n }\n }\n\n increment(amount: number = 1) {\n this.count += amount;\n this.notify();\n }\n\n decrement(amount: number = 1) {\n this.count -= amount;\n this.notify();\n }\n}\n"],"mappings":";;AAMA,IAAa,UAAb,MAAqB;CACnB,AAAQ,QAAgB;CAExB,4BAA2B,IAAI,KAAK;CAEpC,cAAc;AACZ,OAAK,QAAQ;;CAGf,UAAU,UAAoB;AAC5B,OAAK,UAAU,IAAI,SAAS;AAE5B,eAAa;AACX,QAAK,UAAU,OAAO,SAAS;;;CAInC,SAAS;AACP,OAAK,MAAM,YAAY,KAAK,UAC1B,UAAS,EAAE,OAAO,KAAK,OAAO,CAAC;;CAInC,UAAU,SAAiB,GAAG;AAC5B,OAAK,SAAS;AACd,OAAK,QAAQ;;CAGf,UAAU,SAAiB,GAAG;AAC5B,OAAK,SAAS;AACd,OAAK,QAAQ"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["type State = {\n count: number;\n};\n\ntype Listener = (state: State) => void;\n\nexport class Counter {\n private count: number = 0;\n\n private listeners: Set<Listener> = new Set();\n\n constructor() {\n this.count = 0;\n }\n\n subscribe(listener: Listener) {\n this.listeners.add(listener);\n\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n private notify() {\n for (const listener of this.listeners) {\n listener(this.getState());\n }\n }\n\n getState() {\n return { count: this.count };\n }\n\n increment(amount: number = 1) {\n this.count += amount;\n this.notify();\n }\n\n decrement(amount: number = 1) {\n this.count -= amount;\n this.notify();\n }\n}\n"],"mappings":";;AAMA,IAAa,UAAb,MAAqB;CACnB,AAAQ,QAAgB;CAExB,AAAQ,4BAA2B,IAAI,KAAK;CAE5C,cAAc;AACZ,OAAK,QAAQ;;CAGf,UAAU,UAAoB;AAC5B,OAAK,UAAU,IAAI,SAAS;AAE5B,eAAa;AACX,QAAK,UAAU,OAAO,SAAS;;;CAInC,AAAQ,SAAS;AACf,OAAK,MAAM,YAAY,KAAK,UAC1B,UAAS,KAAK,UAAU,CAAC;;CAI7B,WAAW;AACT,SAAO,EAAE,OAAO,KAAK,OAAO;;CAG9B,UAAU,SAAiB,GAAG;AAC5B,OAAK,SAAS;AACd,OAAK,QAAQ;;CAGf,UAAU,SAAiB,GAAG;AAC5B,OAAK,SAAS;AACd,OAAK,QAAQ"}
package/dist/index.d.cts CHANGED
@@ -5,10 +5,13 @@ type State = {
5
5
  type Listener = (state: State) => void;
6
6
  declare class Counter {
7
7
  private count;
8
- listeners: Set<Listener>;
8
+ private listeners;
9
9
  constructor();
10
10
  subscribe(listener: Listener): () => void;
11
- notify(): void;
11
+ private notify;
12
+ getState(): {
13
+ count: number;
14
+ };
12
15
  increment(amount?: number): void;
13
16
  decrement(amount?: number): void;
14
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";KAAK,KAAA;EACH,KAAA;AAAA;AAAA,KAGG,QAAA,IAAY,KAAA,EAAO,KAAA;AAAA,cAEX,OAAA;EAAA,QACH,KAAA;EAER,SAAA,EAAW,GAAA,CAAI,QAAA;;EAMf,SAAA,CAAU,QAAA,EAAU,QAAA;EAQpB,MAAA,CAAA;EAMA,SAAA,CAAU,MAAA;EAKV,SAAA,CAAU,MAAA;AAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";KAAK,KAAA;EACH,KAAA;AAAA;AAAA,KAGG,QAAA,IAAY,KAAA,EAAO,KAAA;AAAA,cAEX,OAAA;EAAA,QACH,KAAA;EAAA,QAEA,SAAA;;EAMR,SAAA,CAAU,QAAA,EAAU,QAAA;EAAA,QAQZ,MAAA;EAMR,QAAA,CAAA;;;EAIA,SAAA,CAAU,MAAA;EAKV,SAAA,CAAU,MAAA;AAAA"}
package/dist/index.d.mts CHANGED
@@ -5,10 +5,13 @@ type State = {
5
5
  type Listener = (state: State) => void;
6
6
  declare class Counter {
7
7
  private count;
8
- listeners: Set<Listener>;
8
+ private listeners;
9
9
  constructor();
10
10
  subscribe(listener: Listener): () => void;
11
- notify(): void;
11
+ private notify;
12
+ getState(): {
13
+ count: number;
14
+ };
12
15
  increment(amount?: number): void;
13
16
  decrement(amount?: number): void;
14
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";KAAK,KAAA;EACH,KAAA;AAAA;AAAA,KAGG,QAAA,IAAY,KAAA,EAAO,KAAA;AAAA,cAEX,OAAA;EAAA,QACH,KAAA;EAER,SAAA,EAAW,GAAA,CAAI,QAAA;;EAMf,SAAA,CAAU,QAAA,EAAU,QAAA;EAQpB,MAAA,CAAA;EAMA,SAAA,CAAU,MAAA;EAKV,SAAA,CAAU,MAAA;AAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";KAAK,KAAA;EACH,KAAA;AAAA;AAAA,KAGG,QAAA,IAAY,KAAA,EAAO,KAAA;AAAA,cAEX,OAAA;EAAA,QACH,KAAA;EAAA,QAEA,SAAA;;EAMR,SAAA,CAAU,QAAA,EAAU,QAAA;EAAA,QAQZ,MAAA;EAMR,QAAA,CAAA;;;EAIA,SAAA,CAAU,MAAA;EAKV,SAAA,CAAU,MAAA;AAAA"}
package/dist/index.mjs CHANGED
@@ -12,7 +12,10 @@ var Counter = class {
12
12
  };
13
13
  }
14
14
  notify() {
15
- for (const listener of this.listeners) listener({ count: this.count });
15
+ for (const listener of this.listeners) listener(this.getState());
16
+ }
17
+ getState() {
18
+ return { count: this.count };
16
19
  }
17
20
  increment(amount = 1) {
18
21
  this.count += amount;
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["type State = {\n count: number;\n};\n\ntype Listener = (state: State) => void;\n\nexport class Counter {\n private count: number = 0;\n\n listeners: Set<Listener> = new Set();\n\n constructor() {\n this.count = 0;\n }\n\n subscribe(listener: Listener) {\n this.listeners.add(listener);\n\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n notify() {\n for (const listener of this.listeners) {\n listener({ count: this.count });\n }\n }\n\n increment(amount: number = 1) {\n this.count += amount;\n this.notify();\n }\n\n decrement(amount: number = 1) {\n this.count -= amount;\n this.notify();\n }\n}\n"],"mappings":";AAMA,IAAa,UAAb,MAAqB;CACnB,AAAQ,QAAgB;CAExB,4BAA2B,IAAI,KAAK;CAEpC,cAAc;AACZ,OAAK,QAAQ;;CAGf,UAAU,UAAoB;AAC5B,OAAK,UAAU,IAAI,SAAS;AAE5B,eAAa;AACX,QAAK,UAAU,OAAO,SAAS;;;CAInC,SAAS;AACP,OAAK,MAAM,YAAY,KAAK,UAC1B,UAAS,EAAE,OAAO,KAAK,OAAO,CAAC;;CAInC,UAAU,SAAiB,GAAG;AAC5B,OAAK,SAAS;AACd,OAAK,QAAQ;;CAGf,UAAU,SAAiB,GAAG;AAC5B,OAAK,SAAS;AACd,OAAK,QAAQ"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["type State = {\n count: number;\n};\n\ntype Listener = (state: State) => void;\n\nexport class Counter {\n private count: number = 0;\n\n private listeners: Set<Listener> = new Set();\n\n constructor() {\n this.count = 0;\n }\n\n subscribe(listener: Listener) {\n this.listeners.add(listener);\n\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n private notify() {\n for (const listener of this.listeners) {\n listener(this.getState());\n }\n }\n\n getState() {\n return { count: this.count };\n }\n\n increment(amount: number = 1) {\n this.count += amount;\n this.notify();\n }\n\n decrement(amount: number = 1) {\n this.count -= amount;\n this.notify();\n }\n}\n"],"mappings":";AAMA,IAAa,UAAb,MAAqB;CACnB,AAAQ,QAAgB;CAExB,AAAQ,4BAA2B,IAAI,KAAK;CAE5C,cAAc;AACZ,OAAK,QAAQ;;CAGf,UAAU,UAAoB;AAC5B,OAAK,UAAU,IAAI,SAAS;AAE5B,eAAa;AACX,QAAK,UAAU,OAAO,SAAS;;;CAInC,AAAQ,SAAS;AACf,OAAK,MAAM,YAAY,KAAK,UAC1B,UAAS,KAAK,UAAU,CAAC;;CAI7B,WAAW;AACT,SAAO,EAAE,OAAO,KAAK,OAAO;;CAG9B,UAAU,SAAiB,GAAG;AAC5B,OAAK,SAAS;AACd,OAAK,QAAQ;;CAGf,UAAU,SAAiB,GAAG;AAC5B,OAAK,SAAS;AACd,OAAK,QAAQ"}
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@ivan-angelkoski/counter",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Test counter package with changesets",
5
+ "type": "module",
5
6
  "main": "dist/index.cjs",
6
7
  "module": "dist/index.mjs",
7
8
  "types": "dist/index.d.mts",