main page
This commit is contained in:
commit
7fb446c53a
8943 files changed
+1209030
No files matched your search
+30
@@ -0,0 +1,30 @@
|
||||
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 in data) {
|
||||
let value = data[key];
|
||||
let finalKey = prefix ? `${prefix}[${key}]` : key;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
output = Object.assign(output, this.flatten(value, finalKey));
|
||||
}
|
||||
else {
|
||||
output[finalKey] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user