@lsby/ts-fp-data 0.0.9-beta.3 → 0.1.0

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.
@@ -35,9 +35,6 @@ var Just = class _Just extends Maybe {
35
35
  super();
36
36
  this.\u503C = \u503C;
37
37
  }
38
- match(onJust, _onNothing) {
39
- return onJust(this.\u503C);
40
- }
41
38
  map(f) {
42
39
  return new _Just(f(this.\u503C));
43
40
  }
@@ -50,17 +47,23 @@ var Just = class _Just extends Maybe {
50
47
  isNothing() {
51
48
  return false;
52
49
  }
50
+ assertJust() {
51
+ return this;
52
+ }
53
+ assertNothing() {
54
+ throw new Error("\u65AD\u8A00\u5931\u8D25");
55
+ }
53
56
  getJust() {
54
57
  return this.\u503C;
55
58
  }
56
59
  getJustOrNull() {
57
60
  return this.\u503C;
58
61
  }
62
+ match(onJust, _onNothing) {
63
+ return onJust(this.\u503C);
64
+ }
59
65
  };
60
66
  var Nothing = class _Nothing extends Maybe {
61
- match(_onJust, onNothing) {
62
- return onNothing();
63
- }
64
67
  map(_f) {
65
68
  return new _Nothing();
66
69
  }
@@ -73,9 +76,18 @@ var Nothing = class _Nothing extends Maybe {
73
76
  isNothing() {
74
77
  return true;
75
78
  }
79
+ assertJust() {
80
+ throw new Error("\u65AD\u8A00\u5931\u8D25");
81
+ }
82
+ assertNothing() {
83
+ return this;
84
+ }
76
85
  getJustOrNull() {
77
86
  return null;
78
87
  }
88
+ match(_onJust, onNothing) {
89
+ return onNothing();
90
+ }
79
91
  };
80
92
  // Annotate the CommonJS export names for ESM import in node:
81
93
  0 && (module.exports = {
@@ -4,27 +4,33 @@ declare abstract class Maybe<A> {
4
4
  abstract bind<B>(f: (a: A) => Maybe<B>): Maybe<B>;
5
5
  abstract isJust(): this is Just<A>;
6
6
  abstract isNothing(): this is Nothing<A>;
7
+ abstract assertJust(): Just<A>;
8
+ abstract assertNothing(): Nothing<A>;
7
9
  abstract getJustOrNull(): A | null;
8
10
  abstract match<B>(onJust: (a: A) => B, onNothing: () => B): B;
9
11
  }
10
12
  declare class Just<A> extends Maybe<A> {
11
13
  private 值;
12
14
  constructor(值: A);
13
- match<B>(onJust: (a: A) => B, _onNothing: () => B): B;
14
15
  map<B>(f: (a: A) => B): Maybe<B>;
15
16
  bind<B>(f: (a: A) => Maybe<B>): Maybe<B>;
16
17
  isJust(): this is Just<A>;
17
18
  isNothing(): this is Nothing<A>;
19
+ assertJust(): Just<A>;
20
+ assertNothing(): Nothing<A>;
18
21
  getJust(): A;
19
22
  getJustOrNull(): A | null;
23
+ match<B>(onJust: (a: A) => B, _onNothing: () => B): B;
20
24
  }
21
25
  declare class Nothing<A> extends Maybe<A> {
22
- match<B>(_onJust: (a: A) => B, onNothing: () => B): B;
23
26
  map<B>(_f: (a: A) => B): Maybe<B>;
24
27
  bind<B>(_f: (a: A) => Maybe<B>): Maybe<B>;
25
28
  isJust(): this is Just<A>;
26
29
  isNothing(): this is Nothing<A>;
30
+ assertJust(): Just<A>;
31
+ assertNothing(): Nothing<A>;
27
32
  getJustOrNull(): A | null;
33
+ match<B>(_onJust: (a: A) => B, onNothing: () => B): B;
28
34
  }
29
35
 
30
36
  export { Just, Maybe, Nothing };
@@ -219,9 +219,6 @@ var Just = class _Just extends Maybe {
219
219
  super();
220
220
  this.\u503C = \u503C;
221
221
  }
222
- match(onJust, _onNothing) {
223
- return onJust(this.\u503C);
224
- }
225
222
  map(f) {
226
223
  return new _Just(f(this.\u503C));
227
224
  }
@@ -234,17 +231,23 @@ var Just = class _Just extends Maybe {
234
231
  isNothing() {
235
232
  return false;
236
233
  }
234
+ assertJust() {
235
+ return this;
236
+ }
237
+ assertNothing() {
238
+ throw new Error("\u65AD\u8A00\u5931\u8D25");
239
+ }
237
240
  getJust() {
238
241
  return this.\u503C;
239
242
  }
240
243
  getJustOrNull() {
241
244
  return this.\u503C;
242
245
  }
246
+ match(onJust, _onNothing) {
247
+ return onJust(this.\u503C);
248
+ }
243
249
  };
244
250
  var Nothing = class _Nothing extends Maybe {
245
- match(_onJust, onNothing) {
246
- return onNothing();
247
- }
248
251
  map(_f) {
249
252
  return new _Nothing();
250
253
  }
@@ -257,9 +260,18 @@ var Nothing = class _Nothing extends Maybe {
257
260
  isNothing() {
258
261
  return true;
259
262
  }
263
+ assertJust() {
264
+ throw new Error("\u65AD\u8A00\u5931\u8D25");
265
+ }
266
+ assertNothing() {
267
+ return this;
268
+ }
260
269
  getJustOrNull() {
261
270
  return null;
262
271
  }
272
+ match(_onJust, onNothing) {
273
+ return onNothing();
274
+ }
263
275
  };
264
276
 
265
277
  // src/func/seq.ts
@@ -9,9 +9,6 @@ var Just = class _Just extends Maybe {
9
9
  super();
10
10
  this.\u503C = \u503C;
11
11
  }
12
- match(onJust, _onNothing) {
13
- return onJust(this.\u503C);
14
- }
15
12
  map(f) {
16
13
  return new _Just(f(this.\u503C));
17
14
  }
@@ -24,17 +21,23 @@ var Just = class _Just extends Maybe {
24
21
  isNothing() {
25
22
  return false;
26
23
  }
24
+ assertJust() {
25
+ return this;
26
+ }
27
+ assertNothing() {
28
+ throw new Error("\u65AD\u8A00\u5931\u8D25");
29
+ }
27
30
  getJust() {
28
31
  return this.\u503C;
29
32
  }
30
33
  getJustOrNull() {
31
34
  return this.\u503C;
32
35
  }
36
+ match(onJust, _onNothing) {
37
+ return onJust(this.\u503C);
38
+ }
33
39
  };
34
40
  var Nothing = class _Nothing extends Maybe {
35
- match(_onJust, onNothing) {
36
- return onNothing();
37
- }
38
41
  map(_f) {
39
42
  return new _Nothing();
40
43
  }
@@ -47,9 +50,18 @@ var Nothing = class _Nothing extends Maybe {
47
50
  isNothing() {
48
51
  return true;
49
52
  }
53
+ assertJust() {
54
+ throw new Error("\u65AD\u8A00\u5931\u8D25");
55
+ }
56
+ assertNothing() {
57
+ return this;
58
+ }
50
59
  getJustOrNull() {
51
60
  return null;
52
61
  }
62
+ match(_onJust, onNothing) {
63
+ return onNothing();
64
+ }
53
65
  };
54
66
 
55
67
  export {
@@ -4,27 +4,33 @@ declare abstract class Maybe<A> {
4
4
  abstract bind<B>(f: (a: A) => Maybe<B>): Maybe<B>;
5
5
  abstract isJust(): this is Just<A>;
6
6
  abstract isNothing(): this is Nothing<A>;
7
+ abstract assertJust(): Just<A>;
8
+ abstract assertNothing(): Nothing<A>;
7
9
  abstract getJustOrNull(): A | null;
8
10
  abstract match<B>(onJust: (a: A) => B, onNothing: () => B): B;
9
11
  }
10
12
  declare class Just<A> extends Maybe<A> {
11
13
  private 值;
12
14
  constructor(值: A);
13
- match<B>(onJust: (a: A) => B, _onNothing: () => B): B;
14
15
  map<B>(f: (a: A) => B): Maybe<B>;
15
16
  bind<B>(f: (a: A) => Maybe<B>): Maybe<B>;
16
17
  isJust(): this is Just<A>;
17
18
  isNothing(): this is Nothing<A>;
19
+ assertJust(): Just<A>;
20
+ assertNothing(): Nothing<A>;
18
21
  getJust(): A;
19
22
  getJustOrNull(): A | null;
23
+ match<B>(onJust: (a: A) => B, _onNothing: () => B): B;
20
24
  }
21
25
  declare class Nothing<A> extends Maybe<A> {
22
- match<B>(_onJust: (a: A) => B, onNothing: () => B): B;
23
26
  map<B>(_f: (a: A) => B): Maybe<B>;
24
27
  bind<B>(_f: (a: A) => Maybe<B>): Maybe<B>;
25
28
  isJust(): this is Just<A>;
26
29
  isNothing(): this is Nothing<A>;
30
+ assertJust(): Just<A>;
31
+ assertNothing(): Nothing<A>;
27
32
  getJustOrNull(): A | null;
33
+ match<B>(_onJust: (a: A) => B, onNothing: () => B): B;
28
34
  }
29
35
 
30
36
  export { Just, Maybe, Nothing };
@@ -2,7 +2,7 @@ import {
2
2
  Just,
3
3
  Maybe,
4
4
  Nothing
5
- } from "../chunk-PP7TCBHD.js";
5
+ } from "../chunk-CQG32QQC.js";
6
6
  export {
7
7
  Just,
8
8
  Maybe,
package/dist/esm/index.js CHANGED
@@ -1,14 +1,14 @@
1
+ import {
2
+ Just,
3
+ Maybe,
4
+ Nothing
5
+ } from "./chunk-CQG32QQC.js";
1
6
  import {
2
7
  seqArrayEither,
3
8
  seqArrayTask,
4
9
  seqEitherArray,
5
10
  seqEitherTask
6
11
  } from "./chunk-IHXXIFRN.js";
7
- import {
8
- Just,
9
- Maybe,
10
- Nothing
11
- } from "./chunk-PP7TCBHD.js";
12
12
  import {
13
13
  Task,
14
14
  TaskDo
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lsby/ts-fp-data",
3
- "version": "0.0.9-beta.3",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "require": "./dist/cjs/index.cjs",
@@ -9,34 +9,30 @@
9
9
  "files": [
10
10
  "dist"
11
11
  ],
12
- "dependencies": {},
12
+ "scripts": {
13
+ "build:all": "npm run build:cjs && npm run build:esm",
14
+ "build:cjs": "tsup src/**/*.ts --format cjs --clean --dts -d dist/cjs",
15
+ "build:esm": "tsup src/**/*.ts --format esm --clean --dts -d dist/esm",
16
+ "check:all": "npm run check:format && npm run check:lint && npm run check:type",
17
+ "check:format": "prettier --write .",
18
+ "check:lint": "eslint . --fix",
19
+ "check:type": "tsc --noEmit",
20
+ "check:type:watch": "tsc --noEmit -w",
21
+ "pub:public": "npm run check:all && npm run test:base && npm run build:all && bumpp && npm publish --access public",
22
+ "test:base": "npm run check:all && vitest run",
23
+ "test:coverage": "npm run check:all && vitest run --coverage && open-cli ./coverage/index.html"
24
+ },
13
25
  "devDependencies": {
14
26
  "@ianvs/prettier-plugin-sort-imports": "^4.2.1",
27
+ "@lsby/eslint-config": "^0.0.2",
15
28
  "@types/node": "^20.12.10",
16
- "@typescript-eslint/eslint-plugin": "^7.8.0",
17
- "@typescript-eslint/parser": "^7.8.0",
29
+ "@vitest/coverage-v8": "^2.0.2",
18
30
  "bumpp": "^9.4.1",
19
- "eslint": "^8.56.0",
20
- "eslint-config-prettier": "^9.1.0",
21
- "eslint-plugin-sort-class-members": "^1.20.0",
22
- "eslint-plugin-unused-imports": "^3.2.0",
31
+ "open-cli": "^8.0.0",
23
32
  "prettier": "3.2.5",
24
33
  "prettier-plugin-packagejson": "^2.5.0",
25
34
  "tsup": "^8.0.2",
26
- "tsx": "^4.9.3",
27
- "typescript": "^5.4.5"
28
- },
29
- "scripts": {
30
- "build:all": "npm run build:cjs && npm run build:esm",
31
- "build:cjs": "tsup src/**/*.ts --format cjs --clean --dts -d dist/cjs",
32
- "build:esm": "tsup src/**/*.ts --format esm --clean --dts -d dist/esm",
33
- "other:clean": "rm -rf .parcel-cache dist",
34
- "other:format": "prettier --write .",
35
- "other:lint": "eslint . --fix",
36
- "other:pub": "npm run other:typecheck && npm run build:all && bumpp && pnpm -r publish --access public",
37
- "other:typecheck": "tsc --noEmit",
38
- "other:typecheck:watch": "tsc --noEmit -w",
39
- "run:start": "tsx src/index.ts",
40
- "run:test": "tsx test/index.ts"
35
+ "typescript": "^5.4.5",
36
+ "vitest": "^2.0.2"
41
37
  }
42
- }
38
+ }