From 4ecef7ba30133d86771581549ae2a3e17298ccc9 Mon Sep 17 00:00:00 2001 From: JoooKiwi <66183590+joooKiwi@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:36:34 -0400 Subject: [PATCH] Addition of the common lazy in the javascript readme --- javascript/README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/javascript/README.md b/javascript/README.md index 789866e..d4bcb9c 100644 --- a/javascript/README.md +++ b/javascript/README.md @@ -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/). @@ -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` | | | +| empty WeakSet → `Readonly>` | | | +| empty Map → `ReadonlyMap` | | | +| empty WeakMap → `Readonly>` | | | + + ## Contribution You can contribute to great simple packages. All with similar behaviour across different languages (like Java, Kotlin, C# and PHP).