react-native-deepgram
Version:
React Native SDK for Deepgram's AI-powered speech-to-text, real-time transcription, and text intelligence APIs. Supports live audio streaming, file transcription, sentiment analysis, and topic detection for iOS and Android.
27 lines (23 loc) • 827 B
text/typescript
export function buildParams(
map: Record<string, string | boolean | string[] | undefined | number>
): string {
const p = new URLSearchParams();
Object.entries(map).forEach(([key, value]) => {
if (value == null) return; // skip undefined/null
if (Array.isArray(value)) {
// multiple values
value.forEach((v) => p.append(key, v));
} else if (typeof value === 'boolean') {
if (value) p.append(key, 'true'); // only include true flags
} else {
if (typeof value === 'number') {
p.append(key, String(value)); // convert number to string
} else {
p.append(key, value); // plain string
}
}
});
return p.toString();
}
export const dgPath = (...segments: Array<string | number>) =>
'/' + segments.map((s) => encodeURIComponent(String(s))).join('/');