Function
buildCode
(
fn: (...args: T) => void,
args: T,
)
Source from the content-addressed store, hash-verified
| 46 | } |
| 47 | |
| 48 | export function buildCode<T extends unknown[]>( |
| 49 | fn: (...args: T) => void, |
| 50 | args: T, |
| 51 | ): string { |
| 52 | const params = args |
| 53 | .map((arg) => { |
| 54 | if (typeof arg === 'function') return arg.toString(); |
| 55 | return JSON.stringify(arg ?? null); |
| 56 | }) |
| 57 | .join(','); |
| 58 | return `(${fn.toString()})(${params})`; |
| 59 | } |
| 60 | |
| 61 | export function persistJS(items: JSItem[], context?: unknown): string[] { |
| 62 | return items.map((item) => { |
Tested by
no test coverage detected