Skip to content

Commit

Permalink
Found a couple of remaining references to Buffer and removed them; sm…
Browse files Browse the repository at this point in the history
…aller compiled files
  • Loading branch information
calebsander committed Aug 10, 2016
1 parent 433b4cc commit e8a7b8b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
6 changes: 3 additions & 3 deletions client-side/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
(() => {
require('/client-side/common.js');
const assert = require('/lib/assert.js');
const base64 = require('base64-js');
const r = require('/read.js');
const BASE_64 = 'base64';
const typeCache = {};
function saveTypeCache() {
const composedCache = {};
for (let type in typeCache) {
composedCache[type] = {
sig: typeCache[type].sig,
type: typeCache[type].type.toBuffer().toString(BASE_64)
type: base64.fromByteArray(new Uint8Array(typeCache[type].type.toBuffer()))
};
}
localStorage.typeCache = JSON.stringify(composedCache);
Expand All @@ -21,7 +21,7 @@
for (let typeName in composedCache) {
typeCache[typeName] = {
sig: composedCache[typeName].sig,
type: r.type(Buffer.from(composedCache[typeName].type, BASE_64))
type: r.type(new Uint8Array(base64.toByteArray(composedCache[typeName].type)).buffer)
};
}
}
Expand Down
5 changes: 2 additions & 3 deletions compiled/download.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions compiled/upload-download.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiled/upload.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
if (__dirname === '/') __dirname = '';

const assert = require(__dirname + '/lib/assert.js');
const base64 = require('base64-js');

const VERSION = 7;
assert.between(0, VERSION, 65536);
const VERSION_BYTES = 2;
const VERSION_BUFFER = Buffer.allocUnsafe(VERSION_BYTES);
VERSION_BUFFER.writeUInt16BE(VERSION, 0);
const VERSION_STRING = VERSION_BUFFER.toString('base64');
const VERSION_BUFFER = new ArrayBuffer(VERSION_BYTES);
new DataView(VERSION_BUFFER).setUint16(0, VERSION);
const VERSION_STRING = base64.fromByteArray(new Uint8Array(VERSION_BUFFER));

module.exports = {
VERSION_STRING
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "structure-bytes",
"version": "2.7.7",
"version": "2.8.7",
"description": "Efficiently stores data of any shape by separating it into structure and value",
"main": "index.js",
"dependencies": {
Expand Down

0 comments on commit e8a7b8b

Please sign in to comment.