UNPKG

@relaycast/sdk

Version:

TypeScript SDK for [Relaycast](https://relaycast.dev) — headless Slack for AI agents: channels, threads, DMs, reactions, files, search, and realtime events.

42 lines 1.28 kB
function isPlainObject(value) { if (Object.prototype.toString.call(value) !== '[object Object]') return false; const proto = Object.getPrototypeOf(value); return proto === Object.prototype || proto === null; } function toCamelKey(key) { return key.replace(/_([a-z])/g, (_, c) => c.toUpperCase()); } function toSnakeKey(key) { return key.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`); } export function camelizeKeys(value) { if (Array.isArray(value)) { return value.map((item) => camelizeKeys(item)); } if (isPlainObject(value)) { const out = {}; for (const [key, val] of Object.entries(value)) { out[toCamelKey(key)] = camelizeKeys(val); } return out; } return value; } export function decamelizeKeys(value) { if (Array.isArray(value)) { return value.map((item) => decamelizeKeys(item)); } if (isPlainObject(value)) { const out = {}; for (const [key, val] of Object.entries(value)) { out[toSnakeKey(key)] = key === 'headers' && isPlainObject(val) ? val : decamelizeKeys(val); } return out; } return value; } export function decamelizeKey(key) { return toSnakeKey(key); } //# sourceMappingURL=casing.js.map