Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/kd_clients/core/Utils.ts>Utils

Various HTTP clients for miscellaneous use.
Latest
class Utils
import { Utils } from "https://deno.land/x/kd_clients@v1.0.0-preview.13/core/Utils.ts";

Provides utility functions.

Static Properties

private
readonly
prevVersionRegex: RegExp
private
readonly
prodVersionRegex: RegExp

Static Methods

buildLabelsUrl(ownerName: string, repoName: string): string

Builds a URL to the labels page of a repository with a name that matches the given repoName and is owned by the given ownerName.

buildPullRequestUrl(
ownerName: string,
repoName: string,
prNumber: number,
): string

Builds a URL to a pull request that matches the given prNumber in a repository with a name that matches the given repoName and is owned by the given ownerName.

clamp(
value: number,
min: number,
max: number,
): number

Returns a number that is clamped between the given min and max values.

invalidReleaseType(value: unknown): value is ReleaseType

Returns a value indicating whether or not the given value is a valid release type.

isDirPath(path: string): boolean

Returns a value indicating whether or not the given path is a directory path.

isFilePath(path: string): boolean

Returns a value indicating whether or not the given value is a file path.

isIssue(issueOrPr: unknown): issueOrPr is IssueModel

Returns a value indicating whether or not the given issueOrPr is an issue.

isNotDirPath(path: string): boolean

Returns a value indicating whether or not the given path is not a directory path.

isNotFilePath(path: string): boolean

Returns a value indicating whether or not the given value is not a file path.

isNothing<T>(value: unknown): value is
| undefined
| null
| ""
| number
| T[]
| (() => T)

Checks if the value is null, undefined, or empty.

isNotValidPreviewVersion(version: string): boolean

Checks if the given version is not a valid preview version.

isNotValidProdVersion(version: string): boolean

Checks if the given version is not valid production version.

isNumber(value: unknown): value is number

Returns a value indicating if the given value is a number.

isPr(issueOrPr: unknown): issueOrPr is PullRequestModel

Returns a value indicating whether or not the given issueOrPr is a pull request.

isPreviewRelease(value: unknown): value is ReleaseType

Returns a value indicating whether or not the given value is a valid preview release type.

isProductionRelease(value: unknown): value is ReleaseType

Returns a value indicating whether or not the given value is a valid production release type.

isString(value: unknown): value is string

Returns a value indicating if the given value is a string.

normalizePath(path: string): string

Normalizes the given path by replacing all back slashes with forward slashes, and trimming any and ending slashes.

Prints an empty line to the console.

printError(message: string): void

Prints the given message as a error.

splitBy(value: string, separator: string): string[]

Splits the given value by the given separator.

splitByComma(value: string): string[]

Splits the given value by comma.

toErrorMessage(mainMsg: string, requestResponse: GraphQlRequestResponseModel): string

Combines the given mainMsg and requestResponse error messages into one error message.

trimAllEndingValue(valueToTrim: string, valueToRemove: string): string

Trims the given valueToRemove from the end of the given valueToTrim until the valueToRemove does not exit anymore.

trimAllStartingValue(valueToTrim: string, valueToRemove: string): string

Trims the given valueToRemove from the start of the given valueToTrim until the valueToRemove does not exit anymore.

validPreviewVersion(version: string): boolean

Checks if the given version is a valid preview version.

validProdVersion(version: string): boolean

Checks if the given version is a valid production version.