Sign In

cardigan

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cardigan

node.js function serialization

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

cardigan | node.js function serialization

version versioning branching styling build

Install

$ npm install --save cardigan

Usage

Function serialization:

const {serialize} = require('cardigan');

const add = serialize((a, b) => a + b);
const subtract = serialize((a, b) => a - b);

// Do something with serialized functions (e.g. send to supporting FaaS, save to disk)

PROTIP: Functions should not reference anything outside their lexical scope.

Function deserialization:

const {deserialize, serialize} = require('cardigan');

const add = serialize((a, b) => a + b);
const subtract = serialize((a, b) => a - b);

const add2And3 = deserialize(add)(2, 3); // 5
const subtract3And2 = deserialize(subtract)(3, 2); // 1

Supported Function Types

Function expressions:

function (a) { ... }

Async function expressions:

async function (a) { ... }

Unary arrow functions:

a => { ... }

Async unary arrow functions:

async a => { ... }

Polyadic arrow functions:

(a, b) => { ... }

Async polyadic arrow functions:

async (a, b) => { ... }

Maintainers

Keywords

deserialize

FAQs

Package last updated on 27 Jan 2017

Related posts