@sr-connect/convert
v1.1.0
Published
ScriptRunner Connect utility library for various data conversions
Downloads
7
Keywords
Readme
An utility library for ScriptRunner Connect runtime that provides bunch of conversion functions.
Usage
Either import individual functions:
import { convertTextToBase64 } from '@sr-connect/convert';
export default async function(event: any, context: Context): Promise<void> {
console.log(convertTextToBase64('HELLO WORLD', 'utf8'));
}
or import the entire namespace:
import { Convert } from '@sr-connect/convert';
export default async function(event: any, context: Context): Promise<void> {
console.log(Convert.textToBase64('HELLO WORLD', 'utf8'));
}
Available functions
convertBase64ToBuffer(base64: string): UInt8Array;
convertBase64ToText(base64: string, encoding?: string = 'utf8'): string;
convertBufferToBase64(buffer: ArrayBuffer): string;
convertBufferToText(buffer: ArrayBuffer, encoding?: string = 'utf8'): string;
convertTextToBase64(text: string, encoding?: string = 'utf8'): string;
convertTextToBuffer(text: string, encoding?: string = 'utf8'): UInt8Array;
convertTextToText(text: string, sourceEncoding: string, targetEncoding?: string = 'utf8');
convertArrayBufferToFormDataBuffer(...chunks: chunks): BufferedFormData;
Changelog
1.1.0
- Added
convertArrayBufferToFormDataBuffer
(orConvert.arrayBufferToFormDataBuffer
) function that allows to convert form data into encoded array buffer more efficiently than usingFormData
andBlob
classes together.