open-index/open-npm huggingface dataset:
npm package: @financial-times/n-lambda
Description: Like n-express, but for λ
Latest version: 1.2.2

# n-lambda
Like n-express, but for λ

## Usage

```js
'use strict';

var λ = require('@financial-times/n-lambda');

exports.handle = λ(function(event) {
	return somethingThatReturnsAPromise()
	  .catch(function(err) {
	    if (/* err is a server (rather than a user) error */) {
	      λ.raven.captureError(err);
	    }
	    return Promise.reject(err);
	  });
});
```
npm package: @financial-times/n-map-cache-light
Description: In-memory cache with no dependencies
Author: doramilitaru
Latest version: 1.0.7

# n-map-cache-light
Basic, configurable in-memory cache. No dependencies.

## Installation

```sh
npm install --save @financial-times/n-map-cache-light
```

## Quick start

```js
const MapCache = require('@financial-times/n-map-cache-light').MapCache;

const options = {
  ttl: 3600, // seconds
  interval: 7200, // seconds - purge interval
  memory: 100 * 1024 * 1024, // bytes
  capacity: 100 // items held in cache
};
// all properties are optional
// if none specified, default to 100MB, 1h TimeCache

let cache = new MapCache(options);

```

`MapCache` extends [ECMAScript `Map`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Map).

```js
// use like Map
cache.set(key, value);
cache.get(key);
cache.delete(key);
cache.clear();

for(let [key, value] of cache.entries()) {
  ...
}
```

***

### ByteSize utility

A simple library to *estimate* the size of JavaScript objects in bytes.

```js
const ByteSize = require('@financial-times/n-map-cache-light').ByteSize;
```

#### Usage

```js
let computedSize = new ByteSize(myBigNestedObject);
const size = computedSize.value; // bytes
const megabytes = computedSize._format('MB'); // megabytes
```