-4

The following code is written with ES6: How do I convert to pre ES6 so that its compatible with IE. I tried to following; see second code snipet below

FilePond.create(document.querySelector('input'), {
    acceptedFileTypes: ['image/png'],
    fileValidateTypeDetectType: (source, type) => new Promise((resolve, reject) => {

        // Do custom type detection here and return with promise

        resolve(type);
    })
});


i tried the following 

FilePond.create(imageInputElement, {
            acceptedFileTypes: ['image/png', 'image/x-png', 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/tiff', 'application/pdf'],
            fileValidateTypeDetectType: function (source, type) {
                                            return resolveFileType(resolve, reject);
                                        }
    })

async function resolveFileType(resolve, reject){
            const response = await resolve(type);
            return response;
        }
Andra Avram
  • 75
  • 1
  • 8

1 Answers1

0

You can use the online transpiler for babel or if you work in a complete project

with ES6 so use task runner that will help you like [webpack, gulp]

or just fix your promises use a third party like BlueBird it uses to polyfill

promises in old browsers

<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js"></script>
Joseph
  • 5,644
  • 3
  • 18
  • 44
  • hmm i tried it thanks a lot! but it still uses a Promise which is not supported by IE – Andra Avram Jan 28 '20 at 21:11
  • there is a third party called `bluebird` it use to polyfill the promises [link](http://bluebirdjs.com/docs/getting-started.html) – Joseph Jan 28 '20 at 21:13