Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { valPartMaxLength } from "https://esm.town/v/stevekrouse/valPartMaxLength";
// Utility for saving a reasonable truncated version of a val
// for when vals are too big to save in their entirety
// usage: @stevekrouse.exampleTruncatedVal
export let truncateVal = async (data: any) => {
const { jsonrepair } = await import("npm:jsonrepair");
return JSON.parse(
jsonrepair(
JSON.stringify(await data).substring(
0,
valPartMaxLength,
),
),
);
};
October 23, 2023