open-index/open-npm huggingface dataset:
npm package: @maxdome/cache
Description: ```javascript const cache = require('@maxdome/cache')(client);
Latest version: 1.0.2

# Usage

```javascript
const cache = require('@maxdome/cache')(client);

const value = await cache(
  'key',
  async () => 'value'
);
```

If the client supports `setJSON()` and `getJSON()` (e.g. [@maxdome/redis](https://www.npmjs.com/package/@maxdome/redis)) it
will be used to encode/decode the values.

```javascript
const cache = require('@maxdome/cache')(client);

const value = await cache(
  'key',
  async () => ({ example: 'example' })
);
```

## Expire  

An expire (in seconds) can be passed to automatically remove the value from the cache after certain time.

```javascript
const cache = require('@maxdome/cache')(client);

const value = await cache(
  'key',
  async () => 'value',
  1 * 60 * 60
);
```

If the expire is an object supporting `asSeconds()` (e.g. [@maxdome/duration](https://www.npmjs.com/package/@maxdome/duration) or [moment.duration](http://momentjs.com/docs/#/durations/)) it will be used.

```javascript
const cache = require('@maxdome/cache')(client);
const duration = require('@maxdome/duration');

const value = await cache(
  'key',
  async () => 'value',
  duration('1h')
);
```

## Invalidate  

The invalidate will be called after getting the value from the cache and can, if return true, force to get a new value.

```javascript
const cache = require('@maxdome/cache')(client);

const value = await cache(
  'key',
  async () => 'value',
  { invalidate: value => value.invalid }
);
```

## Refresh

If `refresh` is `true`, the expire will always be refreshed if the key is available and the value is valid.

```javascript
const cache = require('@maxdome/cache')(client);

const value = await cache(
  'key',
  async () => 'value',
  { refresh: true }
);
```
npm package: @maxdome/cbe2
Description: ## Get an asset without knowing the type
Latest version: 1.0.3

# Usage

## Get an asset without knowing the type

```javascript
const cbe2 = require('@maxdome/cbe2')({ cbe2Url: process.env.CBE2_URL });

const objectId = 0;
const mamAsset = cbe2.asset(objectId);
```

## Get an asset with the type

```javascript
const cbe2 = require('@maxdome/cbe2')({ cbe2Url: process.env.CBE2_URL });

const objectId = 0;
const objectType = '';
const mamAsset = cbe2.asset(objectId, objectType);
```

## Get the asset data of all updated assets for a diff

```javascript
const cbe2 = require('@maxdome/cbe2')({ cbe2Url: process.env.CBE2_URL });

const timestamp = 0;
const diffs = cbe2.diff(timestamp);

for (const diff of diffs) {
  for (const objectId of diff.updated) {
    const mamAsset = await cb2.asset(objectId, diff.objectType);
  }
}
```