UNPKG

@skyware/labeler

Version:

A lightweight alternative to Ozone for operating an atproto labeler.

15 lines (14 loc) 483 B
import { encode as cborEncode } from "@atcute/cbor"; import { concat as ui8Concat } from "uint8arrays"; export function excludeNullish(obj) { return Object.entries(obj).reduce((acc, [key, value]) => { if (value != null) { acc[key] = value; } return acc; }, {}); } export function frameToBytes(type, body, t) { const header = type === "error" ? { op: -1 } : { op: 1, t }; return ui8Concat([cborEncode(header), cborEncode(body)]); }