Don't mutate prototypes of Uint8Array, ReadableStream and ReadableStreamDefaultWriter

This commit is contained in:
Daniel Huigens
2018-05-15 18:56:25 +02:00
parent 70f0e1d2f5
commit 4ada3fa590
13 changed files with 145 additions and 121 deletions

View File

@@ -19,6 +19,7 @@
* @requires encoding/base64
* @requires enums
* @requires config
* @requires stream
* @requires util
* @module encoding/armor
*/
@@ -26,6 +27,7 @@
import base64 from './base64.js';
import enums from '../enums.js';
import config from '../config';
import stream from '../stream';
import util from '../util';
/**
@@ -166,7 +168,7 @@ const crc_table = [
function createcrc24(input) {
let crc = 0xB704CE;
return input.transform((done, value) => {
return stream.transform(input, (done, value) => {
if (!done) {
for (let index = 0; index < value.length; index++) {
crc = (crc << 8) ^ crc_table[((crc >> 16) ^ value[index]) & 0xff];
@@ -311,7 +313,7 @@ function armor(messagetype, body, partindex, parttotal, customComment) {
body = body.data;
}
let bodyClone;
[body, bodyClone] = body.tee();
[body, bodyClone] = stream.tee(body);
const result = [];
switch (messagetype) {
case enums.armor.multipart_section:

View File

@@ -12,10 +12,12 @@
*/
/**
* @requires stream
* @requires util
* @module encoding/base64
*/
import stream from '../stream';
import util from '../util';
const b64s = util.str_to_Uint8Array('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'); // Standard radix-64
@@ -37,7 +39,7 @@ function s2r(t, u = false) {
let l = 0;
let s = 0;
return t.transform((done, value) => {
return stream.transform(t, (done, value) => {
const r = [];
if (!done) {
@@ -106,7 +108,7 @@ function r2s(t, u) {
let s = 0;
let a = 0;
return t.transform((done, value) => {
return stream.transform(t, (done, value) => {
if (!done) {
const r = [];
const tl = value.length;