@ivan-angelkoski/counter 1.0.5 → 1.0.7
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 +12 -4
- package/.turbo/turbo-build.log +0 -27
- package/.turbo/turbo-lint.log +0 -4
- package/.turbo/turbo-test.log +0 -14
- package/CHANGELOG.md +0 -32
- package/eslint.config.mjs +0 -4
- package/src/index.spec.ts +0 -119
- package/src/index.ts +0 -39
- package/tsconfig.json +0 -46
- package/tsdown.config.ts +0 -11
- package/vitest.config.ts +0 -7
package/package.json
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ivan-angelkoski/counter",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Test counter package with changesets",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.mts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.mts",
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.cts",
|
|
16
|
+
"default": "./dist/index.cjs"
|
|
17
|
+
}
|
|
13
18
|
}
|
|
14
19
|
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
15
23
|
"keywords": [
|
|
16
24
|
"counter",
|
|
17
25
|
"package",
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @ivan-angelkoski/counter@1.0.5 build /home/runner/work/counter-changesets/counter-changesets/packages/counter
|
|
3
|
-
> tsdown
|
|
4
|
-
|
|
5
|
-
[34mℹ[39m tsdown [2mv0.20.1[22m powered by rolldown [2mv1.0.0-rc.1[22m
|
|
6
|
-
[34mℹ[39m config file: [4m/home/runner/work/counter-changesets/counter-changesets/packages/counter/tsdown.config.ts[24m
|
|
7
|
-
(node:2415) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/counter-changesets/counter-changesets/packages/counter/tsdown.config.ts?no-cache=be498652-a4fd-41bd-b2ed-1e6441d72541 is not specified and it doesn't parse as CommonJS.
|
|
8
|
-
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
|
|
9
|
-
To eliminate this warning, add "type": "module" to /home/runner/work/counter-changesets/counter-changesets/packages/counter/package.json.
|
|
10
|
-
(Use `node --trace-warnings ...` to show where the warning was created)
|
|
11
|
-
[34mℹ[39m entry: [34msrc/index.ts[39m
|
|
12
|
-
[34mℹ[39m target: [34mes2022[39m
|
|
13
|
-
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
14
|
-
[34mℹ[39m Build start
|
|
15
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[1mindex.cjs[22m [2m0.56 kB[22m [2m│ gzip: 0.29 kB[22m
|
|
16
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mindex.cjs.map [2m1.13 kB[22m [2m│ gzip: 0.52 kB[22m
|
|
17
|
-
[34mℹ[39m [33m[CJS][39m 2 files, total: 1.68 kB
|
|
18
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mindex.d.cts.map [2m0.30 kB[22m [2m│ gzip: 0.20 kB[22m
|
|
19
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32m[1mindex.d.cts[22m[39m [2m0.39 kB[22m [2m│ gzip: 0.24 kB[22m
|
|
20
|
-
[34mℹ[39m [33m[CJS][39m 2 files, total: 0.69 kB
|
|
21
|
-
[32m✔[39m Build complete in [32m3171ms[39m
|
|
22
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[1mindex.mjs[22m [2m0.55 kB[22m [2m│ gzip: 0.29 kB[22m
|
|
23
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mindex.mjs.map [2m1.13 kB[22m [2m│ gzip: 0.52 kB[22m
|
|
24
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mindex.d.mts.map [2m0.30 kB[22m [2m│ gzip: 0.20 kB[22m
|
|
25
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m0.39 kB[22m [2m│ gzip: 0.24 kB[22m
|
|
26
|
-
[34mℹ[39m [34m[ESM][39m 4 files, total: 2.37 kB
|
|
27
|
-
[32m✔[39m Build complete in [32m3173ms[39m
|
package/.turbo/turbo-lint.log
DELETED
package/.turbo/turbo-test.log
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @ivan-angelkoski/counter@1.0.5 test /home/runner/work/counter-changesets/counter-changesets/packages/counter
|
|
3
|
-
> vitest run
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[1m[46m RUN [49m[22m [36mv4.0.18 [39m[90m/home/runner/work/counter-changesets/counter-changesets/packages/counter[39m
|
|
7
|
-
|
|
8
|
-
[32m✓[39m src/index.spec.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 13[2mms[22m[39m
|
|
9
|
-
|
|
10
|
-
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
11
|
-
[2m Tests [22m [1m[32m10 passed[39m[22m[90m (10)[39m
|
|
12
|
-
[2m Start at [22m 12:13:23
|
|
13
|
-
[2m Duration [22m 456ms[2m (transform 94ms, setup 0ms, import 111ms, tests 13ms, environment 0ms)[22m
|
|
14
|
-
|
package/CHANGELOG.md
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# @ivanangjelkoski/counter
|
|
2
|
-
|
|
3
|
-
## 1.0.5
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- 35d53e7: name change
|
|
8
|
-
|
|
9
|
-
## 1.0.4
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
- 901fe4e: updated the publish script
|
|
14
|
-
|
|
15
|
-
## 1.0.3
|
|
16
|
-
|
|
17
|
-
### Patch Changes
|
|
18
|
-
|
|
19
|
-
- 2355f3d: update package name
|
|
20
|
-
|
|
21
|
-
## 1.0.2
|
|
22
|
-
|
|
23
|
-
### Patch Changes
|
|
24
|
-
|
|
25
|
-
- 0e29ba4: Added more tests
|
|
26
|
-
- c9a70c4: updated the increment and decrement methods to accept an amount
|
|
27
|
-
|
|
28
|
-
## 1.0.1
|
|
29
|
-
|
|
30
|
-
### Patch Changes
|
|
31
|
-
|
|
32
|
-
- e23f26a: Initial Version
|
package/eslint.config.mjs
DELETED
package/src/index.spec.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { Counter } from "./index";
|
|
2
|
-
|
|
3
|
-
describe("Counter", () => {
|
|
4
|
-
let counter: Counter;
|
|
5
|
-
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
counter = new Counter();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
describe("increment", () => {
|
|
11
|
-
it("should increment the count", () => {
|
|
12
|
-
const listener = vi.fn();
|
|
13
|
-
counter.subscribe(listener);
|
|
14
|
-
|
|
15
|
-
counter.increment();
|
|
16
|
-
|
|
17
|
-
expect(listener).toHaveBeenCalledWith({ count: 1 });
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should increment multiple times", () => {
|
|
21
|
-
const listener = vi.fn();
|
|
22
|
-
counter.subscribe(listener);
|
|
23
|
-
|
|
24
|
-
counter.increment();
|
|
25
|
-
counter.increment();
|
|
26
|
-
counter.increment();
|
|
27
|
-
|
|
28
|
-
expect(listener).toHaveBeenCalledTimes(3);
|
|
29
|
-
expect(listener).toHaveBeenLastCalledWith({ count: 3 });
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("should increment by a specific amount", () => {
|
|
33
|
-
const listener = vi.fn();
|
|
34
|
-
counter.subscribe(listener);
|
|
35
|
-
|
|
36
|
-
counter.increment(5);
|
|
37
|
-
|
|
38
|
-
expect(listener).toHaveBeenCalledWith({ count: 5 });
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe("decrement", () => {
|
|
43
|
-
it("should decrement the count", () => {
|
|
44
|
-
const listener = vi.fn();
|
|
45
|
-
counter.subscribe(listener);
|
|
46
|
-
|
|
47
|
-
counter.decrement();
|
|
48
|
-
|
|
49
|
-
expect(listener).toHaveBeenCalledWith({ count: -1 });
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("should decrement multiple times", () => {
|
|
53
|
-
const listener = vi.fn();
|
|
54
|
-
counter.subscribe(listener);
|
|
55
|
-
|
|
56
|
-
counter.decrement();
|
|
57
|
-
counter.decrement();
|
|
58
|
-
|
|
59
|
-
expect(listener).toHaveBeenCalledTimes(2);
|
|
60
|
-
expect(listener).toHaveBeenLastCalledWith({ count: -2 });
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("should decrement by a specific amount", () => {
|
|
64
|
-
const listener = vi.fn();
|
|
65
|
-
counter.subscribe(listener);
|
|
66
|
-
|
|
67
|
-
counter.decrement(5);
|
|
68
|
-
|
|
69
|
-
expect(listener).toHaveBeenCalledWith({ count: -5 });
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
describe("subscribe", () => {
|
|
74
|
-
it("should add a listener", () => {
|
|
75
|
-
const listener = vi.fn();
|
|
76
|
-
|
|
77
|
-
counter.subscribe(listener);
|
|
78
|
-
counter.increment();
|
|
79
|
-
|
|
80
|
-
expect(listener).toHaveBeenCalledWith({ count: 1 });
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("should support multiple listeners", () => {
|
|
84
|
-
const listener1 = vi.fn();
|
|
85
|
-
const listener2 = vi.fn();
|
|
86
|
-
|
|
87
|
-
counter.subscribe(listener1);
|
|
88
|
-
counter.subscribe(listener2);
|
|
89
|
-
counter.increment();
|
|
90
|
-
|
|
91
|
-
expect(listener1).toHaveBeenCalledWith({ count: 1 });
|
|
92
|
-
expect(listener2).toHaveBeenCalledWith({ count: 1 });
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("should return an unsubscribe function", () => {
|
|
96
|
-
const listener = vi.fn();
|
|
97
|
-
|
|
98
|
-
const unsubscribe = counter.subscribe(listener);
|
|
99
|
-
unsubscribe();
|
|
100
|
-
counter.increment();
|
|
101
|
-
|
|
102
|
-
expect(listener).not.toHaveBeenCalled();
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe("notify", () => {
|
|
107
|
-
it("should notify all listeners with current state", () => {
|
|
108
|
-
const listener1 = vi.fn();
|
|
109
|
-
const listener2 = vi.fn();
|
|
110
|
-
|
|
111
|
-
counter.subscribe(listener1);
|
|
112
|
-
counter.subscribe(listener2);
|
|
113
|
-
counter.notify();
|
|
114
|
-
|
|
115
|
-
expect(listener1).toHaveBeenCalledWith({ count: 0 });
|
|
116
|
-
expect(listener2).toHaveBeenCalledWith({ count: 0 });
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
});
|
package/src/index.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
type State = {
|
|
2
|
-
count: number;
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
type Listener = (state: State) => void;
|
|
6
|
-
|
|
7
|
-
export class Counter {
|
|
8
|
-
private count: number = 0;
|
|
9
|
-
|
|
10
|
-
listeners: Set<Listener> = new Set();
|
|
11
|
-
|
|
12
|
-
constructor() {
|
|
13
|
-
this.count = 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
subscribe(listener: Listener) {
|
|
17
|
-
this.listeners.add(listener);
|
|
18
|
-
|
|
19
|
-
return () => {
|
|
20
|
-
this.listeners.delete(listener);
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
notify() {
|
|
25
|
-
for (const listener of this.listeners) {
|
|
26
|
-
listener({ count: this.count });
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
increment(amount: number = 1) {
|
|
31
|
-
this.count += amount;
|
|
32
|
-
this.notify();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
decrement(amount: number = 1) {
|
|
36
|
-
this.count -= amount;
|
|
37
|
-
this.notify();
|
|
38
|
-
}
|
|
39
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"exclude": ["node_modules", "dist", "vitest.config.ts", "tsdown.config.ts"],
|
|
3
|
-
// Visit https://aka.ms/tsconfig to read more about this file
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
// File Layout
|
|
6
|
-
"rootDir": "./src",
|
|
7
|
-
"outDir": "./dist",
|
|
8
|
-
|
|
9
|
-
// Environment Settings
|
|
10
|
-
// See also https://aka.ms/tsconfig/module
|
|
11
|
-
"module": "preserve",
|
|
12
|
-
"target": "esnext",
|
|
13
|
-
"moduleResolution": "bundler",
|
|
14
|
-
"types": ["vitest/globals"],
|
|
15
|
-
// For nodejs:
|
|
16
|
-
// "lib": ["esnext"],
|
|
17
|
-
// "types": ["node"],
|
|
18
|
-
// and npm install -D @types/node
|
|
19
|
-
|
|
20
|
-
// Other Outputs
|
|
21
|
-
"sourceMap": true,
|
|
22
|
-
"declaration": true,
|
|
23
|
-
"declarationMap": true,
|
|
24
|
-
|
|
25
|
-
// Stricter Typechecking Options
|
|
26
|
-
"noUncheckedIndexedAccess": true,
|
|
27
|
-
"exactOptionalPropertyTypes": true,
|
|
28
|
-
|
|
29
|
-
// Style Options
|
|
30
|
-
// "noImplicitReturns": true,
|
|
31
|
-
// "noImplicitOverride": true,
|
|
32
|
-
// "noUnusedLocals": true,
|
|
33
|
-
// "noUnusedParameters": true,
|
|
34
|
-
// "noFallthroughCasesInSwitch": true,
|
|
35
|
-
// "noPropertyAccessFromIndexSignature": true,
|
|
36
|
-
|
|
37
|
-
// Recommended Options
|
|
38
|
-
"strict": true,
|
|
39
|
-
"jsx": "react-jsx",
|
|
40
|
-
"verbatimModuleSyntax": true,
|
|
41
|
-
"isolatedModules": true,
|
|
42
|
-
"noUncheckedSideEffectImports": true,
|
|
43
|
-
"moduleDetection": "force",
|
|
44
|
-
"skipLibCheck": true
|
|
45
|
-
}
|
|
46
|
-
}
|
package/tsdown.config.ts
DELETED