├── .gitignore ├── .npmignore ├── test └── basic.js ├── .github ├── dependabot.yml └── workflows │ └── ci.yml ├── buffer.js ├── LICENSE ├── example └── index.html ├── package.json ├── README.md └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | example/drag-drop.js 2 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .github/ 2 | example/ 3 | test/ 4 | -------------------------------------------------------------------------------- /test/basic.js: -------------------------------------------------------------------------------- 1 | const test = require('tape') 2 | 3 | // writing tests for this would be hard, so let's just check that requiring the module 4 | // doesn't throw 5 | 6 | test('requiring drag-drop does not throw', t => { 7 | t.doesNotThrow(() => { 8 | require('../') 9 | }) 10 | t.end() 11 | }) 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: / 5 | schedule: 6 | interval: daily 7 | labels: 8 | - dependency 9 | versioning-strategy: increase-if-necessary 10 | - package-ecosystem: github-actions 11 | directory: / 12 | schedule: 13 | interval: daily 14 | labels: 15 | - dependency 16 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 'on': 3 | - push 4 | - pull_request 5 | jobs: 6 | test: 7 | name: Node ${{ matrix.node }} / ${{ matrix.os }} 8 | runs-on: ${{ matrix.os }} 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | os: 13 | - ubuntu-latest 14 | node: 15 | - '14' 16 | steps: 17 | - uses: actions/checkout@v2 18 | - uses: actions/setup-node@v2 19 | with: 20 | node-version: ${{ matrix.node }} 21 | - run: npm install 22 | - run: npm run build --if-present 23 | - run: npm test 24 | -------------------------------------------------------------------------------- /buffer.js: -------------------------------------------------------------------------------- 1 | module.exports = dragDropAsBuffer 2 | 3 | const dragDrop = require('./') 4 | const parallel = require('run-parallel') 5 | const blobToBuffer = require('blob-to-buffer') 6 | 7 | function dragDropAsBuffer (elem, cb) { 8 | return dragDrop(elem, function (files, pos, fileList) { 9 | const tasks = files.map(function (file) { 10 | return function (cb) { 11 | blobToBuffer(file, function (err, buffer) { 12 | if (err) return cb(err) 13 | buffer.name = file.name 14 | buffer.fullPath = file.fullPath 15 | buffer.size = file.size 16 | buffer.type = file.type 17 | buffer.lastModifiedDate = file.lastModifiedDate 18 | cb(null, buffer) 19 | }) 20 | } 21 | }) 22 | parallel(tasks, function (err, results) { 23 | if (err) throw err 24 | cb(results, pos, fileList) 25 | }) 26 | }) 27 | } 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Feross Aboukhadijeh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /example/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |