generated from AlexXanderGrib/package-template
-
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.
feat!: better errors, asyncMap, removed biMatch
- Loading branch information
1 parent
21d033e
commit 1b805ed
Showing
38 changed files
with
5,459 additions
and
2,875 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import process from "node:process"; | ||
|
||
const Type = Object.freeze({ | ||
None: 0, | ||
Just: 1 | ||
}); | ||
|
||
class Just { | ||
static create(value) { | ||
return new Just(value); | ||
} | ||
|
||
get type() { | ||
return Type.Just; | ||
} | ||
|
||
constructor(value) { | ||
this.value = value; | ||
Object.freeze(this); | ||
} | ||
} | ||
|
||
class None { | ||
static instance = new None(); | ||
static create() { | ||
return None.instance; | ||
} | ||
|
||
get type() { | ||
return Type.None; | ||
} | ||
|
||
constructor() { | ||
Object.freeze(this); | ||
} | ||
} | ||
|
||
const store = Array(10_000); | ||
const base = process.memoryUsage().heapUsed; | ||
|
||
let allocated = 0; | ||
|
||
for (let i = 0; i < store.length; i++) { | ||
const random = Math.random(); | ||
|
||
store[i] = random > 0.5 ? Just.create(random) : None.create(); | ||
allocated += store[i] !== None.create(); | ||
} | ||
|
||
const diff = process.memoryUsage().heapUsed - base; | ||
const KB = 1024; | ||
|
||
const total = diff; | ||
const perJust = total / allocated; | ||
|
||
console.log( | ||
(total / KB).toFixed(2), | ||
"KB -", | ||
Math.ceil(perJust), | ||
"bytes / Just" | ||
); |
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,64 @@ | ||
[Package](../README.md) / [Exports](../modules.md) / DecorationError | ||
|
||
# Class: DecorationError | ||
|
||
## Hierarchy | ||
|
||
- `Error` | ||
|
||
↳ **`DecorationError`** | ||
|
||
## Table of contents | ||
|
||
### Constructors | ||
|
||
- [constructor](DecorationError.md#constructor) | ||
|
||
### Properties | ||
|
||
- [name](DecorationError.md#name) | ||
- [Messages](DecorationError.md#messages) | ||
|
||
## Constructors | ||
|
||
### constructor | ||
|
||
• **new DecorationError**(`message?`) | ||
|
||
#### Parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `message?` | [`EXPECTED_DECORATING_METHOD`](../enums/internal_.DecorationErrorMessages.md#expected_decorating_method) | | ||
|
||
#### Overrides | ||
|
||
Error.constructor | ||
|
||
#### Defined in | ||
|
||
dist/errors.d.ts:17 | ||
|
||
## Properties | ||
|
||
### name | ||
|
||
• **name**: `string` | ||
|
||
#### Overrides | ||
|
||
Error.name | ||
|
||
#### Defined in | ||
|
||
dist/errors.d.ts:16 | ||
|
||
___ | ||
|
||
### Messages | ||
|
||
▪ `Static` `Readonly` **Messages**: typeof [`DecorationErrorMessages`](../enums/internal_.DecorationErrorMessages.md) | ||
|
||
#### Defined in | ||
|
||
dist/errors.d.ts:15 |
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,64 @@ | ||
[Package](../README.md) / [Exports](../modules.md) / DeserializationError | ||
|
||
# Class: DeserializationError | ||
|
||
## Hierarchy | ||
|
||
- `Error` | ||
|
||
↳ **`DeserializationError`** | ||
|
||
## Table of contents | ||
|
||
### Constructors | ||
|
||
- [constructor](DeserializationError.md#constructor) | ||
|
||
### Properties | ||
|
||
- [name](DeserializationError.md#name) | ||
- [Messages](DeserializationError.md#messages) | ||
|
||
## Constructors | ||
|
||
### constructor | ||
|
||
• **new DeserializationError**(`message`) | ||
|
||
#### Parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `message` | [`DeserializationErrorMessages`](../enums/internal_.DeserializationErrorMessages.md) | | ||
|
||
#### Overrides | ||
|
||
Error.constructor | ||
|
||
#### Defined in | ||
|
||
dist/errors.d.ts:9 | ||
|
||
## Properties | ||
|
||
### name | ||
|
||
• **name**: `string` | ||
|
||
#### Overrides | ||
|
||
Error.name | ||
|
||
#### Defined in | ||
|
||
dist/errors.d.ts:8 | ||
|
||
___ | ||
|
||
### Messages | ||
|
||
▪ `Static` `Readonly` **Messages**: typeof [`DeserializationErrorMessages`](../enums/internal_.DeserializationErrorMessages.md) | ||
|
||
#### Defined in | ||
|
||
dist/errors.d.ts:7 |
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,64 @@ | ||
[Package](../README.md) / [Exports](../modules.md) / InvalidStateError | ||
|
||
# Class: InvalidStateError | ||
|
||
## Hierarchy | ||
|
||
- `Error` | ||
|
||
↳ **`InvalidStateError`** | ||
|
||
## Table of contents | ||
|
||
### Constructors | ||
|
||
- [constructor](InvalidStateError.md#constructor) | ||
|
||
### Properties | ||
|
||
- [name](InvalidStateError.md#name) | ||
- [Messages](InvalidStateError.md#messages) | ||
|
||
## Constructors | ||
|
||
### constructor | ||
|
||
• **new InvalidStateError**(`message?`) | ||
|
||
#### Parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `message?` | [`InvalidStateMessages`](../enums/internal_.InvalidStateMessages.md) | | ||
|
||
#### Overrides | ||
|
||
Error.constructor | ||
|
||
#### Defined in | ||
|
||
dist/errors.d.ts:26 | ||
|
||
## Properties | ||
|
||
### name | ||
|
||
• **name**: `string` | ||
|
||
#### Overrides | ||
|
||
Error.name | ||
|
||
#### Defined in | ||
|
||
dist/errors.d.ts:25 | ||
|
||
___ | ||
|
||
### Messages | ||
|
||
▪ `Static` `Readonly` **Messages**: typeof [`InvalidStateMessages`](../enums/internal_.InvalidStateMessages.md) | ||
|
||
#### Defined in | ||
|
||
dist/errors.d.ts:24 |
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,88 @@ | ||
[Package](../README.md) / [Exports](../modules.md) / UnwrapCustomError | ||
|
||
# Class: UnwrapCustomError | ||
|
||
## Hierarchy | ||
|
||
- `Error` | ||
|
||
↳ **`UnwrapCustomError`** | ||
|
||
## Table of contents | ||
|
||
### Constructors | ||
|
||
- [constructor](UnwrapCustomError.md#constructor) | ||
|
||
### Properties | ||
|
||
- [name](UnwrapCustomError.md#name) | ||
- [Messages](UnwrapCustomError.md#messages) | ||
|
||
### Methods | ||
|
||
- [inlineThrow](UnwrapCustomError.md#inlinethrow) | ||
|
||
## Constructors | ||
|
||
### constructor | ||
|
||
• **new UnwrapCustomError**(`message`) | ||
|
||
#### Parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `message` | `string` | | ||
|
||
#### Overrides | ||
|
||
Error.constructor | ||
|
||
#### Defined in | ||
|
||
dist/errors.d.ts:36 | ||
|
||
## Properties | ||
|
||
### name | ||
|
||
• **name**: `string` | ||
|
||
#### Overrides | ||
|
||
Error.name | ||
|
||
#### Defined in | ||
|
||
dist/errors.d.ts:34 | ||
|
||
___ | ||
|
||
### Messages | ||
|
||
▪ `Static` `Readonly` **Messages**: typeof [`UnwrapCustomErrorMessages`](../enums/internal_.UnwrapCustomErrorMessages.md) | ||
|
||
#### Defined in | ||
|
||
dist/errors.d.ts:33 | ||
|
||
## Methods | ||
|
||
### inlineThrow | ||
|
||
▸ `Static` **inlineThrow**(`message`): `never` | ||
|
||
#### Parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `message` | `string` | | ||
|
||
#### Returns | ||
|
||
`never` | ||
|
||
#### Defined in | ||
|
||
dist/errors.d.ts:35 |
Oops, something went wrong.