Нет описания

json-stream.js 1004B

12345678910111213141516171819202122232425262728293031323334353637383940
  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('Use JSONStream will automatically replace window.XMLHttpRequest with RNFetchBlob.polyfill.XMLHttpRequest. You are seeing this warning because you did not replace it maually.')
  9. }
  10. if(typeof arg === 'string') {
  11. if(URIUtil.isFileURI(arg)) {
  12. arg = {
  13. url : 'JSONStream://' + arg,
  14. headers : { noCache : true }
  15. }
  16. }
  17. else
  18. arg = 'JSONStream://' + arg
  19. }
  20. else if(typeof arg === 'object') {
  21. let headers = arg.headers || {}
  22. if(URIUtil.isFileURI(arg.url)) {
  23. headers.noCache = true
  24. }
  25. arg = Object.assign(arg, {
  26. url : 'JSONStream://' + arg.url,
  27. headers
  28. })
  29. }
  30. return Oboe(arg)
  31. }
  32. export default OboeExtended