retuple 1.0.0-next.12 → 1.0.0-next.14
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 +396 -184
- package/dist/index.d.cts +291 -491
- package/dist/index.d.ts +291 -491
- package/dist/index.js +394 -180
- package/dist/symbol.cjs +38 -0
- package/dist/symbol.d.cts +36 -0
- package/dist/symbol.d.ts +36 -0
- package/dist/symbol.js +35 -0
- package/package.json +12 -2
package/dist/symbol.cjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResultLikeSymbol = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ## Result Like Symbol
|
|
6
|
+
*
|
|
7
|
+
* Implement a custom result-like by implementing the `ResultLike` interface
|
|
8
|
+
* on a class or object. An object with this implementation can be converted
|
|
9
|
+
* to a `Result` and can be used in most places where a `Result` is required.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { ResultLikeSymbol } from "retuple/symbol";
|
|
13
|
+
* import { Result, Ok, Err, type ResultLike } from "retuple";
|
|
14
|
+
*
|
|
15
|
+
* class CustomResult<T> implements ResultLike<T, CustomError> {
|
|
16
|
+
* value: T;
|
|
17
|
+
*
|
|
18
|
+
* constructor(value: T) {
|
|
19
|
+
* this.value = value;
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* [ResultLikeSymbol](): Result<T, CustomError> {
|
|
23
|
+
* return this.value === "test"
|
|
24
|
+
* ? Ok(this.value)
|
|
25
|
+
* : Err(new CustomError("Value was not test"));
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* const custom = new CustomResult("test");
|
|
30
|
+
* const result: Result<string, Error> = Result(custom);
|
|
31
|
+
*
|
|
32
|
+
* const chain = Ok()
|
|
33
|
+
* .$map(() => "value")
|
|
34
|
+
* .$andThen((value) => new CustomResult(value))
|
|
35
|
+
* .$or(myresult);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
exports.ResultLikeSymbol = Symbol("retuple/result");
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ## Result Like Symbol
|
|
3
|
+
*
|
|
4
|
+
* Implement a custom result-like by implementing the `ResultLike` interface
|
|
5
|
+
* on a class or object. An object with this implementation can be converted
|
|
6
|
+
* to a `Result` and can be used in most places where a `Result` is required.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { ResultLikeSymbol } from "retuple/symbol";
|
|
10
|
+
* import { Result, Ok, Err, type ResultLike } from "retuple";
|
|
11
|
+
*
|
|
12
|
+
* class CustomResult<T> implements ResultLike<T, CustomError> {
|
|
13
|
+
* value: T;
|
|
14
|
+
*
|
|
15
|
+
* constructor(value: T) {
|
|
16
|
+
* this.value = value;
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* [ResultLikeSymbol](): Result<T, CustomError> {
|
|
20
|
+
* return this.value === "test"
|
|
21
|
+
* ? Ok(this.value)
|
|
22
|
+
* : Err(new CustomError("Value was not test"));
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* const custom = new CustomResult("test");
|
|
27
|
+
* const result: Result<string, Error> = Result(custom);
|
|
28
|
+
*
|
|
29
|
+
* const chain = Ok()
|
|
30
|
+
* .$map(() => "value")
|
|
31
|
+
* .$andThen((value) => new CustomResult(value))
|
|
32
|
+
* .$or(myresult);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare const ResultLikeSymbol: unique symbol;
|
|
36
|
+
export type ResultLikeSymbol = typeof ResultLikeSymbol;
|
package/dist/symbol.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ## Result Like Symbol
|
|
3
|
+
*
|
|
4
|
+
* Implement a custom result-like by implementing the `ResultLike` interface
|
|
5
|
+
* on a class or object. An object with this implementation can be converted
|
|
6
|
+
* to a `Result` and can be used in most places where a `Result` is required.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { ResultLikeSymbol } from "retuple/symbol";
|
|
10
|
+
* import { Result, Ok, Err, type ResultLike } from "retuple";
|
|
11
|
+
*
|
|
12
|
+
* class CustomResult<T> implements ResultLike<T, CustomError> {
|
|
13
|
+
* value: T;
|
|
14
|
+
*
|
|
15
|
+
* constructor(value: T) {
|
|
16
|
+
* this.value = value;
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* [ResultLikeSymbol](): Result<T, CustomError> {
|
|
20
|
+
* return this.value === "test"
|
|
21
|
+
* ? Ok(this.value)
|
|
22
|
+
* : Err(new CustomError("Value was not test"));
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* const custom = new CustomResult("test");
|
|
27
|
+
* const result: Result<string, Error> = Result(custom);
|
|
28
|
+
*
|
|
29
|
+
* const chain = Ok()
|
|
30
|
+
* .$map(() => "value")
|
|
31
|
+
* .$andThen((value) => new CustomResult(value))
|
|
32
|
+
* .$or(myresult);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare const ResultLikeSymbol: unique symbol;
|
|
36
|
+
export type ResultLikeSymbol = typeof ResultLikeSymbol;
|
package/dist/symbol.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ## Result Like Symbol
|
|
3
|
+
*
|
|
4
|
+
* Implement a custom result-like by implementing the `ResultLike` interface
|
|
5
|
+
* on a class or object. An object with this implementation can be converted
|
|
6
|
+
* to a `Result` and can be used in most places where a `Result` is required.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { ResultLikeSymbol } from "retuple/symbol";
|
|
10
|
+
* import { Result, Ok, Err, type ResultLike } from "retuple";
|
|
11
|
+
*
|
|
12
|
+
* class CustomResult<T> implements ResultLike<T, CustomError> {
|
|
13
|
+
* value: T;
|
|
14
|
+
*
|
|
15
|
+
* constructor(value: T) {
|
|
16
|
+
* this.value = value;
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* [ResultLikeSymbol](): Result<T, CustomError> {
|
|
20
|
+
* return this.value === "test"
|
|
21
|
+
* ? Ok(this.value)
|
|
22
|
+
* : Err(new CustomError("Value was not test"));
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* const custom = new CustomResult("test");
|
|
27
|
+
* const result: Result<string, Error> = Result(custom);
|
|
28
|
+
*
|
|
29
|
+
* const chain = Ok()
|
|
30
|
+
* .$map(() => "value")
|
|
31
|
+
* .$andThen((value) => new CustomResult(value))
|
|
32
|
+
* .$or(myresult);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export const ResultLikeSymbol = Symbol("retuple/result");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "retuple",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.14",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"test": "vitest",
|
|
6
6
|
"lint": "eslint . --ext .ts -c eslint.config.mjs --fix",
|
|
@@ -11,7 +11,12 @@
|
|
|
11
11
|
"main": "./dist/index.cjs",
|
|
12
12
|
"types": "./dist/index.d.cts",
|
|
13
13
|
"module": "./dist/index.js",
|
|
14
|
-
"zshy":
|
|
14
|
+
"zshy": {
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./src/index.ts",
|
|
17
|
+
"./symbol": "./src/symbol.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
15
20
|
"keywords": [
|
|
16
21
|
"result",
|
|
17
22
|
"safe",
|
|
@@ -43,6 +48,11 @@
|
|
|
43
48
|
"types": "./dist/index.d.cts",
|
|
44
49
|
"import": "./dist/index.js",
|
|
45
50
|
"require": "./dist/index.cjs"
|
|
51
|
+
},
|
|
52
|
+
"./symbol": {
|
|
53
|
+
"types": "./dist/symbol.d.cts",
|
|
54
|
+
"import": "./dist/symbol.js",
|
|
55
|
+
"require": "./dist/symbol.cjs"
|
|
46
56
|
}
|
|
47
57
|
},
|
|
48
58
|
"files": [
|