From 78880d97b0a0b3ab3eea66f0dbc76fb5fc79f500 Mon Sep 17 00:00:00 2001
From: Yadd <yadd@debian.org>
Date: Tue, 12 Apr 2022 18:46:34 +0200
Subject: [PATCH] New upstream version 2.0.0+~1.8.2

---
 HISTORY.md                     |  15 ++++
 README.md                      |   4 +-
 index.js                       |  40 ++++------
 package.json                   |  13 ++--
 scripts/version-history.js     |  63 +++++++++++++++
 test/test.js                   |   8 +-
 types-http-errors/README.md    |   2 +-
 types-http-errors/index.d.ts   | 135 ++++++++++++---------------------
 types-http-errors/package.json |   6 +-
 9 files changed, 157 insertions(+), 129 deletions(-)
 create mode 100644 scripts/version-history.js

diff --git a/HISTORY.md b/HISTORY.md
index fd802a5..7228684 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -1,3 +1,18 @@
+2.0.0 / 2021-12-17
+==================
+
+  * Drop support for Node.js 0.6
+  * Remove `I'mateapot` export; use `ImATeapot` instead
+  * Remove support for status being non-first argument
+  * Rename `UnorderedCollection` constructor to `TooEarly`
+  * deps: depd@2.0.0
+    - Replace internal `eval` usage with `Function` constructor
+    - Use instance methods on `process` to check for listeners
+  * deps: statuses@2.0.1
+    - Fix messaging casing of `418 I'm a Teapot`
+    - Remove code 306
+    - Rename `425 Unordered Collection` to standard `425 Too Early`
+
 2021-11-14 / 1.8.1
 ==================
 
diff --git a/README.md b/README.md
index 42251a3..a8b7330 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ This is a [Node.js](https://nodejs.org/en/) module available through the
 [npm registry](https://www.npmjs.com/). Installation is done using the
 [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
 
-```bash
+```console
 $ npm install http-errors
 ```
 
@@ -133,7 +133,7 @@ var err = new createError.NotFound()
 |422        |UnprocessableEntity          |
 |423        |Locked                       |
 |424        |FailedDependency             |
-|425        |UnorderedCollection          |
+|425        |TooEarly                     |
 |426        |UpgradeRequired              |
 |428        |PreconditionRequired         |
 |429        |TooManyRequests              |
diff --git a/index.js b/index.js
index 1a88029..c425f1e 100644
--- a/index.js
+++ b/index.js
@@ -54,24 +54,18 @@ function createError () {
   var props = {}
   for (var i = 0; i < arguments.length; i++) {
     var arg = arguments[i]
-    if (arg instanceof Error) {
+    var type = typeof arg
+    if (type === 'object' && arg instanceof Error) {
       err = arg
       status = err.status || err.statusCode || status
-      continue
-    }
-    switch (typeof arg) {
-      case 'string':
-        msg = arg
-        break
-      case 'number':
-        status = arg
-        if (i !== 0) {
-          deprecate('non-first-argument status code; replace with createError(' + arg + ', ...)')
-        }
-        break
-      case 'object':
-        props = arg
-        break
+    } else if (type === 'number' && i === 0) {
+      status = arg
+    } else if (type === 'string') {
+      msg = arg
+    } else if (type === 'object') {
+      props = arg
+    } else {
+      throw new TypeError('argument #' + (i + 1) + ' unsupported type ' + type)
     }
   }
 
@@ -80,7 +74,7 @@ function createError () {
   }
 
   if (typeof status !== 'number' ||
-    (!statuses[status] && (status < 400 || status >= 600))) {
+    (!statuses.message[status] && (status < 400 || status >= 600))) {
     status = 500
   }
 
@@ -91,7 +85,7 @@ function createError () {
     // create error
     err = HttpError
       ? new HttpError(msg)
-      : new Error(msg || statuses[status])
+      : new Error(msg || statuses.message[status])
     Error.captureStackTrace(err, createError)
   }
 
@@ -135,7 +129,7 @@ function createClientErrorConstructor (HttpError, name, code) {
 
   function ClientError (message) {
     // create the error object
-    var msg = message != null ? message : statuses[code]
+    var msg = message != null ? message : statuses.message[code]
     var err = new Error(msg)
 
     // capture a stack trace to the construction point
@@ -204,7 +198,7 @@ function createServerErrorConstructor (HttpError, name, code) {
 
   function ServerError (message) {
     // create the error object
-    var msg = message != null ? message : statuses[code]
+    var msg = message != null ? message : statuses.message[code]
     var err = new Error(msg)
 
     // capture a stack trace to the construction point
@@ -264,7 +258,7 @@ function nameFunc (func, name) {
 function populateConstructorExports (exports, codes, HttpError) {
   codes.forEach(function forEachCode (code) {
     var CodeError
-    var name = toIdentifier(statuses[code])
+    var name = toIdentifier(statuses.message[code])
 
     switch (codeClass(code)) {
       case 400:
@@ -281,10 +275,6 @@ function populateConstructorExports (exports, codes, HttpError) {
       exports[name] = CodeError
     }
   })
-
-  // backwards-compatibility
-  exports["I'mateapot"] = deprecate.function(exports.ImATeapot,
-    '"I\'mateapot"; use "ImATeapot" instead')
 }
 
 /**
diff --git a/package.json b/package.json
index df52507..4cb6d7e 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "http-errors",
   "description": "Create HTTP error objects",
-  "version": "1.8.1",
+  "version": "2.0.0",
   "author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)",
   "contributors": [
     "Alan Plum <me@pluma.io>",
@@ -10,10 +10,10 @@
   "license": "MIT",
   "repository": "jshttp/http-errors",
   "dependencies": {
-    "depd": "~1.1.2",
+    "depd": "2.0.0",
     "inherits": "2.0.4",
     "setprototypeof": "1.2.0",
-    "statuses": ">= 1.5.0 < 2",
+    "statuses": "2.0.1",
     "toidentifier": "1.0.1"
   },
   "devDependencies": {
@@ -22,19 +22,20 @@
     "eslint-plugin-import": "2.25.3",
     "eslint-plugin-markdown": "2.2.1",
     "eslint-plugin-node": "11.1.0",
-    "eslint-plugin-promise": "5.1.1",
+    "eslint-plugin-promise": "5.2.0",
     "eslint-plugin-standard": "4.1.0",
     "mocha": "9.1.3",
     "nyc": "15.1.0"
   },
   "engines": {
-    "node": ">= 0.6"
+    "node": ">= 0.8"
   },
   "scripts": {
     "lint": "eslint . && node ./scripts/lint-readme-list.js",
     "test": "mocha --reporter spec --bail",
     "test-ci": "nyc --reporter=lcov --reporter=text npm test",
-    "test-cov": "nyc --reporter=html --reporter=text npm test"
+    "test-cov": "nyc --reporter=html --reporter=text npm test",
+    "version": "node scripts/version-history.js && git add HISTORY.md"
   },
   "keywords": [
     "http",
diff --git a/scripts/version-history.js b/scripts/version-history.js
new file mode 100644
index 0000000..c58268a
--- /dev/null
+++ b/scripts/version-history.js
@@ -0,0 +1,63 @@
+'use strict'
+
+var fs = require('fs')
+var path = require('path')
+
+var HISTORY_FILE_PATH = path.join(__dirname, '..', 'HISTORY.md')
+var MD_HEADER_REGEXP = /^====*$/
+var VERSION = process.env.npm_package_version
+var VERSION_PLACEHOLDER_REGEXP = /^(?:unreleased|(\d+\.)+x)$/
+
+var historyFileLines = fs.readFileSync(HISTORY_FILE_PATH, 'utf-8').split('\n')
+
+if (!MD_HEADER_REGEXP.test(historyFileLines[1])) {
+  console.error('Missing header in HISTORY.md')
+  process.exit(1)
+}
+
+if (!VERSION_PLACEHOLDER_REGEXP.test(historyFileLines[0])) {
+  console.error('Missing placeholder version in HISTORY.md')
+  process.exit(1)
+}
+
+if (historyFileLines[0].indexOf('x') !== -1) {
+  var versionCheckRegExp = new RegExp('^' + historyFileLines[0].replace('x', '.+') + '$')
+
+  if (!versionCheckRegExp.test(VERSION)) {
+    console.error('Version %s does not match placeholder %s', VERSION, historyFileLines[0])
+    process.exit(1)
+  }
+}
+
+historyFileLines[0] = VERSION + ' / ' + getLocaleDate()
+historyFileLines[1] = repeat('=', historyFileLines[0].length)
+
+fs.writeFileSync(HISTORY_FILE_PATH, historyFileLines.join('\n'))
+
+function getLocaleDate () {
+  var now = new Date()
+
+  return zeroPad(now.getFullYear(), 4) + '-' +
+    zeroPad(now.getMonth() + 1, 2) + '-' +
+    zeroPad(now.getDate(), 2)
+}
+
+function repeat (str, length) {
+  var out = ''
+
+  for (var i = 0; i < length; i++) {
+    out += str
+  }
+
+  return out
+}
+
+function zeroPad (number, length) {
+  var num = number.toString()
+
+  while (num.length < length) {
+    num = '0' + num
+  }
+
+  return num
+}
diff --git a/test/test.js b/test/test.js
index eaf4e96..0059d01 100644
--- a/test/test.js
+++ b/test/test.js
@@ -226,11 +226,9 @@ describe('HTTP Errors', function () {
   })
 
   it('createError(msg, status)', function () {
-    var err = createError('LOL', 404)
-    assert.strictEqual(err.name, 'NotFoundError')
-    assert.strictEqual(err.message, 'LOL')
-    assert.strictEqual(err.status, 404)
-    assert.strictEqual(err.statusCode, 404)
+    assert.throws(function () {
+      createError('LOL', 404)
+    }, /argument #2 unsupported type number/)
   })
 
   it('createError(msg)', function () {
diff --git a/types-http-errors/README.md b/types-http-errors/README.md
index 8b7b3b1..007d209 100755
--- a/types-http-errors/README.md
+++ b/types-http-errors/README.md
@@ -8,7 +8,7 @@ This package contains type definitions for http-errors (https://github.com/jshtt
 Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/http-errors.
 
 ### Additional Details
- * Last updated: Tue, 06 Jul 2021 21:33:36 GMT
+ * Last updated: Thu, 13 Jan 2022 20:01:39 GMT
  * Dependencies: none
  * Global values: none
 
diff --git a/types-http-errors/index.d.ts b/types-http-errors/index.d.ts
index 84c95f1..cc2cb13 100755
--- a/types-http-errors/index.d.ts
+++ b/types-http-errors/index.d.ts
@@ -12,9 +12,9 @@ declare const createHttpError: createHttpError.CreateHttpError & createHttpError
 };
 
 declare namespace createHttpError {
-    interface HttpError extends Error {
-        status: number;
-        statusCode: number;
+    interface HttpError<N extends number = number> extends Error {
+        status: N;
+        statusCode: N;
         expose: boolean;
         headers?: {
             [key: string]: string;
@@ -24,95 +24,56 @@ declare namespace createHttpError {
 
     type UnknownError = Error | string | number | { [key: string]: any };
 
-    type HttpErrorConstructor = new (msg?: string) => HttpError;
+    type HttpErrorConstructor<N extends number = number> = new (msg?: string) => HttpError<N>;
 
-    type CreateHttpError = (...args: UnknownError[]) => HttpError;
+    type CreateHttpError = <N extends UnknownError>(arg: N, ...rest: UnknownError[]) => HttpError<N extends number ? N : number>;
 
     type IsHttpError = (error: unknown) => error is HttpError;
 
     type NamedConstructors = {
         [code: string]: HttpErrorConstructor;
         HttpError: HttpErrorConstructor;
-    } & Record<'BadRequest' |
-        'Unauthorized' |
-        'PaymentRequired' |
-        'Forbidden' |
-        'NotFound' |
-        'MethodNotAllowed' |
-        'NotAcceptable' |
-        'ProxyAuthenticationRequired' |
-        'RequestTimeout' |
-        'Conflict' |
-        'Gone' |
-        'LengthRequired' |
-        'PreconditionFailed' |
-        'PayloadTooLarge' |
-        'URITooLong' |
-        'UnsupportedMediaType' |
-        'RangeNotSatisfiable' |
-        'ExpectationFailed' |
-        'ImATeapot' |
-        'MisdirectedRequest' |
-        'UnprocessableEntity' |
-        'Locked' |
-        'FailedDependency' |
-        'UnorderedCollection' |
-        'UpgradeRequired' |
-        'PreconditionRequired' |
-        'TooManyRequests' |
-        'RequestHeaderFieldsTooLarge' |
-        'UnavailableForLegalReasons' |
-        'InternalServerError' |
-        'NotImplemented' |
-        'BadGateway' |
-        'ServiceUnavailable' |
-        'GatewayTimeout' |
-        'HTTPVersionNotSupported' |
-        'VariantAlsoNegotiates' |
-        'InsufficientStorage' |
-        'LoopDetected' |
-        'BandwidthLimitExceeded' |
-        'NotExtended' |
-        'NetworkAuthenticationRequire' |
-        '400' |
-        '401' |
-        '402' |
-        '403' |
-        '404' |
-        '405' |
-        '406' |
-        '407' |
-        '408' |
-        '409' |
-        '410' |
-        '411' |
-        '412' |
-        '413' |
-        '414' |
-        '415' |
-        '416' |
-        '417' |
-        '418' |
-        '421' |
-        '422' |
-        '423' |
-        '424' |
-        '425' |
-        '426' |
-        '428' |
-        '429' |
-        '431' |
-        '451' |
-        '500' |
-        '501' |
-        '502' |
-        '503' |
-        '504' |
-        '505' |
-        '506' |
-        '507' |
-        '508' |
-        '509' |
-        '510' |
-        '511', HttpErrorConstructor>;
+    }
+    & Record<'BadRequest' | '400', HttpErrorConstructor<400>>
+    & Record<'Unauthorized' | '401', HttpErrorConstructor<401>>
+    & Record<'PaymentRequired' | '402', HttpErrorConstructor<402>>
+    & Record<'Forbidden' | '403', HttpErrorConstructor<403>>
+    & Record<'NotFound' | '404', HttpErrorConstructor<404>>
+    & Record<'MethodNotAllowed' | '405', HttpErrorConstructor<405>>
+    & Record<'NotAcceptable' | '406', HttpErrorConstructor<406>>
+    & Record<'ProxyAuthenticationRequired' | '407', HttpErrorConstructor<407>>
+    & Record<'RequestTimeout' | '408', HttpErrorConstructor<408>>
+    & Record<'Conflict' | '409', HttpErrorConstructor<409>>
+    & Record<'Gone' | '410', HttpErrorConstructor<410>>
+    & Record<'LengthRequired' | '411', HttpErrorConstructor<411>>
+    & Record<'PreconditionFailed' | '412', HttpErrorConstructor<412>>
+    & Record<'PayloadTooLarge' | '413', HttpErrorConstructor<413>>
+    & Record<'URITooLong' | '414', HttpErrorConstructor<414>>
+    & Record<'UnsupportedMediaType' | '415', HttpErrorConstructor<415>>
+    & Record<'RangeNotSatisfiable' | '416', HttpErrorConstructor<416>>
+    & Record<'ExpectationFailed' | '417', HttpErrorConstructor<417>>
+    & Record<'ImATeapot' | '418', HttpErrorConstructor<418>>
+    & Record<'MisdirectedRequest' | '421', HttpErrorConstructor<421>>
+    & Record<'UnprocessableEntity' | '422', HttpErrorConstructor<422>>
+    & Record<'Locked' | '423', HttpErrorConstructor<423>>
+    & Record<'FailedDependency' | '424', HttpErrorConstructor<424>>
+    & Record<'UnorderedCollection' | '425', HttpErrorConstructor<425>>
+    & Record<'UpgradeRequired' | '426', HttpErrorConstructor<426>>
+    & Record<'PreconditionRequired' | '428', HttpErrorConstructor<428>>
+    & Record<'TooManyRequests' | '429', HttpErrorConstructor<429>>
+    & Record<'RequestHeaderFieldsTooLarge' | '431', HttpErrorConstructor<431>>
+    & Record<'UnavailableForLegalReasons' | '451', HttpErrorConstructor<451>>
+    & Record<'InternalServerError' | '500', HttpErrorConstructor<500>>
+    & Record<'NotImplemented' | '501', HttpErrorConstructor<501>>
+    & Record<'BadGateway' | '502', HttpErrorConstructor<502>>
+    & Record<'ServiceUnavailable' | '503', HttpErrorConstructor<500>>
+    & Record<'GatewayTimeout' | '504', HttpErrorConstructor<504>>
+    & Record<'HTTPVersionNotSupported' | '505', HttpErrorConstructor<505>>
+    & Record<'VariantAlsoNegotiates' | '506', HttpErrorConstructor<506>>
+    & Record<'InsufficientStorage' | '507', HttpErrorConstructor<507>>
+    & Record<'LoopDetected' | '508', HttpErrorConstructor<508>>
+    & Record<'BandwidthLimitExceeded' | '509', HttpErrorConstructor<509>>
+    & Record<'NotExtended' | '510', HttpErrorConstructor<510>>
+    & Record<'NetworkAuthenticationRequire' | '511', HttpErrorConstructor<511>>
+    ;
 }
diff --git a/types-http-errors/package.json b/types-http-errors/package.json
index 0c35404..fef80e3 100755
--- a/types-http-errors/package.json
+++ b/types-http-errors/package.json
@@ -1,6 +1,6 @@
 {
     "name": "@types/http-errors",
-    "version": "1.8.1",
+    "version": "1.8.2",
     "description": "TypeScript definitions for http-errors",
     "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/http-errors",
     "license": "MIT",
@@ -25,6 +25,6 @@
     },
     "scripts": {},
     "dependencies": {},
-    "typesPublisherContentHash": "b19a9052d35058a24569cde965e62a59db1ef8d456381598978c2d65370c634b",
-    "typeScriptVersion": "3.6"
+    "typesPublisherContentHash": "c2479b8b9d3c81b8d5e05a4e9af2847027b1274dadcdd92a5468f98c98449978",
+    "typeScriptVersion": "3.8"
 }
\ No newline at end of file
-- 
GitLab