An utility library for Stitch It runtime that provides bunch of conversion functions.
Usage
Either import individual functions:
import { convertTextToBase64 } from '@stitch-it/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 '@stitch-it/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');