# memoize_until

> A unique Memoization Pattern which memoizes until the next time metric - could be until the next minute, hour, day, week.

Latest version **1.0.3** (published 2019-03-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install memoize_until
pnpm add memoize_until
yarn add memoize_until
bun add memoize_until
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2019-03-09 |
| First published | 2019-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Ritikesh G |
| Maintainers | ritikesh |
| Keywords | memoization, typescript, caching, javascript |

## Links

- npm: https://www.npmjs.com/package/memoize_until
- Repository: https://github.com/ritikesh/memoize_until
- Homepage: https://github.com/ritikesh/memoize_until#readme
- Issues: https://github.com/ritikesh/memoize_until/issues
- npm.io page: https://npm.io/package/memoize_until

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2019-03-09
- 1.0.2 — 2019-03-07
- 1.0.1 — 2019-03-07

## README

# MemoizeUntil

A unique Memoization Pattern which memoizes until the next time metric - could be until the next minute, hour, day, week.

## Get Started

Install `memoize_until` with: 

```bash
npm install memoize_until --save-dev
```

## Usage

```javascript
const MemoizeUntil = require('memoize_until').MemoizeUntil

MemoizeUntil.fetch('min', 'default', () => { 
    return 'SomeComplexOperation'; 
})
```

#### options:
1. `min` : Metric until when you want to memoize. Can be one of ['min', 'hour', 'day', 'week']

2. `default` : All metric levels come with a 'default' key. More can be added by [initializing](#Initialisation) `MemoizeUntil` with extra keys

3. `cb`: callback function. This callback function must return a value which needs to be memoized/cached.

## Initialisation
To add custom keys to each metric, pass a custom object to the `init` function of `MemoizeUntil`.
```javascript
MemoizeUntil.init({ 
    min: ['custom1', 'custom2']
})

MemoizeUntil.fetch('min', 'custom1', () => { 
    return 'SomeComplexOperation'; 
})
```

## Extend
To add custom keys during runtime to any metric, use the `extend` function of `MemoizeUntil`.
```javascript
let runtime_key = 'runtime_key';
MemoizeUntil.extend('min', runtime_key)

MemoizeUntil.fetch('min', runtime_key, () => { 
    return 'SomeComplexOperation'; 
})
```

## Nulls
if the value to be memoized is `undefined` or `null`, `MemoizeUntil` wraps it underneath a pseudo null-like object called `NullObject` and always returns `undefined`. This ensures that even nulls are memoized.

## License
[Ritikesh](https://ritikesh.github.io)  
Licensed under the MIT license.

---
_Source: https://npm.io/package/memoize_until · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
