2018-06-13 22:39:39 +03:00
|
|
|
'use strict';
|
|
|
|
|
2018-07-16 10:27:49 +03:00
|
|
|
import { arrayify } from './bytes';
|
|
|
|
|
2018-07-31 01:59:52 +03:00
|
|
|
///////////////////////////////
|
|
|
|
// Imported Types
|
2018-06-13 22:39:39 +03:00
|
|
|
|
2018-07-31 01:59:52 +03:00
|
|
|
import { Arrayish } from './bytes';
|
|
|
|
|
|
|
|
///////////////////////////////
|
|
|
|
/*
|
2018-06-13 22:39:39 +03:00
|
|
|
declare class Buffer implements ArrayLike<number> {
|
|
|
|
constructor(data: any, encoding?: string);
|
|
|
|
toString(encoding?: string): any;
|
|
|
|
[key: number]: number;
|
|
|
|
length: number;
|
|
|
|
}
|
2018-07-31 01:59:52 +03:00
|
|
|
*/
|
2018-06-13 22:39:39 +03:00
|
|
|
export function decode(textData: string): Uint8Array {
|
2018-09-04 17:20:31 +03:00
|
|
|
return arrayify(new Uint8Array(Buffer.from(textData, 'base64')));
|
2018-06-13 22:39:39 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export function encode(data: Arrayish): string {
|
2018-09-04 17:20:31 +03:00
|
|
|
return Buffer.from(arrayify(data)).toString('base64');
|
2018-06-13 22:39:39 +03:00
|
|
|
}
|