Don't export default objects / namespaces

Import individual functions, instead.
This commit is contained in:
Daniel Huigens
2020-06-26 19:46:06 +02:00
parent f276e1ef51
commit b3e08fdc26
40 changed files with 1746 additions and 1845 deletions

View File

@@ -25,7 +25,7 @@
*/
import stream from 'web-stream-tools';
import base64 from './base64.js';
import * as base64 from './base64.js';
import enums from '../enums.js';
import config from '../config';
import util from '../util';
@@ -233,7 +233,7 @@ function splitChecksum(text) {
* @async
* @static
*/
function dearmor(input) {
export function unarmor(input) {
return new Promise(async (resolve, reject) => {
try {
const reSplit = /^-----[^-]+-----$/m;
@@ -359,7 +359,7 @@ function dearmor(input) {
* @returns {String | ReadableStream<String>} Armored text
* @static
*/
function armor(messagetype, body, partindex, parttotal, customComment) {
export function armor(messagetype, body, partindex, parttotal, customComment) {
let text;
let hash;
if (messagetype === enums.armor.signed) {
@@ -426,8 +426,3 @@ function armor(messagetype, body, partindex, parttotal, customComment) {
return util.concat(result);
}
export default {
encode: armor,
decode: dearmor
};

View File

@@ -41,7 +41,7 @@ if (Buffer) {
* @returns {String | ReadableStream<String>} radix-64 version of input string
* @static
*/
function encode(data) {
export function encode(data) {
let buf = new Uint8Array();
return stream.transform(data, value => {
buf = util.concatUint8Array([buf, value]);
@@ -65,7 +65,7 @@ function encode(data) {
* @returns {Uint8Array | ReadableStream<Uint8Array>} binary array version of input string
* @static
*/
function decode(data) {
export function decode(data) {
let buf = '';
return stream.transform(data, value => {
buf += value;
@@ -92,5 +92,3 @@ function decode(data) {
return decoded;
}, () => decodeChunk(buf));
}
export default { encode, decode };