0.6.0 • Published 5 years ago

@hexxag0nal/utils v0.6.0

Weekly downloads
66
License
CC-BY-SA-4.0
Repository
-
Last release
5 years ago

Utils

A handy collection of utilities.

Module: "utils"

Index

Classes

Type aliases

Type aliases

Constructable

Ƭ Constructable: object

Defined in utils.ts:303

Basically telling that an object can be constructed via the 'new' keyword

Type declaration:


Percentage

Ƭ Percentage: number

Defined in utils.ts:296

Basically telling that the number is expected to resemble some kind of percentage

Class: Utils

Hierarchy

  • Utils

Index

Methods

Methods

Static areSimilarArrays

areSimilarArraysT›(array1: ArrayLike‹T›, array2: ArrayLike‹T›, ...moreArrays: Array‹ArrayLike‹T››): boolean

Defined in utils.ts:74

Checks two or more given array for equality regarding their values

Type parameters:

T

Parameters:

NameType
array1ArrayLike‹T›
array2ArrayLike‹T›
...moreArraysArray‹ArrayLike‹T››

Returns: boolean


Static binaryImageDataToDataUrl

binaryImageDataToDataUrl(imageData: Uint8ClampedArray, width: number, height: number, format: "RGBA" | "RGB" | "AUTODETECT"): DataUrl

Defined in utils.ts:148

Turns a Uint8ClampedArray containing an image's pixel data into a DataUrl object

Parameters:

NameTypeDefaultDescription
imageDataUint8ClampedArray-Uint8ClampedArray containing an image's pixel data in either RGBA or RGB
widthnumber-The width of the image
heightnumber-The height of the image
format"RGBA" | "RGB" | "AUTODETECT""AUTODETECT"The format the binary data is provided. Can autodetect between RGB and RGBA, but will try RGBA first

Returns: DataUrl


Static binaryToImageData

binaryToImageData(imageData: Uint8ClampedArray, width: number, height: number, format: "RGBA" | "RGB" | "AUTODETECT"): ImageData

Defined in utils.ts:172

Turns a Uint8ClampedArray containing an image's pixel data into an object of type ImageData

Parameters:

NameTypeDefaultDescription
imageDataUint8ClampedArray-Uint8ClampedArray containing an image's pixel data in either RGBA or RGB
widthnumber-The width of the image
heightnumber-The height of the image
format"RGBA" | "RGB" | "AUTODETECT""AUTODETECT"The format the binary data is provided. Can autodetect between RGB and RGBA, but will try RGBA first

Returns: ImageData


Static isInArray

isInArrayT›(outerArray: Array‹T›, innerArray: Array‹T›): number

Defined in utils.ts:115

Checks whether the inner array is completely contained within the outer array. If it is, it returns the index where the inner array starts in the outer one. If it is NOT contained, it return -1

Type parameters:

T

Parameters:

NameTypeDescription
outerArrayArray‹T›The array that is tested if it contains the other one
innerArrayArray‹T›The array that is tested if it is contained within the other one

Returns: number

If inner is in outer, it returns the index where the inner array starts in the outer one. If it is NOT contained, it returns -1


Static isNullOrUndefined

isNullOrUndefined(...values: any[]): boolean

Defined in utils.ts:23

Checks if a value is null or undefined

Parameters:

NameType
...valuesany[]

Returns: boolean


Static readBlobAsDataUrl

readBlobAsDataUrl(blob: Blob): Promise‹DataUrl›

Defined in utils.ts:48

This function wraps the file reader into a promise such that it can be used with async/await

Parameters:

NameTypeDescription
blobBlobThe blob that shall be read as a data url

Returns: Promise‹DataUrl›


Static readFileAsDataUrl

readFileAsDataUrl(file: Blob): Promise‹DataUrl›

Defined in utils.ts:67

Just an alias for readBlobAsDataUrl()

Parameters:

NameType
fileBlob

Returns: Promise‹DataUrl›


Static safeUnsubscribe

safeUnsubscribe(...subscriptions: Subscription[]): void

Defined in utils.ts:281

Safely unsubscribe from rxjs' Subscriptions. If it is not set, the unsubscribe() method will not be called. Supports array of subscriptions or infinitely many subscriptions as direct arguments

Parameters:

NameTypeDescription
...subscriptionsSubscription[]The subscription(s) that are/is to be unsubscribed from

Returns: void


Static saveAs

saveAs(data: Blob | string, filename?: string, options?: FileSaverOptions): Promise‹void›

Defined in utils.ts:272

Open the browser's save file dialog

Parameters:

NameTypeDescription
dataBlob | stringThe file that is being saved
filename?stringThe name if the file
options?FileSaverOptionsSome further options

Returns: Promise‹void›


Static setOnlyOnce

setOnlyOnceS›(variable: S, value: S, errorMessage?: string): void

Defined in utils.ts:12

Set variable. If already set, an error is thrown.

Type parameters:

S

Parameters:

NameType
variableS
valueS
errorMessage?string

Returns: void


Static thisOrNull

thisOrNullT›(value: T): T | null

Defined in utils.ts:36

If the given value is not null or undefined, it will be returned without modification. If it is null or undefined, null is returned

Type parameters:

T

Parameters:

NameTypeDescription
valueTThe value that shall be checked

Returns: T | null

0.6.0

5 years ago

0.5.1

5 years ago

0.4.9

5 years ago

0.5.0

5 years ago

0.4.8

5 years ago

0.4.7

5 years ago

0.4.6

5 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.3.0

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago