open-index/open-npm huggingface dataset:
npm package: @istok/core
Description: istok's core entites, types and helpers to make extensions.
Author: Alexander "Snov" Semenchenko
Latest version: 0.9.2

# @istok/core

istok's core entites, types and helpers to make extensions.

### Sources

Source - repository with resources. Source can get resource by id, set resource with data by id, get filtered list of resources and clear all resources.

Sources Sequence - sequence of sources with primary use case for caches.

- Get resource from the first source where it is available.
- Set resource to all sources in the sequence.

Cachable Source - Sources Sequence with invalidation rules.

### Source Sequence

Source1 -- Source2 -- Source3
  Res1      Res1      Res1
            Res2      Res2
                      Res3

Strategy: Get First / Set All

`get('Res1')` -> Source1.Res1.
`set()
npm package: @istok/lazy-load
Description: Load all objects from async map.
Author: Alexander "Snov" Semenchenko
Latest version: 0.2.0

# @istok/lazy-load

Load all objects from async map.

## loadMap<T>(map: AsyncLoadMap<T> | undefined): Promise<ResolvedMap<T>>

Aawits for all promises in the map. Maps structure of form:

```js
const map = {
  a: () => asyncLoadA(),
  b: () => asyncLoadB(),
};
```

to:

```js
const resolvedMap = {
  a: awaitedA,
  b: awaitedB,
};
```

Usage

```js
const map = {
  a: () => Promise.resolve('a is loaded'),
  b: () => Promise.resolve('b is loaded'),
};

const resolvedMap = await loadMap(map);
```

## makeLoadMap<T>(elements: string[], loader: (element: string) => Promise<T>)

Usefull for dynamic imports of an array of files when using Webpack. Webpack can not resolve dynamic imports without static first part in the path. This will throw an error:

```js
const PATH = '../components/';
const component = 'a';
import(PATH + component);
```

While this is okay:

```js
const component = 'a';
import('../components/' + component);
```

Usage:

```js
const map = makeLoadMap(['Button', 'Input'], component => import('../components/' + component).then(m => m.default));
```