BVB Source Codes

prettier Show request.js Source code

Return Download prettier: download request.js Source code - Download prettier Source code - Type:.js
  1. /* @flow */
  2. const a: Request = new Request(); // incorrect
  3. const b: Request = new Request('http://example.org'); // correct
  4. const c: Request = new Request(b); // correct
  5. const d: Request = new Request(c.clone()); // correct (doesn't make much sense though)
  6. const e: Request = new Request(b, c); // incorrect
  7.  
  8. const f: Request = new Request({}) // incorrect
  9. const g: Request = new Request('http://example.org', {}) // correct
  10. new Request(new URL('http://example.org')); // correct
  11.  
  12. const h: Request = new Request('http://example.org', {
  13.   method: 'GET',
  14.   headers: {
  15.     'Content-Type': 'image/jpeg'
  16.   },
  17.   mode: 'cors',
  18.   cache: 'default'
  19. }) // correct
  20.  
  21. var bodyUsed: boolean = h.bodyUsed;
  22.  
  23. h.text().then((t: string) => t); // correct
  24. h.text().then((t: Buffer) => t); // incorrect
  25. h.arrayBuffer().then((ab: ArrayBuffer) => ab); // correct
  26. h.arrayBuffer().then((ab: Buffer) => ab); // incorrect
  27.  
  28. const i: Request = new Request('http://example.org', {
  29.   method: 'POST',
  30.   headers: {
  31.     'Content-Type': 'application/octet-stream'
  32.   },
  33.   body: new ArrayBuffer(10),
  34. }); // correct
  35.  
  36. const j: Request = new Request('http://example.org', {
  37.   method: 'POST',
  38.   headers: {
  39.     'Content-Type': 'application/octet-stream'
  40.   },
  41.   body: new Uint8Array(10),
  42. }); // correct
  43.  
  44. const k: Request = new Request('http://example.org', {
  45.   method: 'POST',
  46.   headers: {
  47.     'Content-Type': 'image/jpeg'
  48.   },
  49.   body: new URLSearchParams("key=value"),
  50.   mode: 'cors',
  51.   cache: 'default'
  52. }) // correct
  53.  
  54. const l: Request = new Request('http://example.org', {
  55.   method: 'GET',
  56.   headers: 'Content-Type: image/jpeg',
  57.   mode: 'cors',
  58.   cache: 'default'
  59. }) // incorrect - headers is string
  60.  
  61. new Request('/', { method: 'post' }); // correct
  62. new Request('/', { method: 'hello' }); // correct
  63. new Request('/', { method: null }); // incorrect
  64.  
downloadrequest.js Source code - Download prettier Source code
Related Source Codes/Software:
storybook - 2017-06-07
ionicons - The premium icon font for Ionic ... 2017-06-07
AsyncDisplayKit - Smooth asynchronous user interfaces for iOS apps. ... 2017-06-07
lottie-android - Render After Effects animations natively on Androi... 2017-06-07
parse-server - Parse-compatible API server module for Node/Expres... 2017-06-07
inferno - An extremely fast, React-like JavaScript library f... 2017-06-08
guetzli - Perceptual JPEG encoder 2017-06-08
cs-video-courses - List of Computer Science courses with video lectur... 2017-06-08
interviews - Everything you need to know to get the job. 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top