Skip to content

Commit 20eec6c

Browse files
committed
updates
1 parent 79ef3e0 commit 20eec6c

7 files changed

Lines changed: 1090 additions & 271 deletions

File tree

dist/httpsnippet.js

Lines changed: 39 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/httpsnippet.min.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/helpers/code-builder.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"use strict";
2-
3-
const { cloneDeep } = require("lodash");
4-
const util = require("util");
2+
var util = require("./util");
53

64
/**
75
* Helper object to format and aggragate lines of code.
@@ -12,7 +10,7 @@ const util = require("util");
1210
* @param {string} indentation Desired indentation character for aggregated lines of code
1311
* @param {string} join Desired character to join each line of code
1412
*/
15-
const CodeBuilder = function (indentation, join) {
13+
var CodeBuilder = function (indentation, join) {
1614
this.code = [];
1715
this.indentation = indentation;
1816
this.lineJoin = join || "\n";
@@ -38,8 +36,8 @@ const CodeBuilder = function (indentation, join) {
3836
* // returns: 'console.log("\t\thello world")'
3937
*/
4038
CodeBuilder.prototype.buildLine = function (indentationLevel, line) {
41-
let lineIndentation = "";
42-
let slice = 2;
39+
var lineIndentation = "";
40+
var slice = 2;
4341
if (Object.prototype.toString.call(indentationLevel) === "[object String]") {
4442
slice = 1;
4543
line = indentationLevel;
@@ -53,9 +51,8 @@ CodeBuilder.prototype.buildLine = function (indentationLevel, line) {
5351
indentationLevel--;
5452
}
5553

56-
const format = Array.prototype.slice.call(arguments, slice, arguments.length);
54+
var format = Array.prototype.slice.call(arguments, slice, arguments.length);
5755
format.unshift(lineIndentation + line);
58-
5956
return util.format.apply(this, format);
6057
};
6158

@@ -101,12 +98,4 @@ CodeBuilder.prototype.join = function () {
10198
return this.code.join(this.lineJoin);
10299
};
103100

104-
CodeBuilder.prototype.clone = function () {
105-
return cloneDeep(this);
106-
};
107-
108-
CodeBuilder.prototype.getLength = function () {
109-
return this.code.length;
110-
};
111-
112101
module.exports = CodeBuilder;

src/helpers/reducer.js

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
'use strict'
1+
"use strict";
22

33
module.exports = function (obj, pair) {
44
if (obj[pair.name] === undefined) {
5-
obj[pair.name] = pair.value
6-
return obj
7-
}
8-
9-
// If we already have it as array just push the value
10-
if (obj[pair.name] instanceof Array) {
11-
obj[pair.name].push(pair.value)
12-
return obj
5+
obj[pair.name] = pair.value;
6+
return obj;
137
}
148

159
// convert to array
16-
const arr = [
17-
obj[pair.name],
18-
pair.value
19-
]
10+
var arr = [obj[pair.name], pair.value];
2011

21-
obj[pair.name] = arr
12+
obj[pair.name] = arr;
2213

23-
return obj
24-
}
14+
return obj;
15+
};

src/helpers/shell.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
'use strict'
2-
3-
const util = require('util')
1+
/* eslint-disable no-useless-escape */
2+
"use strict";
43

54
module.exports = {
65
/**
@@ -9,17 +8,17 @@ module.exports = {
98
* http://wiki.bash-hackers.org/syntax/quoting#strong_quoting
109
*/
1110
quote: function (value) {
12-
const safe = /^[a-z0-9-_/.@%^=:]+$/i
11+
var safe = /^[a-z0-9-_/.@%^=:]+$/i;
1312

1413
// Unless `value` is a simple shell-safe string, quote it.
1514
if (!safe.test(value)) {
16-
return util.format('\'%s\'', value.replace(/'/g, "'\\''"))
15+
return "'" + value.replace(/'/g, "'\\''") + "'";
1716
}
1817

19-
return value
18+
return value;
2019
},
2120

2221
escape: function (value) {
23-
return value.replace(/\r/g, '\\r').replace(/\n/g, '\\n')
24-
}
25-
}
22+
return value.replace(/\r/g, "\\r").replace(/\n/g, "\\n");
23+
},
24+
};

0 commit comments

Comments
 (0)