Нет описания

json-stream.js 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import Oboe from './lib/oboe-browser.min.js'
  2. import XMLHttpRequest from './polyfill/XMLHttpRequest'
  3. import URIUtil from './utils/uri'
  4. const OboeExtended = (arg: string | Object) => {
  5. window.location = ''
  6. if(!window.XMLHttpRequest.isRNFBPolyfill ) {
  7. window.XMLHttpRequest = XMLHttpRequest
  8. console.warn(
  9. 'Use JSONStream will automatically replace window.XMLHttpRequest with RNFetchBlob.polyfill.XMLHttpRequest. ' +
  10. 'You are seeing this warning because you did not replace it manually.'
  11. )
  12. }
  13. if(typeof arg === 'string') {
  14. if(URIUtil.isFileURI(arg)) {
  15. arg = {
  16. url : 'JSONStream://' + arg,
  17. headers : { noCache : true }
  18. }
  19. }
  20. else
  21. arg = 'JSONStream://' + arg
  22. }
  23. else if(typeof arg === 'object') {
  24. let headers = arg.headers || {}
  25. if(URIUtil.isFileURI(arg.url)) {
  26. headers.noCache = true
  27. }
  28. arg = Object.assign(arg, {
  29. url : 'JSONStream://' + arg.url,
  30. headers
  31. })
  32. }
  33. return Oboe(arg)
  34. }
  35. export default OboeExtended