MCPcopy
hub / github.com/jpillora/xdomain / convertToArrayBuffer

Function convertToArrayBuffer

src/lib/master.js:97–116  ·  view source on GitHub ↗
(args, done)

Source from the content-addressed store, hash-verified

95};
96
97const convertToArrayBuffer = function(args, done) {
98 const [name, obj] = Array.from(args);
99 const isBlob = instOf(obj, "Blob");
100 const isFile = instOf(obj, "File");
101 if (!isBlob && !isFile) {
102 return 0;
103 }
104 const reader = new FileReader();
105 reader.onload = function() {
106 // clear value
107 args[1] = null;
108 // formdata.append(name, value, **filename**)
109 if (isFile) {
110 args[2] = obj.name;
111 }
112 return done(["XD_BLOB", args, this.result, obj.type]);
113 };
114 reader.readAsArrayBuffer(obj);
115 return 1;
116};
117
118//this FormData is actually XHooks custom FormData `fd`,
119//which exposes all `entries` added, where each entry

Callers 2

bundle.jsFile · 0.85
convertFormDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected