Skip to content

Remove polyfills #357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions components/Fetch.onPress.js

This file was deleted.

15 changes: 0 additions & 15 deletions components/Fetch.when.js

This file was deleted.

16 changes: 3 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import URIUtil from './utils/uri'
import fs from './fs'
import getUUID from './utils/uuid'
import base64 from 'base-64'
import polyfill from './polyfill'
import _ from 'lodash'
import android from './android'
import ios from './ios'
Expand All @@ -42,7 +41,6 @@ const {
cp
} = fs

const Blob = polyfill.Blob
const emitter = DeviceEventEmitter
const RNFetchBlob = NativeModules.RNFetchBlob

Expand Down Expand Up @@ -264,12 +262,6 @@ function fetch(...args:any):Promise {
}
})

// When the request body comes from Blob polyfill, we should use special its ref
// as the request body
if( body instanceof Blob && body.isRNFetchBlobPolyfill) {
body = body.getRNFetchBlobRef()
}

let req = RNFetchBlob[nativeMethodName]

/**
Expand Down Expand Up @@ -431,18 +423,17 @@ class FetchBlobResponse {
* @return {Promise<Blob>} Return a promise resolves Blob object.
*/
this.blob = ():Promise<Blob> => {
let Blob = polyfill.Blob
let cType = info.headers['Content-Type'] || info.headers['content-type']
return new Promise((resolve, reject) => {
switch(this.type) {
case 'base64':
Blob.build(this.data, { type : cType + ';BASE64' }).then(resolve)
resolve(new Blob([this.data], { type : cType + ';BASE64' }))
break
case 'path':
polyfill.Blob.build(wrap(this.data), { type : cType }).then(resolve)
resolve(new Blob([wrap(this.data)], { type : cType }))
break
default:
polyfill.Blob.build(this.data, { type : 'text/plain' }).then(resolve)
resolve(new Blob([this.data], { type : 'text/plain' }))
break
}
})
Expand Down Expand Up @@ -561,6 +552,5 @@ export default {
session,
fs,
wrap,
polyfill,
JSONStream
}
11 changes: 1 addition & 10 deletions json-stream.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import Oboe from './lib/oboe-browser.min.js'
import XMLHttpRequest from './polyfill/XMLHttpRequest'
import Oboe from 'oboe'
import URIUtil from './utils/uri'

const OboeExtended = (arg: string | Object) => {


window.location = ''

if(!window.XMLHttpRequest.isRNFBPolyfill ) {
window.XMLHttpRequest = XMLHttpRequest
console.warn(
'Use JSONStream will automatically replace window.XMLHttpRequest with RNFetchBlob.polyfill.XMLHttpRequest. ' +
'You are seeing this warning because you did not replace it manually.'
)
}

if(typeof arg === 'string') {
if(URIUtil.isFileURI(arg)) {
arg = {
Expand Down
Loading