Skip to content

Commit

Permalink
Addition of the common lazy in the javascript readme
Browse files Browse the repository at this point in the history
  • Loading branch information
joooKiwi committed Aug 14, 2023
1 parent 37a55da commit 4ecef7b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions javascript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* [Usage](#usage)
* [Lazy value](#lazy-value)
* [Non-lazy value](#non-lazy-value)
* [Common lazy](#common-lazy)
* [Contribution](#contribution)

This project is a simple implementation of the [Kotlin Lazy](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-lazy/).
Expand Down Expand Up @@ -58,6 +59,37 @@ firstValue.value // 2
firstValue.isInitialized // true
```

### Common lazy

When utilizing the lazy methods,
it always creates a new instance.

But, there could be some cases where an already known value is there.

Here is the full list of the common `Lazy` instances:

| Value | With string | With character |
|----------------------------------------------------|-------------|:---------------|
| `null` | yes | |
| `undefined` | yes | |
| `true` / `false` | yes | |
| `-1` / `0` / `1` / `2` | yes | yes |
| `NaN` / `Infinity` / `-Infinity` | yes | |
| `ln(2)` / `ln(10)` | | |
| `log₂(E)` / `log₁₀(E)` | | |
| `E`, `PI` | | |
| ` ` / `\t` / `\n` | | yes |
| epoch / now / tomorrow / yesterday | | |
| invalid Date | yes | |
| empty String → `''` | | |
| empty object → `Readonly<{}>` | | |
| empty Array → `readonly []` | | |
| empty Set → `ReadonlySet<never>` | | |
| empty WeakSet → `Readonly<WeakSet<never>>` | | |
| empty Map → `ReadonlyMap<unknown, never>` | | |
| empty WeakMap → `Readonly<WeakMap<object, never>>` | | |


## Contribution
You can contribute to great simple packages.
All with similar behaviour across different languages (like Java, Kotlin, C# and PHP).
Expand Down

0 comments on commit 4ecef7b

Please sign in to comment.