-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpolyfill.js
More file actions
73 lines (62 loc) · 1.6 KB
/
Copy pathpolyfill.js
File metadata and controls
73 lines (62 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
if (typeof globalThis.File === 'undefined') {
globalThis.File = class File {
constructor(chunks, filename, options = {}) {
this.name = filename;
this.size = 0;
this.type = options.type || '';
this.lastModified = options.lastModified || Date.now();
this.webkitRelativePath = '';
if (Array.isArray(chunks)) {
this.size = chunks.reduce((acc, chunk) => acc + (chunk.length || 0), 0);
}
}
slice(start, end, contentType) {
return new File([], this.name, {
type: contentType || this.type,
lastModified: this.lastModified
});
}
stream() {
return new ReadableStream({
start(controller) {
controller.close();
}
});
}
text() {
return Promise.resolve('');
}
arrayBuffer() {
return Promise.resolve(new ArrayBuffer(0));
}
};
}
if (typeof globalThis.Blob === 'undefined') {
globalThis.Blob = class Blob {
constructor(chunks = [], options = {}) {
this.size = 0;
this.type = options.type || '';
if (Array.isArray(chunks)) {
this.size = chunks.reduce((acc, chunk) => acc + (chunk.length || 0), 0);
}
}
slice(start, end, contentType) {
return new Blob([], {
type: contentType || this.type
});
}
stream() {
return new ReadableStream({
start(controller) {
controller.close();
}
});
}
text() {
return Promise.resolve('');
}
arrayBuffer() {
return Promise.resolve(new ArrayBuffer(0));
}
};
}