npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hexxag0nal/utils

v0.6.0

Published

A handy collection of utilities.

Downloads

6

Readme

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:

Name | Type | ------ | ------ | array1 | ArrayLike‹T› | array2 | ArrayLike‹T› | ...moreArrays | Array‹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:

Name | Type | Default | Description | ------ | ------ | ------ | ------ | imageData | Uint8ClampedArray | - | Uint8ClampedArray containing an image's pixel data in either RGBA or RGB | width | number | - | The width of the image | height | number | - | 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:

Name | Type | Default | Description | ------ | ------ | ------ | ------ | imageData | Uint8ClampedArray | - | Uint8ClampedArray containing an image's pixel data in either RGBA or RGB | width | number | - | The width of the image | height | number | - | 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:

Name | Type | Description | ------ | ------ | ------ | outerArray | Array‹T› | The array that is tested if it contains the other one | innerArray | Array‹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:

Name | Type | ------ | ------ | ...values | any[] |

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:

Name | Type | Description | ------ | ------ | ------ | blob | Blob | The 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:

Name | Type | ------ | ------ | file | Blob |

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:

Name | Type | Description | ------ | ------ | ------ | ...subscriptions | Subscription[] | 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:

Name | Type | Description | ------ | ------ | ------ | data | Blob | string | The file that is being saved | filename? | string | The name if the file | options? | FileSaverOptions | Some 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:

Name | Type | ------ | ------ | variable | S | value | S | 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:

Name | Type | Description | ------ | ------ | ------ | value | T | The value that shall be checked |

Returns: T | null