From f9b8d77f20fdd6ba992d061c7ebbe9f2c2580b07 Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Mon, 21 Oct 2024 23:41:40 +0200 Subject: [PATCH] Replace `methods` dependency with standard library Signed-off-by: Jon Koops --- HISTORY.md | 5 +++++ lib/route.js | 5 ++++- package.json | 1 - 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index ad7f247..254f434 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +unreleased +========================= + +* Replace `methods` dependency with standard library + 2.0.0 / 2024-09-09 ================== diff --git a/lib/route.js b/lib/route.js index c9c53e7..e6079e5 100644 --- a/lib/route.js +++ b/lib/route.js @@ -14,7 +14,7 @@ const flatten = require('array-flatten').flatten const Layer = require('./layer') -const methods = require('methods') +const { METHODS } = require('node:http') /** * Module variables. @@ -215,6 +215,9 @@ Route.prototype.all = function all (handler) { return this } + +const methods = METHODS.map((method) => method.toLowerCase()) + methods.forEach(function (method) { Route.prototype[method] = function (handler) { const callbacks = flatten(slice.call(arguments)) diff --git a/package.json b/package.json index c118ec6..76b41fb 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "dependencies": { "array-flatten": "3.0.0", "is-promise": "4.0.0", - "methods": "~1.1.2", "parseurl": "~1.3.3", "path-to-regexp": "^8.0.0", "setprototypeof": "1.2.0",