@ivan-angelkoski/counter 1.0.8 → 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 +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +5 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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(
|
|
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;
|
package/dist/index.cjs.map
CHANGED
|
@@ -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 }
|
|
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
|
|
8
|
+
private listeners;
|
|
9
9
|
constructor();
|
|
10
10
|
subscribe(listener: Listener): () => void;
|
|
11
|
-
notify
|
|
11
|
+
private notify;
|
|
12
|
+
getState(): {
|
|
13
|
+
count: number;
|
|
14
|
+
};
|
|
12
15
|
increment(amount?: number): void;
|
|
13
16
|
decrement(amount?: number): void;
|
|
14
17
|
}
|
package/dist/index.d.cts.map
CHANGED
|
@@ -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;
|
|
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
|
|
8
|
+
private listeners;
|
|
9
9
|
constructor();
|
|
10
10
|
subscribe(listener: Listener): () => void;
|
|
11
|
-
notify
|
|
11
|
+
private notify;
|
|
12
|
+
getState(): {
|
|
13
|
+
count: number;
|
|
14
|
+
};
|
|
12
15
|
increment(amount?: number): void;
|
|
13
16
|
decrement(amount?: number): void;
|
|
14
17
|
}
|
package/dist/index.d.mts.map
CHANGED
|
@@ -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;
|
|
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(
|
|
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;
|
package/dist/index.mjs.map
CHANGED
|
@@ -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 }
|
|
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"}
|