blob: dd221844f24ab9687fb19ac2ef626d10cf1ff6bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
async function timeout (cmd) {
const timer = new Promise((resolve, reject) => {
const id = setTimeout(() => {
clearTimeout(id)
reject(new Error('Promise timed out!'))
}, 750)
})
return Promise.race([cmd, timer])
}
(async () => {
const root = await navigator.storage.getDirectory()
const blob = new Blob(['A'])
const sub = await root.getDirectoryHandle('a', { 'create': true })
const file = await root.getFileHandle('b', { 'create': true })
await file.move(sub)
const stream = await file.createWritable({})
await stream.write(blob)
const sub2 = await root.getDirectoryHandle('a', {})
await sub2.move(root, 'X')
})()
|