summaryrefslogtreecommitdiff
path: root/cli/bench/testdata/npm/hono/dist/request.js
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2022-08-19 15:54:54 +0530
committerGitHub <noreply@github.com>2022-08-19 15:54:54 +0530
commit25a109d9ea27ad3a76fdce14bba283e953af9bce (patch)
tree68f0280065c9df4be8fa325ba82693879b4b46cd /cli/bench/testdata/npm/hono/dist/request.js
parent9e576dff7c39cfd510c60ba92aa0d1c15fd24a6b (diff)
chore(bench): add flash router benchmarks (#15495)
Diffstat (limited to 'cli/bench/testdata/npm/hono/dist/request.js')
-rw-r--r--cli/bench/testdata/npm/hono/dist/request.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/cli/bench/testdata/npm/hono/dist/request.js b/cli/bench/testdata/npm/hono/dist/request.js
new file mode 100644
index 000000000..fb900d743
--- /dev/null
+++ b/cli/bench/testdata/npm/hono/dist/request.js
@@ -0,0 +1,78 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.extendRequestPrototype = void 0;
+const body_1 = require("./utils/body");
+const cookie_1 = require("./utils/cookie");
+function extendRequestPrototype() {
+ if (!!Request.prototype.param) {
+ // already extended
+ return;
+ }
+ Request.prototype.param = function (key) {
+ if (this.paramData) {
+ if (key) {
+ return this.paramData[key];
+ }
+ else {
+ return this.paramData;
+ }
+ }
+ return null;
+ };
+ Request.prototype.header = function (name) {
+ if (name) {
+ return this.headers.get(name);
+ }
+ else {
+ const result = {};
+ for (const [key, value] of this.headers) {
+ result[key] = value;
+ }
+ return result;
+ }
+ };
+ Request.prototype.query = function (key) {
+ const url = new URL(this.url);
+ if (key) {
+ return url.searchParams.get(key);
+ }
+ else {
+ const result = {};
+ for (const key of url.searchParams.keys()) {
+ result[key] = url.searchParams.get(key) || '';
+ }
+ return result;
+ }
+ };
+ Request.prototype.queries = function (key) {
+ const url = new URL(this.url);
+ if (key) {
+ return url.searchParams.getAll(key);
+ }
+ else {
+ const result = {};
+ for (const key of url.searchParams.keys()) {
+ result[key] = url.searchParams.getAll(key);
+ }
+ return result;
+ }
+ };
+ Request.prototype.cookie = function (key) {
+ const cookie = this.headers.get('Cookie') || '';
+ const obj = (0, cookie_1.parse)(cookie);
+ if (key) {
+ const value = obj[key];
+ return value;
+ }
+ else {
+ return obj;
+ }
+ };
+ Request.prototype.parseBody = function () {
+ if (!this.parsedBody) {
+ this.parsedBody = (0, body_1.parseBody)(this);
+ }
+ return this.parsedBody;
+ };
+}
+exports.extendRequestPrototype = extendRequestPrototype;