forked from feross/drag-drop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuffer.js
More file actions
26 lines (24 loc) · 701 Bytes
/
Copy pathbuffer.js
File metadata and controls
26 lines (24 loc) · 701 Bytes
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
module.exports = DragDropAsBuffer
var dragDrop = require('./')
var parallel = require('run-parallel')
var toBuffer = require('blob-to-buffer')
function DragDropAsBuffer (elem, cb) {
dragDrop(elem, function (files, pos) {
var tasks = files.map(function (file) {
return function (cb) {
toBuffer(file, function (err, buffer) {
if (err) return cb(err)
buffer.name = file.name
buffer.size = file.size
buffer.type = file.type
buffer.lastModifiedDate = file.lastModifiedDate
cb(null, buffer)
})
}
})
parallel(tasks, function (err, results) {
if (err) throw err
cb(results, pos)
})
})
}