Skip to content

Commit

Permalink
fix(utils): update jsdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
PunGrumpy committed Nov 6, 2023
1 parent db77b0a commit 8cab996
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logixlysia",
"version": "0.0.2-alpha.2.3",
"version": "0.0.2-alpha.2.4",
"description": "🪵 Logixlysia is a logger for Elysia",
"type": "module",
"module": "src/index.ts",
Expand Down
13 changes: 7 additions & 6 deletions src/utils/duration.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @param {bigint} beforeTime
* @returns {string}
* @description
* Convert the time difference between the start of the request and the end of the request to a string.
* Converts the time difference between the start of the request and the end of the request to a formatted string.
*
* @param {bigint} beforeTime - The timestamp taken before the request.
* @returns {string} - A formatted duration string with a time unit.
* @example
* durationString(123456789n) // => '| 123456789ns'
* durationString(123456789000n) // => '| 123456789µs'
Expand All @@ -14,8 +14,9 @@ function durationString(beforeTime: bigint): string {
const timeDifference = now - beforeTime
const nanoseconds = Number(timeDifference)

const durationInMicroseconds = (nanoseconds / 1e3).toFixed(0) // Convert to microseconds
const durationInMilliseconds = (nanoseconds / 1e6).toFixed(0) // Convert to milliseconds
const durationInMicroseconds = (nanoseconds / 1e3).toFixed(0)
const durationInMilliseconds = (nanoseconds / 1e6).toFixed(0)

let timeMessage: string = ''

if (nanoseconds >= 1e9) {
Expand Down
23 changes: 4 additions & 19 deletions src/utils/method.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as pc from 'picocolors'

/**
* @param {string} method
* @returns {string}
* @description
* Convert the request method to a string.
* Converts an HTTP request method to a colored string representation.
*
* @param {string} method - The HTTP request method (e.g., 'GET', 'POST').
* @returns {string} - A colored string representing the method.
* @example
* methodString('GET') // => 'GET'
* methodString('POST') // => 'POST'
Expand All @@ -19,35 +19,20 @@ import * as pc from 'picocolors'
function methodString(method: string): string {
switch (method) {
case 'GET':
// Handle GET request
return pc.white('GET')

case 'POST':
// Handle POST request
return pc.yellow('POST')

case 'PUT':
// Handle PUT request
return pc.blue('PUT')

case 'DELETE':
// Handle DELETE request
return pc.red('DELETE')

case 'PATCH':
// Handle PATCH request
return pc.green('PATCH')

case 'OPTIONS':
// Handle OPTIONS request
return pc.gray('OPTIONS')

case 'HEAD':
// Handle HEAD request
return pc.magenta('HEAD')

default:
// Handle unknown request method
return method
}
}
Expand Down

0 comments on commit 8cab996

Please sign in to comment.