From cd034d030b2317898ce8d5e10cbf6ff643a438a8 Mon Sep 17 00:00:00 2001 From: Jon Ursenbach Date: Fri, 7 Aug 2020 12:22:41 -0700 Subject: [PATCH] feat: updating javascript targets to use `const` instead of `var` --- src/targets/javascript/fetch.js | 2 +- src/targets/javascript/jquery.js | 4 ++-- src/targets/javascript/xhr.js | 8 ++++---- src/targets/node/native.js | 12 ++++++------ src/targets/node/request.js | 10 +++++----- src/targets/node/unirest.js | 19 +++++++++++-------- .../output/javascript/fetch/multipart-data.js | 2 +- .../output/javascript/fetch/multipart-file.js | 2 +- .../javascript/fetch/multipart-form-data.js | 2 +- .../jquery/application-form-encoded.js | 4 ++-- .../javascript/jquery/application-json.js | 4 ++-- .../output/javascript/jquery/cookies.js | 4 ++-- .../output/javascript/jquery/custom-method.js | 4 ++-- .../fixtures/output/javascript/jquery/full.js | 4 ++-- .../output/javascript/jquery/headers.js | 4 ++-- .../output/javascript/jquery/https.js | 4 ++-- .../javascript/jquery/jsonObj-multiline.js | 4 ++-- .../javascript/jquery/jsonObj-null-value.js | 4 ++-- .../javascript/jquery/multipart-data.js | 6 +++--- .../javascript/jquery/multipart-file.js | 6 +++--- .../javascript/jquery/multipart-form-data.js | 6 +++--- .../output/javascript/jquery/query.js | 4 ++-- .../output/javascript/jquery/short.js | 4 ++-- .../output/javascript/jquery/text-plain.js | 4 ++-- .../xhr/application-form-encoded.js | 4 ++-- .../output/javascript/xhr/application-json.js | 4 ++-- .../fixtures/output/javascript/xhr/cookies.js | 4 ++-- .../output/javascript/xhr/custom-method.js | 4 ++-- test/fixtures/output/javascript/xhr/full.js | 4 ++-- .../fixtures/output/javascript/xhr/headers.js | 4 ++-- test/fixtures/output/javascript/xhr/https.js | 4 ++-- .../javascript/xhr/jsonObj-multiline.js | 4 ++-- .../javascript/xhr/jsonObj-null-value.js | 4 ++-- .../output/javascript/xhr/multipart-data.js | 4 ++-- .../output/javascript/xhr/multipart-file.js | 4 ++-- .../javascript/xhr/multipart-form-data.js | 4 ++-- test/fixtures/output/javascript/xhr/query.js | 4 ++-- test/fixtures/output/javascript/xhr/short.js | 4 ++-- .../output/javascript/xhr/text-plain.js | 4 ++-- .../node/native/application-form-encoded.js | 12 ++++++------ .../output/node/native/application-json.js | 10 +++++----- test/fixtures/output/node/native/cookies.js | 10 +++++----- .../output/node/native/custom-method.js | 10 +++++----- test/fixtures/output/node/native/full.js | 12 ++++++------ test/fixtures/output/node/native/headers.js | 10 +++++----- test/fixtures/output/node/native/https.js | 10 +++++----- .../output/node/native/jsonObj-multiline.js | 10 +++++----- .../output/node/native/jsonObj-null-value.js | 10 +++++----- .../output/node/native/multipart-data.js | 10 +++++----- .../output/node/native/multipart-file.js | 10 +++++----- .../output/node/native/multipart-form-data.js | 10 +++++----- test/fixtures/output/node/native/query.js | 10 +++++----- test/fixtures/output/node/native/short.js | 10 +++++----- .../fixtures/output/node/native/text-plain.js | 10 +++++----- .../node/request/application-form-encoded.js | 4 ++-- .../output/node/request/application-json.js | 4 ++-- test/fixtures/output/node/request/cookies.js | 10 +++++----- .../output/node/request/custom-method.js | 4 ++-- test/fixtures/output/node/request/full.js | 10 +++++----- test/fixtures/output/node/request/headers.js | 4 ++-- test/fixtures/output/node/request/https.js | 4 ++-- .../output/node/request/jsonObj-multiline.js | 4 ++-- .../output/node/request/jsonObj-null-value.js | 4 ++-- .../output/node/request/multipart-data.js | 4 ++-- .../output/node/request/multipart-file.js | 12 ++++++------ .../node/request/multipart-form-data.js | 4 ++-- test/fixtures/output/node/request/query.js | 4 ++-- test/fixtures/output/node/request/short.js | 4 ++-- .../output/node/request/text-plain.js | 4 ++-- .../node/unirest/application-form-encoded.js | 4 ++-- .../output/node/unirest/application-json.js | 4 ++-- test/fixtures/output/node/unirest/cookies.js | 7 +++---- .../output/node/unirest/custom-method.js | 5 ++--- test/fixtures/output/node/unirest/full.js | 6 +++--- test/fixtures/output/node/unirest/headers.js | 5 ++--- test/fixtures/output/node/unirest/https.js | 5 ++--- .../output/node/unirest/jsonObj-multiline.js | 4 ++-- .../output/node/unirest/jsonObj-null-value.js | 4 ++-- .../output/node/unirest/multipart-data.js | 4 ++-- .../output/node/unirest/multipart-file.js | 6 +++--- .../node/unirest/multipart-form-data.js | 4 ++-- test/fixtures/output/node/unirest/query.js | 5 ++--- test/fixtures/output/node/unirest/short.js | 5 ++--- .../output/node/unirest/text-plain.js | 6 +++--- test/targets/javascript/xhr.js | 2 +- 85 files changed, 247 insertions(+), 250 deletions(-) diff --git a/src/targets/javascript/fetch.js b/src/targets/javascript/fetch.js index 1d0d147ea..7c7452203 100644 --- a/src/targets/javascript/fetch.js +++ b/src/targets/javascript/fetch.js @@ -44,7 +44,7 @@ module.exports = function (source, options) { break case 'multipart/form-data': - code.push('var form = new FormData();') + code.push('const form = new FormData();') source.postData.params.forEach(function (param) { code.push( diff --git a/src/targets/javascript/jquery.js b/src/targets/javascript/jquery.js index 8cea77477..e84e390b6 100644 --- a/src/targets/javascript/jquery.js +++ b/src/targets/javascript/jquery.js @@ -38,7 +38,7 @@ module.exports = function (source, options) { break case 'multipart/form-data': - code.push('var form = new FormData();') + code.push('const form = new FormData();') source.postData.params.forEach(function (param) { code.push('form.append(%s, %s);', JSON.stringify(param.name), JSON.stringify(param.value || param.fileName || '')) @@ -62,7 +62,7 @@ module.exports = function (source, options) { } } - code.push('var settings = ' + JSON.stringify(settings, null, opts.indent).replace('"[form]"', 'form')) + code.push('const settings = ' + JSON.stringify(settings, null, opts.indent).replace('"[form]"', 'form') + ';') .blank() .push('$.ajax(settings).done(function (response) {') .push(1, 'console.log(response);') diff --git a/src/targets/javascript/xhr.js b/src/targets/javascript/xhr.js index 64d8d7885..e2793c62b 100644 --- a/src/targets/javascript/xhr.js +++ b/src/targets/javascript/xhr.js @@ -22,12 +22,12 @@ module.exports = function (source, options) { switch (source.postData.mimeType) { case 'application/json': - code.push('var data = JSON.stringify(%s);', JSON.stringify(source.postData.jsonObj, null, opts.indent)) + code.push('const data = JSON.stringify(%s);', JSON.stringify(source.postData.jsonObj, null, opts.indent)) .push(null) break case 'multipart/form-data': - code.push('var data = new FormData();') + code.push('const data = new FormData();') source.postData.params.forEach(function (param) { code.push('data.append(%s, %s);', JSON.stringify(param.name), JSON.stringify(param.value || param.fileName || '')) @@ -42,11 +42,11 @@ module.exports = function (source, options) { break default: - code.push('var data = %s;', JSON.stringify(source.postData.text || null)) + code.push('const data = %s;', JSON.stringify(source.postData.text || null)) .blank() } - code.push('var xhr = new XMLHttpRequest();') + code.push('const xhr = new XMLHttpRequest();') if (opts.cors) { code.push('xhr.withCredentials = true;') diff --git a/src/targets/node/native.js b/src/targets/node/native.js index a4ec208b1..7cbf1b746 100644 --- a/src/targets/node/native.js +++ b/src/targets/node/native.js @@ -28,20 +28,20 @@ module.exports = function (source, options) { headers: source.allHeaders } - code.push('var http = require("%s");', source.uriObj.protocol.replace(':', '')) + code.push('const http = require("%s");', source.uriObj.protocol.replace(':', '')) code.blank() - .push('var options = %s;', JSON.stringify(reqOpts, null, opts.indent)) + .push('const options = %s;', JSON.stringify(reqOpts, null, opts.indent)) .blank() - .push('var req = http.request(options, function (res) {') - .push(1, 'var chunks = [];') + .push('const req = http.request(options, function (res) {') + .push(1, 'const chunks = [];') .blank() .push(1, 'res.on("data", function (chunk) {') .push(2, 'chunks.push(chunk);') .push(1, '});') .blank() .push(1, 'res.on("end", function () {') - .push(2, 'var body = Buffer.concat(chunks);') + .push(2, 'const body = Buffer.concat(chunks);') .push(2, 'console.log(body.toString());') .push(1, '});') .push('});') @@ -50,7 +50,7 @@ module.exports = function (source, options) { switch (source.postData.mimeType) { case 'application/x-www-form-urlencoded': if (source.postData.paramsObj) { - code.unshift('var qs = require("querystring");') + code.unshift('const qs = require("querystring");') code.push('req.write(qs.stringify(%s));', stringifyObject(source.postData.paramsObj, { indent: ' ', inlineCharacterLimit: 80 diff --git a/src/targets/node/request.js b/src/targets/node/request.js index 7711d63db..d704ae19f 100644 --- a/src/targets/node/request.js +++ b/src/targets/node/request.js @@ -22,7 +22,7 @@ module.exports = function (source, options) { var includeFS = false var code = new CodeBuilder(opts.indent) - code.push('var request = require("request");') + code.push("const request = require('request');") .blank() var reqOpts = { @@ -90,21 +90,21 @@ module.exports = function (source, options) { if (source.cookies.length) { reqOpts.jar = 'JAR' - code.push('var jar = request.jar();') + code.push('const jar = request.jar();') var url = source.url source.cookies.forEach(function (cookie) { - code.push('jar.setCookie(request.cookie("%s=%s"), "%s");', encodeURIComponent(cookie.name), encodeURIComponent(cookie.value), url) + code.push("jar.setCookie(request.cookie('%s=%s'), '%s');", encodeURIComponent(cookie.name), encodeURIComponent(cookie.value), url) }) code.blank() } if (includeFS) { - code.unshift('var fs = require("fs");') + code.unshift("const fs = require('fs');") } - code.push('var options = %s;', stringifyObject(reqOpts, { indent: ' ', inlineCharacterLimit: 80 })) + code.push('const options = %s;', stringifyObject(reqOpts, { indent: ' ', inlineCharacterLimit: 80 })) .blank() code.push(util.format('request(options, %s', 'function (error, response, body) {')) diff --git a/src/targets/node/unirest.js b/src/targets/node/unirest.js index 9927be182..616805a42 100644 --- a/src/targets/node/unirest.js +++ b/src/targets/node/unirest.js @@ -20,20 +20,20 @@ module.exports = function (source, options) { var includeFS = false var code = new CodeBuilder(opts.indent) - code.push('var unirest = require("unirest");') + code.push('const unirest = require("unirest");') .blank() - .push('var req = unirest("%s", "%s");', source.method, source.url) + .push('const req = unirest("%s", "%s");', source.method, source.url) .blank() if (source.cookies.length) { - code.push('var CookieJar = unirest.jar();') + code.push('const CookieJar = unirest.jar();') source.cookies.forEach(function (cookie) { code.push('CookieJar.add("%s=%s","%s");', encodeURIComponent(cookie.name), encodeURIComponent(cookie.value), source.url) }) code.push('req.jar(CookieJar);') - .blank() + .blank() } if (Object.keys(source.queryObj).length) { @@ -50,6 +50,7 @@ module.exports = function (source, options) { case 'application/x-www-form-urlencoded': if (source.postData.paramsObj) { code.push('req.form(%s);', JSON.stringify(source.postData.paramsObj, null, opts.indent)) + .blank() } break @@ -57,6 +58,7 @@ module.exports = function (source, options) { if (source.postData.jsonObj) { code.push('req.type("json");') .push('req.send(%s);', JSON.stringify(source.postData.jsonObj, null, opts.indent)) + .blank() } break @@ -84,20 +86,21 @@ module.exports = function (source, options) { }) code.push('req.multipart(%s);', JSON.stringify(multipart, null, opts.indent)) + .blank() break default: if (source.postData.text) { - code.push(opts.indent + 'req.send(%s);', JSON.stringify(source.postData.text, null, opts.indent)) + code.push('req.send(%s);', JSON.stringify(source.postData.text, null, opts.indent)) + .blank() } } if (includeFS) { - code.unshift('var fs = require("fs");') + code.unshift('const fs = require("fs");') } - code.blank() - .push('req.end(function (res) {') + code.push('req.end(function (res) {') .push(1, 'if (res.error) throw new Error(res.error);') .blank() .push(1, 'console.log(res.body);') diff --git a/test/fixtures/output/javascript/fetch/multipart-data.js b/test/fixtures/output/javascript/fetch/multipart-data.js index bb8740063..f90125e10 100644 --- a/test/fixtures/output/javascript/fetch/multipart-data.js +++ b/test/fixtures/output/javascript/fetch/multipart-data.js @@ -1,4 +1,4 @@ -var form = new FormData(); +const form = new FormData(); form.append("foo", "Hello World"); fetch("http://mockbin.com/har", { diff --git a/test/fixtures/output/javascript/fetch/multipart-file.js b/test/fixtures/output/javascript/fetch/multipart-file.js index 968eb3bee..a425041b5 100644 --- a/test/fixtures/output/javascript/fetch/multipart-file.js +++ b/test/fixtures/output/javascript/fetch/multipart-file.js @@ -1,4 +1,4 @@ -var form = new FormData(); +const form = new FormData(); form.append("foo", "test/fixtures/files/hello.txt"); fetch("http://mockbin.com/har", { diff --git a/test/fixtures/output/javascript/fetch/multipart-form-data.js b/test/fixtures/output/javascript/fetch/multipart-form-data.js index 62937b3fd..f0c050724 100644 --- a/test/fixtures/output/javascript/fetch/multipart-form-data.js +++ b/test/fixtures/output/javascript/fetch/multipart-form-data.js @@ -1,4 +1,4 @@ -var form = new FormData(); +const form = new FormData(); form.append("foo", "bar"); fetch("http://mockbin.com/har", { diff --git a/test/fixtures/output/javascript/jquery/application-form-encoded.js b/test/fixtures/output/javascript/jquery/application-form-encoded.js index dc296cc3e..9ecf72e80 100644 --- a/test/fixtures/output/javascript/jquery/application-form-encoded.js +++ b/test/fixtures/output/javascript/jquery/application-form-encoded.js @@ -1,4 +1,4 @@ -var settings = { +const settings = { "async": true, "crossDomain": true, "url": "http://mockbin.com/har", @@ -10,7 +10,7 @@ var settings = { "foo": "bar", "hello": "world" } -} +}; $.ajax(settings).done(function (response) { console.log(response); diff --git a/test/fixtures/output/javascript/jquery/application-json.js b/test/fixtures/output/javascript/jquery/application-json.js index 0b53728b3..5b02a22f0 100644 --- a/test/fixtures/output/javascript/jquery/application-json.js +++ b/test/fixtures/output/javascript/jquery/application-json.js @@ -1,4 +1,4 @@ -var settings = { +const settings = { "async": true, "crossDomain": true, "url": "http://mockbin.com/har", @@ -8,7 +8,7 @@ var settings = { }, "processData": false, "data": "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" -} +}; $.ajax(settings).done(function (response) { console.log(response); diff --git a/test/fixtures/output/javascript/jquery/cookies.js b/test/fixtures/output/javascript/jquery/cookies.js index f65a8d048..653f10d0c 100644 --- a/test/fixtures/output/javascript/jquery/cookies.js +++ b/test/fixtures/output/javascript/jquery/cookies.js @@ -1,4 +1,4 @@ -var settings = { +const settings = { "async": true, "crossDomain": true, "url": "http://mockbin.com/har", @@ -6,7 +6,7 @@ var settings = { "headers": { "cookie": "foo=bar; bar=baz" } -} +}; $.ajax(settings).done(function (response) { console.log(response); diff --git a/test/fixtures/output/javascript/jquery/custom-method.js b/test/fixtures/output/javascript/jquery/custom-method.js index ba4185299..521c2fc00 100644 --- a/test/fixtures/output/javascript/jquery/custom-method.js +++ b/test/fixtures/output/javascript/jquery/custom-method.js @@ -1,10 +1,10 @@ -var settings = { +const settings = { "async": true, "crossDomain": true, "url": "http://mockbin.com/har", "method": "PROPFIND", "headers": {} -} +}; $.ajax(settings).done(function (response) { console.log(response); diff --git a/test/fixtures/output/javascript/jquery/full.js b/test/fixtures/output/javascript/jquery/full.js index 50f7cf609..36fb5b1f9 100644 --- a/test/fixtures/output/javascript/jquery/full.js +++ b/test/fixtures/output/javascript/jquery/full.js @@ -1,4 +1,4 @@ -var settings = { +const settings = { "async": true, "crossDomain": true, "url": "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value", @@ -11,7 +11,7 @@ var settings = { "data": { "foo": "bar" } -} +}; $.ajax(settings).done(function (response) { console.log(response); diff --git a/test/fixtures/output/javascript/jquery/headers.js b/test/fixtures/output/javascript/jquery/headers.js index 030e7f6ff..17652fa25 100644 --- a/test/fixtures/output/javascript/jquery/headers.js +++ b/test/fixtures/output/javascript/jquery/headers.js @@ -1,4 +1,4 @@ -var settings = { +const settings = { "async": true, "crossDomain": true, "url": "http://mockbin.com/har", @@ -7,7 +7,7 @@ var settings = { "accept": "application/json", "x-foo": "Bar" } -} +}; $.ajax(settings).done(function (response) { console.log(response); diff --git a/test/fixtures/output/javascript/jquery/https.js b/test/fixtures/output/javascript/jquery/https.js index 418bfba7f..09fe852d6 100644 --- a/test/fixtures/output/javascript/jquery/https.js +++ b/test/fixtures/output/javascript/jquery/https.js @@ -1,10 +1,10 @@ -var settings = { +const settings = { "async": true, "crossDomain": true, "url": "https://mockbin.com/har", "method": "GET", "headers": {} -} +}; $.ajax(settings).done(function (response) { console.log(response); diff --git a/test/fixtures/output/javascript/jquery/jsonObj-multiline.js b/test/fixtures/output/javascript/jquery/jsonObj-multiline.js index 5e5096c53..f7060b4b5 100644 --- a/test/fixtures/output/javascript/jquery/jsonObj-multiline.js +++ b/test/fixtures/output/javascript/jquery/jsonObj-multiline.js @@ -1,4 +1,4 @@ -var settings = { +const settings = { "async": true, "crossDomain": true, "url": "http://mockbin.com/har", @@ -8,7 +8,7 @@ var settings = { }, "processData": false, "data": "{\n \"foo\": \"bar\"\n}" -} +}; $.ajax(settings).done(function (response) { console.log(response); diff --git a/test/fixtures/output/javascript/jquery/jsonObj-null-value.js b/test/fixtures/output/javascript/jquery/jsonObj-null-value.js index a8b88b785..afa5f175a 100644 --- a/test/fixtures/output/javascript/jquery/jsonObj-null-value.js +++ b/test/fixtures/output/javascript/jquery/jsonObj-null-value.js @@ -1,4 +1,4 @@ -var settings = { +const settings = { "async": true, "crossDomain": true, "url": "http://mockbin.com/har", @@ -8,7 +8,7 @@ var settings = { }, "processData": false, "data": "{\"foo\":null}" -} +}; $.ajax(settings).done(function (response) { console.log(response); diff --git a/test/fixtures/output/javascript/jquery/multipart-data.js b/test/fixtures/output/javascript/jquery/multipart-data.js index 8dea93d99..74f9b9752 100644 --- a/test/fixtures/output/javascript/jquery/multipart-data.js +++ b/test/fixtures/output/javascript/jquery/multipart-data.js @@ -1,7 +1,7 @@ -var form = new FormData(); +const form = new FormData(); form.append("foo", "Hello World"); -var settings = { +const settings = { "async": true, "crossDomain": true, "url": "http://mockbin.com/har", @@ -11,7 +11,7 @@ var settings = { "contentType": false, "mimeType": "multipart/form-data", "data": form -} +}; $.ajax(settings).done(function (response) { console.log(response); diff --git a/test/fixtures/output/javascript/jquery/multipart-file.js b/test/fixtures/output/javascript/jquery/multipart-file.js index 12006dd89..8c1a50404 100644 --- a/test/fixtures/output/javascript/jquery/multipart-file.js +++ b/test/fixtures/output/javascript/jquery/multipart-file.js @@ -1,7 +1,7 @@ -var form = new FormData(); +const form = new FormData(); form.append("foo", "test/fixtures/files/hello.txt"); -var settings = { +const settings = { "async": true, "crossDomain": true, "url": "http://mockbin.com/har", @@ -11,7 +11,7 @@ var settings = { "contentType": false, "mimeType": "multipart/form-data", "data": form -} +}; $.ajax(settings).done(function (response) { console.log(response); diff --git a/test/fixtures/output/javascript/jquery/multipart-form-data.js b/test/fixtures/output/javascript/jquery/multipart-form-data.js index 584b8d9ec..fc2f25e0b 100644 --- a/test/fixtures/output/javascript/jquery/multipart-form-data.js +++ b/test/fixtures/output/javascript/jquery/multipart-form-data.js @@ -1,7 +1,7 @@ -var form = new FormData(); +const form = new FormData(); form.append("foo", "bar"); -var settings = { +const settings = { "async": true, "crossDomain": true, "url": "http://mockbin.com/har", @@ -11,7 +11,7 @@ var settings = { "contentType": false, "mimeType": "multipart/form-data", "data": form -} +}; $.ajax(settings).done(function (response) { console.log(response); diff --git a/test/fixtures/output/javascript/jquery/query.js b/test/fixtures/output/javascript/jquery/query.js index 15a0663e4..58baea69e 100644 --- a/test/fixtures/output/javascript/jquery/query.js +++ b/test/fixtures/output/javascript/jquery/query.js @@ -1,10 +1,10 @@ -var settings = { +const settings = { "async": true, "crossDomain": true, "url": "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value", "method": "GET", "headers": {} -} +}; $.ajax(settings).done(function (response) { console.log(response); diff --git a/test/fixtures/output/javascript/jquery/short.js b/test/fixtures/output/javascript/jquery/short.js index 45e3bdd07..c87b2c8cf 100644 --- a/test/fixtures/output/javascript/jquery/short.js +++ b/test/fixtures/output/javascript/jquery/short.js @@ -1,10 +1,10 @@ -var settings = { +const settings = { "async": true, "crossDomain": true, "url": "http://mockbin.com/har", "method": "GET", "headers": {} -} +}; $.ajax(settings).done(function (response) { console.log(response); diff --git a/test/fixtures/output/javascript/jquery/text-plain.js b/test/fixtures/output/javascript/jquery/text-plain.js index 58debb2de..160075d2f 100644 --- a/test/fixtures/output/javascript/jquery/text-plain.js +++ b/test/fixtures/output/javascript/jquery/text-plain.js @@ -1,4 +1,4 @@ -var settings = { +const settings = { "async": true, "crossDomain": true, "url": "http://mockbin.com/har", @@ -7,7 +7,7 @@ var settings = { "content-type": "text/plain" }, "data": "Hello World" -} +}; $.ajax(settings).done(function (response) { console.log(response); diff --git a/test/fixtures/output/javascript/xhr/application-form-encoded.js b/test/fixtures/output/javascript/xhr/application-form-encoded.js index 90cfc66a6..c6b2cdecc 100644 --- a/test/fixtures/output/javascript/xhr/application-form-encoded.js +++ b/test/fixtures/output/javascript/xhr/application-form-encoded.js @@ -1,6 +1,6 @@ -var data = "foo=bar&hello=world"; +const data = "foo=bar&hello=world"; -var xhr = new XMLHttpRequest(); +const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { diff --git a/test/fixtures/output/javascript/xhr/application-json.js b/test/fixtures/output/javascript/xhr/application-json.js index 98508d808..853be4a3c 100644 --- a/test/fixtures/output/javascript/xhr/application-json.js +++ b/test/fixtures/output/javascript/xhr/application-json.js @@ -1,4 +1,4 @@ -var data = JSON.stringify({ +const data = JSON.stringify({ "number": 1, "string": "f\"oo", "arr": [ @@ -19,7 +19,7 @@ var data = JSON.stringify({ "boolean": false }); -var xhr = new XMLHttpRequest(); +const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { diff --git a/test/fixtures/output/javascript/xhr/cookies.js b/test/fixtures/output/javascript/xhr/cookies.js index d110546ea..dbce36082 100644 --- a/test/fixtures/output/javascript/xhr/cookies.js +++ b/test/fixtures/output/javascript/xhr/cookies.js @@ -1,6 +1,6 @@ -var data = null; +const data = null; -var xhr = new XMLHttpRequest(); +const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { diff --git a/test/fixtures/output/javascript/xhr/custom-method.js b/test/fixtures/output/javascript/xhr/custom-method.js index 6da6675c3..40c589237 100644 --- a/test/fixtures/output/javascript/xhr/custom-method.js +++ b/test/fixtures/output/javascript/xhr/custom-method.js @@ -1,6 +1,6 @@ -var data = null; +const data = null; -var xhr = new XMLHttpRequest(); +const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { diff --git a/test/fixtures/output/javascript/xhr/full.js b/test/fixtures/output/javascript/xhr/full.js index 55547738f..a32dd52bc 100644 --- a/test/fixtures/output/javascript/xhr/full.js +++ b/test/fixtures/output/javascript/xhr/full.js @@ -1,6 +1,6 @@ -var data = "foo=bar"; +const data = "foo=bar"; -var xhr = new XMLHttpRequest(); +const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { diff --git a/test/fixtures/output/javascript/xhr/headers.js b/test/fixtures/output/javascript/xhr/headers.js index 27e9347bc..511c4ab52 100644 --- a/test/fixtures/output/javascript/xhr/headers.js +++ b/test/fixtures/output/javascript/xhr/headers.js @@ -1,6 +1,6 @@ -var data = null; +const data = null; -var xhr = new XMLHttpRequest(); +const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { diff --git a/test/fixtures/output/javascript/xhr/https.js b/test/fixtures/output/javascript/xhr/https.js index 6f2e8f34f..0d5ce6b2b 100644 --- a/test/fixtures/output/javascript/xhr/https.js +++ b/test/fixtures/output/javascript/xhr/https.js @@ -1,6 +1,6 @@ -var data = null; +const data = null; -var xhr = new XMLHttpRequest(); +const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { diff --git a/test/fixtures/output/javascript/xhr/jsonObj-multiline.js b/test/fixtures/output/javascript/xhr/jsonObj-multiline.js index 8cc564a3d..b0bfbe099 100644 --- a/test/fixtures/output/javascript/xhr/jsonObj-multiline.js +++ b/test/fixtures/output/javascript/xhr/jsonObj-multiline.js @@ -1,8 +1,8 @@ -var data = JSON.stringify({ +const data = JSON.stringify({ "foo": "bar" }); -var xhr = new XMLHttpRequest(); +const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { diff --git a/test/fixtures/output/javascript/xhr/jsonObj-null-value.js b/test/fixtures/output/javascript/xhr/jsonObj-null-value.js index 8105f6446..d6948dcf9 100644 --- a/test/fixtures/output/javascript/xhr/jsonObj-null-value.js +++ b/test/fixtures/output/javascript/xhr/jsonObj-null-value.js @@ -1,8 +1,8 @@ -var data = JSON.stringify({ +const data = JSON.stringify({ "foo": null }); -var xhr = new XMLHttpRequest(); +const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { diff --git a/test/fixtures/output/javascript/xhr/multipart-data.js b/test/fixtures/output/javascript/xhr/multipart-data.js index 2b7f42579..5753015f5 100644 --- a/test/fixtures/output/javascript/xhr/multipart-data.js +++ b/test/fixtures/output/javascript/xhr/multipart-data.js @@ -1,7 +1,7 @@ -var data = new FormData(); +const data = new FormData(); data.append("foo", "Hello World"); -var xhr = new XMLHttpRequest(); +const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { diff --git a/test/fixtures/output/javascript/xhr/multipart-file.js b/test/fixtures/output/javascript/xhr/multipart-file.js index a5326f2a3..44d80da5b 100644 --- a/test/fixtures/output/javascript/xhr/multipart-file.js +++ b/test/fixtures/output/javascript/xhr/multipart-file.js @@ -1,7 +1,7 @@ -var data = new FormData(); +const data = new FormData(); data.append("foo", "test/fixtures/files/hello.txt"); -var xhr = new XMLHttpRequest(); +const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { diff --git a/test/fixtures/output/javascript/xhr/multipart-form-data.js b/test/fixtures/output/javascript/xhr/multipart-form-data.js index 574bafff5..32e25edb3 100644 --- a/test/fixtures/output/javascript/xhr/multipart-form-data.js +++ b/test/fixtures/output/javascript/xhr/multipart-form-data.js @@ -1,7 +1,7 @@ -var data = new FormData(); +const data = new FormData(); data.append("foo", "bar"); -var xhr = new XMLHttpRequest(); +const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { diff --git a/test/fixtures/output/javascript/xhr/query.js b/test/fixtures/output/javascript/xhr/query.js index b9cfa0d23..f620f6b37 100644 --- a/test/fixtures/output/javascript/xhr/query.js +++ b/test/fixtures/output/javascript/xhr/query.js @@ -1,6 +1,6 @@ -var data = null; +const data = null; -var xhr = new XMLHttpRequest(); +const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { diff --git a/test/fixtures/output/javascript/xhr/short.js b/test/fixtures/output/javascript/xhr/short.js index af35e7675..0993af510 100644 --- a/test/fixtures/output/javascript/xhr/short.js +++ b/test/fixtures/output/javascript/xhr/short.js @@ -1,6 +1,6 @@ -var data = null; +const data = null; -var xhr = new XMLHttpRequest(); +const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { diff --git a/test/fixtures/output/javascript/xhr/text-plain.js b/test/fixtures/output/javascript/xhr/text-plain.js index 6b6ca5171..495fc0e4a 100644 --- a/test/fixtures/output/javascript/xhr/text-plain.js +++ b/test/fixtures/output/javascript/xhr/text-plain.js @@ -1,6 +1,6 @@ -var data = "Hello World"; +const data = "Hello World"; -var xhr = new XMLHttpRequest(); +const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { diff --git a/test/fixtures/output/node/native/application-form-encoded.js b/test/fixtures/output/node/native/application-form-encoded.js index 6d91f8974..bcd87872b 100644 --- a/test/fixtures/output/node/native/application-form-encoded.js +++ b/test/fixtures/output/node/native/application-form-encoded.js @@ -1,7 +1,7 @@ -var qs = require("querystring"); -var http = require("http"); +const qs = require("querystring"); +const http = require("http"); -var options = { +const options = { "method": "POST", "hostname": "mockbin.com", "port": null, @@ -11,15 +11,15 @@ var options = { } }; -var req = http.request(options, function (res) { - var chunks = []; +const req = http.request(options, function (res) { + const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); console.log(body.toString()); }); }); diff --git a/test/fixtures/output/node/native/application-json.js b/test/fixtures/output/node/native/application-json.js index 9ee32ee3b..4234fe283 100644 --- a/test/fixtures/output/node/native/application-json.js +++ b/test/fixtures/output/node/native/application-json.js @@ -1,6 +1,6 @@ -var http = require("http"); +const http = require("http"); -var options = { +const options = { "method": "POST", "hostname": "mockbin.com", "port": null, @@ -10,15 +10,15 @@ var options = { } }; -var req = http.request(options, function (res) { - var chunks = []; +const req = http.request(options, function (res) { + const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); console.log(body.toString()); }); }); diff --git a/test/fixtures/output/node/native/cookies.js b/test/fixtures/output/node/native/cookies.js index 39e75389d..56936f0eb 100644 --- a/test/fixtures/output/node/native/cookies.js +++ b/test/fixtures/output/node/native/cookies.js @@ -1,6 +1,6 @@ -var http = require("http"); +const http = require("http"); -var options = { +const options = { "method": "POST", "hostname": "mockbin.com", "port": null, @@ -10,15 +10,15 @@ var options = { } }; -var req = http.request(options, function (res) { - var chunks = []; +const req = http.request(options, function (res) { + const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); console.log(body.toString()); }); }); diff --git a/test/fixtures/output/node/native/custom-method.js b/test/fixtures/output/node/native/custom-method.js index f87f77499..2c44fc9b7 100644 --- a/test/fixtures/output/node/native/custom-method.js +++ b/test/fixtures/output/node/native/custom-method.js @@ -1,6 +1,6 @@ -var http = require("http"); +const http = require("http"); -var options = { +const options = { "method": "PROPFIND", "hostname": "mockbin.com", "port": null, @@ -8,15 +8,15 @@ var options = { "headers": {} }; -var req = http.request(options, function (res) { - var chunks = []; +const req = http.request(options, function (res) { + const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); console.log(body.toString()); }); }); diff --git a/test/fixtures/output/node/native/full.js b/test/fixtures/output/node/native/full.js index 8701cdc42..af89775d9 100644 --- a/test/fixtures/output/node/native/full.js +++ b/test/fixtures/output/node/native/full.js @@ -1,7 +1,7 @@ -var qs = require("querystring"); -var http = require("http"); +const qs = require("querystring"); +const http = require("http"); -var options = { +const options = { "method": "POST", "hostname": "mockbin.com", "port": null, @@ -13,15 +13,15 @@ var options = { } }; -var req = http.request(options, function (res) { - var chunks = []; +const req = http.request(options, function (res) { + const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); console.log(body.toString()); }); }); diff --git a/test/fixtures/output/node/native/headers.js b/test/fixtures/output/node/native/headers.js index 21d094b48..a36dfc9c1 100644 --- a/test/fixtures/output/node/native/headers.js +++ b/test/fixtures/output/node/native/headers.js @@ -1,6 +1,6 @@ -var http = require("http"); +const http = require("http"); -var options = { +const options = { "method": "GET", "hostname": "mockbin.com", "port": null, @@ -11,15 +11,15 @@ var options = { } }; -var req = http.request(options, function (res) { - var chunks = []; +const req = http.request(options, function (res) { + const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); console.log(body.toString()); }); }); diff --git a/test/fixtures/output/node/native/https.js b/test/fixtures/output/node/native/https.js index 5dd0a44b6..e6f201a23 100644 --- a/test/fixtures/output/node/native/https.js +++ b/test/fixtures/output/node/native/https.js @@ -1,6 +1,6 @@ -var http = require("https"); +const http = require("https"); -var options = { +const options = { "method": "GET", "hostname": "mockbin.com", "port": null, @@ -8,15 +8,15 @@ var options = { "headers": {} }; -var req = http.request(options, function (res) { - var chunks = []; +const req = http.request(options, function (res) { + const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); console.log(body.toString()); }); }); diff --git a/test/fixtures/output/node/native/jsonObj-multiline.js b/test/fixtures/output/node/native/jsonObj-multiline.js index 2b9873b4a..2a07d1b18 100644 --- a/test/fixtures/output/node/native/jsonObj-multiline.js +++ b/test/fixtures/output/node/native/jsonObj-multiline.js @@ -1,6 +1,6 @@ -var http = require("http"); +const http = require("http"); -var options = { +const options = { "method": "POST", "hostname": "mockbin.com", "port": null, @@ -10,15 +10,15 @@ var options = { } }; -var req = http.request(options, function (res) { - var chunks = []; +const req = http.request(options, function (res) { + const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); console.log(body.toString()); }); }); diff --git a/test/fixtures/output/node/native/jsonObj-null-value.js b/test/fixtures/output/node/native/jsonObj-null-value.js index fa34ca357..be0dad1a0 100644 --- a/test/fixtures/output/node/native/jsonObj-null-value.js +++ b/test/fixtures/output/node/native/jsonObj-null-value.js @@ -1,6 +1,6 @@ -var http = require("http"); +const http = require("http"); -var options = { +const options = { "method": "POST", "hostname": "mockbin.com", "port": null, @@ -10,15 +10,15 @@ var options = { } }; -var req = http.request(options, function (res) { - var chunks = []; +const req = http.request(options, function (res) { + const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); console.log(body.toString()); }); }); diff --git a/test/fixtures/output/node/native/multipart-data.js b/test/fixtures/output/node/native/multipart-data.js index 61d527c1f..54e204013 100644 --- a/test/fixtures/output/node/native/multipart-data.js +++ b/test/fixtures/output/node/native/multipart-data.js @@ -1,6 +1,6 @@ -var http = require("http"); +const http = require("http"); -var options = { +const options = { "method": "POST", "hostname": "mockbin.com", "port": null, @@ -10,15 +10,15 @@ var options = { } }; -var req = http.request(options, function (res) { - var chunks = []; +const req = http.request(options, function (res) { + const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); console.log(body.toString()); }); }); diff --git a/test/fixtures/output/node/native/multipart-file.js b/test/fixtures/output/node/native/multipart-file.js index 17023a88d..23fa91116 100644 --- a/test/fixtures/output/node/native/multipart-file.js +++ b/test/fixtures/output/node/native/multipart-file.js @@ -1,6 +1,6 @@ -var http = require("http"); +const http = require("http"); -var options = { +const options = { "method": "POST", "hostname": "mockbin.com", "port": null, @@ -10,15 +10,15 @@ var options = { } }; -var req = http.request(options, function (res) { - var chunks = []; +const req = http.request(options, function (res) { + const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); console.log(body.toString()); }); }); diff --git a/test/fixtures/output/node/native/multipart-form-data.js b/test/fixtures/output/node/native/multipart-form-data.js index 55244c444..7d3aabd62 100644 --- a/test/fixtures/output/node/native/multipart-form-data.js +++ b/test/fixtures/output/node/native/multipart-form-data.js @@ -1,6 +1,6 @@ -var http = require("http"); +const http = require("http"); -var options = { +const options = { "method": "POST", "hostname": "mockbin.com", "port": null, @@ -10,15 +10,15 @@ var options = { } }; -var req = http.request(options, function (res) { - var chunks = []; +const req = http.request(options, function (res) { + const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); console.log(body.toString()); }); }); diff --git a/test/fixtures/output/node/native/query.js b/test/fixtures/output/node/native/query.js index c706f8217..c88b3a85a 100644 --- a/test/fixtures/output/node/native/query.js +++ b/test/fixtures/output/node/native/query.js @@ -1,6 +1,6 @@ -var http = require("http"); +const http = require("http"); -var options = { +const options = { "method": "GET", "hostname": "mockbin.com", "port": null, @@ -8,15 +8,15 @@ var options = { "headers": {} }; -var req = http.request(options, function (res) { - var chunks = []; +const req = http.request(options, function (res) { + const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); console.log(body.toString()); }); }); diff --git a/test/fixtures/output/node/native/short.js b/test/fixtures/output/node/native/short.js index 1c25ff701..e661ca8c9 100644 --- a/test/fixtures/output/node/native/short.js +++ b/test/fixtures/output/node/native/short.js @@ -1,6 +1,6 @@ -var http = require("http"); +const http = require("http"); -var options = { +const options = { "method": "GET", "hostname": "mockbin.com", "port": null, @@ -8,15 +8,15 @@ var options = { "headers": {} }; -var req = http.request(options, function (res) { - var chunks = []; +const req = http.request(options, function (res) { + const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); console.log(body.toString()); }); }); diff --git a/test/fixtures/output/node/native/text-plain.js b/test/fixtures/output/node/native/text-plain.js index f733d8149..3f737b843 100644 --- a/test/fixtures/output/node/native/text-plain.js +++ b/test/fixtures/output/node/native/text-plain.js @@ -1,6 +1,6 @@ -var http = require("http"); +const http = require("http"); -var options = { +const options = { "method": "POST", "hostname": "mockbin.com", "port": null, @@ -10,15 +10,15 @@ var options = { } }; -var req = http.request(options, function (res) { - var chunks = []; +const req = http.request(options, function (res) { + const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); console.log(body.toString()); }); }); diff --git a/test/fixtures/output/node/request/application-form-encoded.js b/test/fixtures/output/node/request/application-form-encoded.js index 54c6cb9d9..798c16876 100644 --- a/test/fixtures/output/node/request/application-form-encoded.js +++ b/test/fixtures/output/node/request/application-form-encoded.js @@ -1,6 +1,6 @@ -var request = require("request"); +const request = require('request'); -var options = { +const options = { method: 'POST', url: 'http://mockbin.com/har', headers: {'content-type': 'application/x-www-form-urlencoded'}, diff --git a/test/fixtures/output/node/request/application-json.js b/test/fixtures/output/node/request/application-json.js index 47ccb206a..af6ad0db3 100644 --- a/test/fixtures/output/node/request/application-json.js +++ b/test/fixtures/output/node/request/application-json.js @@ -1,6 +1,6 @@ -var request = require("request"); +const request = require('request'); -var options = { +const options = { method: 'POST', url: 'http://mockbin.com/har', headers: {'content-type': 'application/json'}, diff --git a/test/fixtures/output/node/request/cookies.js b/test/fixtures/output/node/request/cookies.js index a739c0cef..4d23a4d14 100644 --- a/test/fixtures/output/node/request/cookies.js +++ b/test/fixtures/output/node/request/cookies.js @@ -1,10 +1,10 @@ -var request = require("request"); +const request = require('request'); -var jar = request.jar(); -jar.setCookie(request.cookie("foo=bar"), "http://mockbin.com/har"); -jar.setCookie(request.cookie("bar=baz"), "http://mockbin.com/har"); +const jar = request.jar(); +jar.setCookie(request.cookie('foo=bar'), 'http://mockbin.com/har'); +jar.setCookie(request.cookie('bar=baz'), 'http://mockbin.com/har'); -var options = {method: 'POST', url: 'http://mockbin.com/har', jar: 'JAR'}; +const options = {method: 'POST', url: 'http://mockbin.com/har', jar: 'JAR'}; request(options, function (error, response, body) { if (error) throw new Error(error); diff --git a/test/fixtures/output/node/request/custom-method.js b/test/fixtures/output/node/request/custom-method.js index 947650559..3b2bff046 100644 --- a/test/fixtures/output/node/request/custom-method.js +++ b/test/fixtures/output/node/request/custom-method.js @@ -1,6 +1,6 @@ -var request = require("request"); +const request = require('request'); -var options = {method: 'PROPFIND', url: 'http://mockbin.com/har'}; +const options = {method: 'PROPFIND', url: 'http://mockbin.com/har'}; request(options, function (error, response, body) { if (error) throw new Error(error); diff --git a/test/fixtures/output/node/request/full.js b/test/fixtures/output/node/request/full.js index b24ae4bb6..2dd1c8aa8 100644 --- a/test/fixtures/output/node/request/full.js +++ b/test/fixtures/output/node/request/full.js @@ -1,10 +1,10 @@ -var request = require("request"); +const request = require('request'); -var jar = request.jar(); -jar.setCookie(request.cookie("foo=bar"), "http://mockbin.com/har"); -jar.setCookie(request.cookie("bar=baz"), "http://mockbin.com/har"); +const jar = request.jar(); +jar.setCookie(request.cookie('foo=bar'), 'http://mockbin.com/har'); +jar.setCookie(request.cookie('bar=baz'), 'http://mockbin.com/har'); -var options = { +const options = { method: 'POST', url: 'http://mockbin.com/har', qs: {foo: ['bar', 'baz'], baz: 'abc', key: 'value'}, diff --git a/test/fixtures/output/node/request/headers.js b/test/fixtures/output/node/request/headers.js index 1e28531ff..a30e3fb4c 100644 --- a/test/fixtures/output/node/request/headers.js +++ b/test/fixtures/output/node/request/headers.js @@ -1,6 +1,6 @@ -var request = require("request"); +const request = require('request'); -var options = { +const options = { method: 'GET', url: 'http://mockbin.com/har', headers: {accept: 'application/json', 'x-foo': 'Bar'} diff --git a/test/fixtures/output/node/request/https.js b/test/fixtures/output/node/request/https.js index d655d6835..b5e4390ed 100644 --- a/test/fixtures/output/node/request/https.js +++ b/test/fixtures/output/node/request/https.js @@ -1,6 +1,6 @@ -var request = require("request"); +const request = require('request'); -var options = {method: 'GET', url: 'https://mockbin.com/har'}; +const options = {method: 'GET', url: 'https://mockbin.com/har'}; request(options, function (error, response, body) { if (error) throw new Error(error); diff --git a/test/fixtures/output/node/request/jsonObj-multiline.js b/test/fixtures/output/node/request/jsonObj-multiline.js index 3a0c3a8d0..b94df9ca5 100644 --- a/test/fixtures/output/node/request/jsonObj-multiline.js +++ b/test/fixtures/output/node/request/jsonObj-multiline.js @@ -1,6 +1,6 @@ -var request = require("request"); +const request = require('request'); -var options = { +const options = { method: 'POST', url: 'http://mockbin.com/har', headers: {'content-type': 'application/json'}, diff --git a/test/fixtures/output/node/request/jsonObj-null-value.js b/test/fixtures/output/node/request/jsonObj-null-value.js index a06dd028a..e12f19716 100644 --- a/test/fixtures/output/node/request/jsonObj-null-value.js +++ b/test/fixtures/output/node/request/jsonObj-null-value.js @@ -1,6 +1,6 @@ -var request = require("request"); +const request = require('request'); -var options = { +const options = { method: 'POST', url: 'http://mockbin.com/har', headers: {'content-type': 'application/json'}, diff --git a/test/fixtures/output/node/request/multipart-data.js b/test/fixtures/output/node/request/multipart-data.js index 2af993d89..84d816975 100644 --- a/test/fixtures/output/node/request/multipart-data.js +++ b/test/fixtures/output/node/request/multipart-data.js @@ -1,6 +1,6 @@ -var request = require("request"); +const request = require('request'); -var options = { +const options = { method: 'POST', url: 'http://mockbin.com/har', headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'}, diff --git a/test/fixtures/output/node/request/multipart-file.js b/test/fixtures/output/node/request/multipart-file.js index 0eae5dea1..61ca0c803 100644 --- a/test/fixtures/output/node/request/multipart-file.js +++ b/test/fixtures/output/node/request/multipart-file.js @@ -1,16 +1,16 @@ -var fs = require("fs"); -var request = require("request"); +const fs = require('fs'); +const request = require('request'); -var options = { +const options = { method: 'POST', url: 'http://mockbin.com/har', headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'}, formData: { foo: { value: 'fs.createReadStream("test/fixtures/files/hello.txt")', - options: { - filename: 'test/fixtures/files/hello.txt', - contentType: 'text/plain' + options: { + filename: 'test/fixtures/files/hello.txt', + contentType: 'text/plain' } } } diff --git a/test/fixtures/output/node/request/multipart-form-data.js b/test/fixtures/output/node/request/multipart-form-data.js index 05ddf57dd..ad4b47049 100644 --- a/test/fixtures/output/node/request/multipart-form-data.js +++ b/test/fixtures/output/node/request/multipart-form-data.js @@ -1,6 +1,6 @@ -var request = require("request"); +const request = require('request'); -var options = { +const options = { method: 'POST', url: 'http://mockbin.com/har', headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'}, diff --git a/test/fixtures/output/node/request/query.js b/test/fixtures/output/node/request/query.js index dfcb2e763..9183840e5 100644 --- a/test/fixtures/output/node/request/query.js +++ b/test/fixtures/output/node/request/query.js @@ -1,6 +1,6 @@ -var request = require("request"); +const request = require('request'); -var options = { +const options = { method: 'GET', url: 'http://mockbin.com/har', qs: {foo: ['bar', 'baz'], baz: 'abc', key: 'value'} diff --git a/test/fixtures/output/node/request/short.js b/test/fixtures/output/node/request/short.js index 823ad63e2..4543d8a39 100644 --- a/test/fixtures/output/node/request/short.js +++ b/test/fixtures/output/node/request/short.js @@ -1,6 +1,6 @@ -var request = require("request"); +const request = require('request'); -var options = {method: 'GET', url: 'http://mockbin.com/har'}; +const options = {method: 'GET', url: 'http://mockbin.com/har'}; request(options, function (error, response, body) { if (error) throw new Error(error); diff --git a/test/fixtures/output/node/request/text-plain.js b/test/fixtures/output/node/request/text-plain.js index bf646234e..e0bdcacfa 100644 --- a/test/fixtures/output/node/request/text-plain.js +++ b/test/fixtures/output/node/request/text-plain.js @@ -1,6 +1,6 @@ -var request = require("request"); +const request = require('request'); -var options = { +const options = { method: 'POST', url: 'http://mockbin.com/har', headers: {'content-type': 'text/plain'}, diff --git a/test/fixtures/output/node/unirest/application-form-encoded.js b/test/fixtures/output/node/unirest/application-form-encoded.js index 5f410768b..b8d2d15c8 100644 --- a/test/fixtures/output/node/unirest/application-form-encoded.js +++ b/test/fixtures/output/node/unirest/application-form-encoded.js @@ -1,6 +1,6 @@ -var unirest = require("unirest"); +const unirest = require("unirest"); -var req = unirest("POST", "http://mockbin.com/har"); +const req = unirest("POST", "http://mockbin.com/har"); req.headers({ "content-type": "application/x-www-form-urlencoded" diff --git a/test/fixtures/output/node/unirest/application-json.js b/test/fixtures/output/node/unirest/application-json.js index ba8d8202a..c9ec7c013 100644 --- a/test/fixtures/output/node/unirest/application-json.js +++ b/test/fixtures/output/node/unirest/application-json.js @@ -1,6 +1,6 @@ -var unirest = require("unirest"); +const unirest = require("unirest"); -var req = unirest("POST", "http://mockbin.com/har"); +const req = unirest("POST", "http://mockbin.com/har"); req.headers({ "content-type": "application/json" diff --git a/test/fixtures/output/node/unirest/cookies.js b/test/fixtures/output/node/unirest/cookies.js index 6d8d62d41..f14403091 100644 --- a/test/fixtures/output/node/unirest/cookies.js +++ b/test/fixtures/output/node/unirest/cookies.js @@ -1,13 +1,12 @@ -var unirest = require("unirest"); +const unirest = require("unirest"); -var req = unirest("POST", "http://mockbin.com/har"); +const req = unirest("POST", "http://mockbin.com/har"); -var CookieJar = unirest.jar(); +const CookieJar = unirest.jar(); CookieJar.add("foo=bar","http://mockbin.com/har"); CookieJar.add("bar=baz","http://mockbin.com/har"); req.jar(CookieJar); - req.end(function (res) { if (res.error) throw new Error(res.error); diff --git a/test/fixtures/output/node/unirest/custom-method.js b/test/fixtures/output/node/unirest/custom-method.js index 3e5bb5fa5..a2a931df2 100644 --- a/test/fixtures/output/node/unirest/custom-method.js +++ b/test/fixtures/output/node/unirest/custom-method.js @@ -1,7 +1,6 @@ -var unirest = require("unirest"); - -var req = unirest("PROPFIND", "http://mockbin.com/har"); +const unirest = require("unirest"); +const req = unirest("PROPFIND", "http://mockbin.com/har"); req.end(function (res) { if (res.error) throw new Error(res.error); diff --git a/test/fixtures/output/node/unirest/full.js b/test/fixtures/output/node/unirest/full.js index a7b949626..2c638e450 100644 --- a/test/fixtures/output/node/unirest/full.js +++ b/test/fixtures/output/node/unirest/full.js @@ -1,8 +1,8 @@ -var unirest = require("unirest"); +const unirest = require("unirest"); -var req = unirest("POST", "http://mockbin.com/har"); +const req = unirest("POST", "http://mockbin.com/har"); -var CookieJar = unirest.jar(); +const CookieJar = unirest.jar(); CookieJar.add("foo=bar","http://mockbin.com/har"); CookieJar.add("bar=baz","http://mockbin.com/har"); req.jar(CookieJar); diff --git a/test/fixtures/output/node/unirest/headers.js b/test/fixtures/output/node/unirest/headers.js index c36114767..a9e1939b2 100644 --- a/test/fixtures/output/node/unirest/headers.js +++ b/test/fixtures/output/node/unirest/headers.js @@ -1,13 +1,12 @@ -var unirest = require("unirest"); +const unirest = require("unirest"); -var req = unirest("GET", "http://mockbin.com/har"); +const req = unirest("GET", "http://mockbin.com/har"); req.headers({ "accept": "application/json", "x-foo": "Bar" }); - req.end(function (res) { if (res.error) throw new Error(res.error); diff --git a/test/fixtures/output/node/unirest/https.js b/test/fixtures/output/node/unirest/https.js index ec5faf337..52ae902f6 100644 --- a/test/fixtures/output/node/unirest/https.js +++ b/test/fixtures/output/node/unirest/https.js @@ -1,7 +1,6 @@ -var unirest = require("unirest"); - -var req = unirest("GET", "https://mockbin.com/har"); +const unirest = require("unirest"); +const req = unirest("GET", "https://mockbin.com/har"); req.end(function (res) { if (res.error) throw new Error(res.error); diff --git a/test/fixtures/output/node/unirest/jsonObj-multiline.js b/test/fixtures/output/node/unirest/jsonObj-multiline.js index cafd8cd60..2044cfe6b 100644 --- a/test/fixtures/output/node/unirest/jsonObj-multiline.js +++ b/test/fixtures/output/node/unirest/jsonObj-multiline.js @@ -1,6 +1,6 @@ -var unirest = require("unirest"); +const unirest = require("unirest"); -var req = unirest("POST", "http://mockbin.com/har"); +const req = unirest("POST", "http://mockbin.com/har"); req.headers({ "content-type": "application/json" diff --git a/test/fixtures/output/node/unirest/jsonObj-null-value.js b/test/fixtures/output/node/unirest/jsonObj-null-value.js index f898c6024..73ae28654 100644 --- a/test/fixtures/output/node/unirest/jsonObj-null-value.js +++ b/test/fixtures/output/node/unirest/jsonObj-null-value.js @@ -1,6 +1,6 @@ -var unirest = require("unirest"); +const unirest = require("unirest"); -var req = unirest("POST", "http://mockbin.com/har"); +const req = unirest("POST", "http://mockbin.com/har"); req.headers({ "content-type": "application/json" diff --git a/test/fixtures/output/node/unirest/multipart-data.js b/test/fixtures/output/node/unirest/multipart-data.js index bdf8da515..dafb13368 100644 --- a/test/fixtures/output/node/unirest/multipart-data.js +++ b/test/fixtures/output/node/unirest/multipart-data.js @@ -1,6 +1,6 @@ -var unirest = require("unirest"); +const unirest = require("unirest"); -var req = unirest("POST", "http://mockbin.com/har"); +const req = unirest("POST", "http://mockbin.com/har"); req.headers({ "content-type": "multipart/form-data; boundary=---011000010111000001101001" diff --git a/test/fixtures/output/node/unirest/multipart-file.js b/test/fixtures/output/node/unirest/multipart-file.js index c8efe878a..d18272287 100644 --- a/test/fixtures/output/node/unirest/multipart-file.js +++ b/test/fixtures/output/node/unirest/multipart-file.js @@ -1,7 +1,7 @@ -var fs = require("fs"); -var unirest = require("unirest"); +const fs = require("fs"); +const unirest = require("unirest"); -var req = unirest("POST", "http://mockbin.com/har"); +const req = unirest("POST", "http://mockbin.com/har"); req.headers({ "content-type": "multipart/form-data; boundary=---011000010111000001101001" diff --git a/test/fixtures/output/node/unirest/multipart-form-data.js b/test/fixtures/output/node/unirest/multipart-form-data.js index ea358a350..b13563c5a 100644 --- a/test/fixtures/output/node/unirest/multipart-form-data.js +++ b/test/fixtures/output/node/unirest/multipart-form-data.js @@ -1,6 +1,6 @@ -var unirest = require("unirest"); +const unirest = require("unirest"); -var req = unirest("POST", "http://mockbin.com/har"); +const req = unirest("POST", "http://mockbin.com/har"); req.headers({ "content-type": "multipart/form-data; boundary=---011000010111000001101001" diff --git a/test/fixtures/output/node/unirest/query.js b/test/fixtures/output/node/unirest/query.js index 464e2f941..2fc6e74d8 100644 --- a/test/fixtures/output/node/unirest/query.js +++ b/test/fixtures/output/node/unirest/query.js @@ -1,6 +1,6 @@ -var unirest = require("unirest"); +const unirest = require("unirest"); -var req = unirest("GET", "http://mockbin.com/har"); +const req = unirest("GET", "http://mockbin.com/har"); req.query({ "foo": [ @@ -11,7 +11,6 @@ req.query({ "key": "value" }); - req.end(function (res) { if (res.error) throw new Error(res.error); diff --git a/test/fixtures/output/node/unirest/short.js b/test/fixtures/output/node/unirest/short.js index 95a778b52..666a38b54 100644 --- a/test/fixtures/output/node/unirest/short.js +++ b/test/fixtures/output/node/unirest/short.js @@ -1,7 +1,6 @@ -var unirest = require("unirest"); - -var req = unirest("GET", "http://mockbin.com/har"); +const unirest = require("unirest"); +const req = unirest("GET", "http://mockbin.com/har"); req.end(function (res) { if (res.error) throw new Error(res.error); diff --git a/test/fixtures/output/node/unirest/text-plain.js b/test/fixtures/output/node/unirest/text-plain.js index bffa7ee03..aa25d2db1 100644 --- a/test/fixtures/output/node/unirest/text-plain.js +++ b/test/fixtures/output/node/unirest/text-plain.js @@ -1,12 +1,12 @@ -var unirest = require("unirest"); +const unirest = require("unirest"); -var req = unirest("POST", "http://mockbin.com/har"); +const req = unirest("POST", "http://mockbin.com/har"); req.headers({ "content-type": "text/plain" }); - req.send("Hello World"); +req.send("Hello World"); req.end(function (res) { if (res.error) throw new Error(res.error); diff --git a/test/targets/javascript/xhr.js b/test/targets/javascript/xhr.js index 38c8b73d5..4e7ec3df7 100644 --- a/test/targets/javascript/xhr.js +++ b/test/targets/javascript/xhr.js @@ -11,6 +11,6 @@ module.exports = function (HTTPSnippet, fixtures) { }) result.should.be.a.String() - result.replace(/\n/g, '').should.eql('var data = null;var xhr = new XMLHttpRequest();xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); }});xhr.open("GET", "http://mockbin.com/har");xhr.send(data);') + result.replace(/\n/g, '').should.eql('const data = null;const xhr = new XMLHttpRequest();xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); }});xhr.open("GET", "http://mockbin.com/har");xhr.send(data);') }) }