@sr-connect/convert
v1.2.0
Published
ScriptRunner Connect utility library for various data conversions
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.2.0
- Introduced
fastTransfermode forconvertBufferToTextandconvertBufferToBase64functions. This option is only functional in runtime V2 and up. When enabled, ArrayBuffer will be transferred instead of being copied, which makes it faster, but as a result the ArrayBuffer will become invalidated (can no longer be read or edited).
Changelog
1.1.1
- Internal
package.jsonfix, no functional changes were introduced with this update.
1.1.0
- Added
convertArrayBufferToFormDataBuffer(orConvert.arrayBufferToFormDataBuffer) function that allows to convert form data into encoded array buffer more efficiently than usingFormDataandBlobclasses together.
