Skip to content

Commit

Permalink
Merge branch 'release/v1.5.0-js' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
joooKiwi committed Jul 21, 2024
2 parents 80220cb + 87e6423 commit e7c088a
Show file tree
Hide file tree
Showing 17 changed files with 426 additions and 75 deletions.
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
# Lazy

This project has the purpose to have a similar implementation depending on the language used.
It can be from `Javascript`, `Java`, `Kotlin`, `PHP` and even `C#`.
This project has the purpose to expand on the lazy pattern on giving ways
to have a "lazy-like" holder
or "true-lazy" holder in the same structure.

_(Maybe other languages will be added, we will see)_
It has its origin in `Kotlin` & `C#`,
but expand on their use to include the nullable type as a valid type.

It will try to include its behaviour across different languages
(`Javascript`, `Java`, `Kotlin`, `PHP`, `C#` and possibly more)

## Publication location

This project only has the Javascript (with Typescript) uploaded.

But other languages will be eventually added

| Language | Published |
|:--------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| Javascript<br/>Typescript | [Published to npm](https://www.npmjs.com/package/@joookiwi/lazy)<br/>[![downloads](https://img.shields.io/npm/dt/@joookiwi/lazy.svg)](https://npm-stat.com/charts.html?package=@joookiwi/lazy) |
| Java | Maven |
| Kotlin | [Integrated in the language](https://kotlinlang.org/docs/delegated-properties.html#observable-properties) |
| PHP | Composer |
| C# | Nuget |
| Language | Published |
|:--------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| Javascript<br/>Typescript | [Published to npm](https://www.npmjs.com/package/@joookiwi/lazy)<br/>[![downloads](https://img.shields.io/npm/dt/@joookiwi/lazy.svg)](https://npm-stat.com/charts.html?package=@joookiwi/lazy) |
| Java | Maven |
| Kotlin | [Integrated in the language](https://kotlinlang.org/docs/delegated-properties.html#observable-properties)<br/>_(but common values are to be added)_ |
| PHP | Composer |
| C# | Nuget |

## Related projects

Expand All @@ -36,6 +41,7 @@ You can contribute to my projects in 2 different ways

| JS/TS | Date | Quick note |
|------------------------------------------------------------------|----------------------|-------------------------------------------------------------------------------------------|
| [1.5.0](https://github.com/joooKiwi/lazy/releases/tag/v1.5.0-js) | July 21st, 2024 | Addition of `lazyOf` for the predefined `boolean`, `bigint` & `number` |
| 1.4.0 | March 31st, 2024 | Addition of [type](https://github.com/joooKiwi/type) to the dependency |
| [1.3.0](https://github.com/joooKiwi/lazy/releases/tag/v1.3.0-js) | February 19th, 2024 | Standardization of the ~~BIG_INT~~ / BIGINT to only be BIGINT |
| 1.2.1 | December 4th, 2023 | A small update of the dependencies |
Expand Down
7 changes: 7 additions & 0 deletions javascript/.idea/runConfigurations/Every_test_on_Lazy.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 28 additions & 20 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)
* [Specialized non-lazy value](#specialized-non-lazy-value)
* [Common lazy](#common-lazy)
* [Contribution](#contribution)

Expand Down Expand Up @@ -59,6 +60,13 @@ firstValue.value // 2
firstValue.isInitialized // true
```

### Specialized non-lazy value

There are some specialized `lazyOf()`-like `Lazy` to reuse the `CommonLazy` values depending on what it has received:
- `booleanLazyOf` for the `boolean`
- `numberLazyOf` for the `number`
- `bigintLazyOf` for the `bigint`

### Common lazy

When using the lazy methods,
Expand All @@ -68,26 +76,26 @@ 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 | With BigInt |
|----------------------------------------------------|:------------|:---------------|:------------|
| `null` | yes | | |
| `undefined` | yes | | |
| `true` / `false` | yes | | |
| `-1` / `0` / `1` / `2` | yes | 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>>` | | | |
| Value | With string | With character | With BigInt |
|-----------------------------------------------------|:------------|:---------------|:------------|
| `null` | yes | | |
| `undefined` | yes | | |
| `true` / `false` | yes | | |
| `-1` / `0` / `1` / `2` | yes | yes | yes |
| `NaN` / `` (infinity) / `-` _(-infinity)_ | yes | | |
| `ln(2)` / `ln(10)` | | | |
| `log₂(E)` / `log₁₀(E)` | | | |
| `E`, `π` _(pi)_, `τ` _(tau)_ | | | |
| ` ` / `\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<WeakKey>>` | | | |
| empty Map → `ReadonlyMap<unknown, never>` | | | |
| empty WeakMap → `Readonly<WeakMap<WeakKey, never>>` | | | |


## Contribution
Expand Down
2 changes: 1 addition & 1 deletion javascript/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {Config} from "jest"
export default {
clearMocks: true,
collectCoverage: true,
collectCoverageFrom: ["./src/**/*.ts", "!**/index.ts",],
collectCoverageFrom: ["./src/**/*.ts", "!**/index.ts", "!./src/Lazy.ts",],
coverageDirectory: "./coverage",
coverageProvider: "v8",
coverageReporters: ["lcov" , ["text", {skipFull: true,},],],
Expand Down
Loading

0 comments on commit e7c088a

Please sign in to comment.