appwrite
Version:
Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API
27 lines (21 loc) • 691 B
text/typescript
import { Client } from './client';
import type { Payload } from './client';
export class Service {
static CHUNK_SIZE = 5*1024*1024; // 5MB
client: Client;
constructor(client: Client) {
this.client = client;
}
static flatten(data: Payload, prefix = ''): Payload {
let output: Payload = {};
for (const [key, value] of Object.entries(data)) {
let finalKey = prefix ? prefix + '[' + key +']' : key;
if (Array.isArray(value)) {
output = { ...output, ...Service.flatten(value, finalKey) };
} else {
output[finalKey] = value;
}
}
return output;
}
}