Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/felix-kaestner/lazy
A small wrapper class for lazy computed values
https://github.com/felix-kaestner/lazy
typescript
Last synced: about 5 hours ago
JSON representation
A small wrapper class for lazy computed values
- Host: GitHub
- URL: https://github.com/felix-kaestner/lazy
- Owner: felix-kaestner
- License: mit
- Created: 2022-01-21T21:05:04.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-30T00:09:13.000Z (17 days ago)
- Last Synced: 2024-10-30T02:47:25.442Z (17 days ago)
- Topics: typescript
- Language: JavaScript
- Homepage:
- Size: 5.25 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Lazy
A small wrapper class for lazy computed values.
## Install
Install with `npm` or `yarn`:
```
$ npm i git+https://github.com/felix-kaestner/lazy
``````
$ yarn add git+https://github.com/felix-kaestner/lazy
```## Usage
Generate a lazy computed value which is memoized once it is computed.
```JavaScript
import Lazy from '@felix-kaestner/lazy'const lazy = new Lazy(() => {
// Do some computation which should be run lazily when needed and then memoized
// ...
return 42
})// Retrieve the value from the instance
// using the `value` property
console.log(lazy.value)
```**TypeScript**
The `Lazy` class accepts a generic type parameter.
```TypeScript
import Lazy from '@felix-kaestner/lazy'const lazy = new Lazy(() => {
// ...
return 42
})
```## Contribute
All contributions in any form are welcome! 🙌
Just use the [Issue](.github/ISSUE_TEMPLATE) and [Pull Request](.github/PULL_REQUEST_TEMPLATE) templates and
I will be happy to review your suggestions. 👍---
Released under the [MIT License](LICENSE).