feat: added form data function

This commit is contained in:
원더 2021-01-27 16:46:54 +09:00
parent c8ae254c33
commit 19a6bd8826

View File

@ -54,7 +54,18 @@ export function generateOauthURL(provider: 'discord', clientID: string, scope: s
return Oauth[provider](clientID, scope)
}
export default function bufferToStream(binary: Buffer) {
export function formData(details: { [key: string]: string | number | boolean }) {
const formBody = []
for (const property in details) {
const encodedKey = encodeURIComponent(property)
const encodedValue = encodeURIComponent(details[property])
formBody.push(encodedKey + '=' + encodedValue)
}
return formBody.join('&')
}
export function bufferToStream(binary: Buffer) {
const readableInstanceStream = new Readable({
read() {
@ -66,5 +77,4 @@ export default function bufferToStream(binary: Buffer) {
return readableInstanceStream
}
export { anchorHeader } from './ShowdownExtensions'