data-synchronizer
Version:
A versatile library for transferring data across multi-page applications or single page applications.
16 lines (13 loc) • 343 B
text/typescript
const $type = 'function'
const to = (value: Function) => {
return [
$type,
value.toString(),
]
}
const from = (value: string) => {
const funcBody = value.startsWith('function') ? value: 'function ' + value;
const func = new Function(`return ${funcBody}`);
return func();
}
export default [$type, from, to];