File shim now translates correctly

This commit is contained in:
d98762625 2019-03-14 16:33:09 +00:00
parent d080c5dd14
commit 2019ae43d7
7 changed files with 14 additions and 28 deletions

View file

@ -19,21 +19,21 @@ class File {
/**
* Constructor
*
* https://w3c.github.io/FileAPI/#file-constructor
*
* @param {String|Array|ArrayBuffer|Buffer} bits - file content
* @param {String} name (optional) - file name
* @param {Object} stats (optional) - file stats e.g. lastModified
*/
constructor(data, name="", stats={}) {
// Look at File API definition to see how to handle this.
this.data = Buffer.from(data[0]);
const buffers = data.map(d => Buffer.from(d));
const totalLength = buffers.reduce((p, c) => p + c.length, 0);
this.data = Buffer.concat(buffers, totalLength);
this.name = name;
this.lastModified = stats.lastModified || Date.now();
this.type = stats.type || mime.getType(this.name);
console.log('File constructor');
console.log(typeof data);
console.log(data);
console.log(this.data);
}
/**