-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Mike96Angelo/v2-proposal
Reorganize package files for npm/deno publish
- Loading branch information
Showing
15 changed files
with
144 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,5 @@ dist | |
|
||
# TernJS port file | ||
.tern-port | ||
*.js | ||
*.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
**/*.ts | ||
!**/*.d.ts | ||
tests/**/* | ||
src\ copy/**/* | ||
docs/**/* | ||
.github/**/* | ||
jest.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Variant, variant, VariantTypeClass } from "./variant.js"; | ||
|
||
type ABCVariant = | ||
| Variant<"A", [a: string]> | ||
| Variant<"B", [b: number, bool: boolean]> | ||
| Variant<"C">; | ||
|
||
class ABC extends VariantTypeClass<ABCVariant> { | ||
// add any useful methods for ABC variants | ||
} | ||
|
||
const A = (a: string) => new ABC(variant("A", a)); | ||
const B = (b: number, bool: boolean) => new ABC(variant("B", b, bool)); | ||
const C = new ABC(variant("C")); | ||
|
||
export { A, B, C }; | ||
|
||
const handleABC = (abc: ABC) => | ||
console.log( | ||
abc, | ||
abc.match({ | ||
A(a) { | ||
return `A: ${a}`; | ||
}, | ||
B(b, bool) { | ||
return `B: ${b} | ${bool}`; | ||
}, | ||
C() { | ||
return "C"; | ||
}, | ||
}) | ||
); | ||
|
||
handleABC(A("string")); // 'A: string' | ||
handleABC(B(123, true)); // 'B: 123 | true' | ||
handleABC(C); // 'C' | ||
|
||
const handleA = (abc: ABC) => { | ||
if (abc.variant.kind === "A") { | ||
abc.variant.values; | ||
} | ||
console.log( | ||
abc, | ||
abc.match<string | number | boolean>({ | ||
A(a) { | ||
return `A: ${a}`; | ||
}, | ||
|
||
// catch all | ||
_() { | ||
return "B or C"; | ||
}, | ||
}) | ||
); | ||
}; | ||
|
||
handleA(A("string")); // 'A: string' | ||
handleA(B(123, true)); // 'B or C' | ||
handleA(C); // 'B or C' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from "./variant.js"; | ||
export * from "./optional.js"; | ||
export * from "./optional-pair.js"; | ||
export * from "./result.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Func } from "./util.types"; | ||
|
||
export type Pipe<T> = { | ||
pipe<R>(func: Func<[value: T], R>): Pipe<R>; | ||
value(): T; | ||
}; | ||
|
||
export const Pipe = <T>(value: T): Pipe<T> => ({ | ||
pipe(func) { | ||
return Pipe(func(value)); | ||
}, | ||
value() { | ||
return value; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters