Skip to content

Commit 714e3e6

Browse files
committed
Splice array to add POST or GET argument into httpDo call
1 parent d007bbc commit 714e3e6

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/io/files.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -792,12 +792,8 @@ p5.prototype.selectInput = function () {
792792
* in as first argument
793793
*/
794794
p5.prototype.httpGet = function () {
795-
var args = new Array(arguments.length);
796-
args[0] = arguments[0];
797-
args[1] = 'GET';
798-
for (var i = 1; i < arguments.length; ++i) {
799-
args[i+1] = arguments[i];
800-
}
795+
var args = Array.prototype.slice.call(arguments);
796+
args.splice(1, 0, 'GET');
801797
p5.prototype.httpDo.apply(this, args);
802798
};
803799

@@ -818,12 +814,8 @@ p5.prototype.httpGet = function () {
818814
* in as first argument
819815
*/
820816
p5.prototype.httpPost = function () {
821-
var args = new Array(arguments.length);
822-
args[0] = arguments[0];
823-
args[1] = 'POST';
824-
for (var i = 1; i < arguments.length; ++i) {
825-
args[i+1] = arguments[i];
826-
}
817+
var args = Array.prototype.slice.call(arguments);
818+
args.splice(1, 0, 'POST');
827819
p5.prototype.httpDo.apply(this, args);
828820
};
829821

0 commit comments

Comments
 (0)