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

@supercat1337/utils

v1.0.1

Published

Utilities for binding reactive variables to DOM elements and other usefull functions

Downloads

1

Readme

@supercat1337/utilsDocs


@supercat1337/utils

Classes

Type Aliases

Functions

Classes

@supercat1337/utilsDocs


@supercat1337/utils / Chain

Class: Chain

Creates a concurrency chain instance

Export

Chain

Constructors

new Chain()

new Chain(): Chain

Returns

Chain

Properties

#private

private #private: any


completedSuccessfully

completedSuccessfully: object

__#2@#private

__#2@#private: any

name

readonly name: string

store

readonly store: Store

value

value: any

clearSubscribers()
Returns

void

hasSubscribers()
Returns

boolean

setCompareFunction()
Parameters

func_or_null

Returns

boolean

subscribe()
Parameters

callback

debounce_time?: number

Returns

Unsubscriber


isRunning

isRunning: object

__#2@#private

__#2@#private: any

name

readonly name: string

store

readonly store: Store

value

value: any

clearSubscribers()
Returns

void

hasSubscribers()
Returns

boolean

setCompareFunction()
Parameters

func_or_null

Returns

boolean

subscribe()
Parameters

callback

debounce_time?: number

Returns

Unsubscriber


returnValue

returnValue: object

__#2@#private

__#2@#private: any

name

readonly name: string

store

readonly store: Store

value

value: any

clearSubscribers()
Returns

void

hasSubscribers()
Returns

boolean

setCompareFunction()
Parameters

func_or_null

Returns

boolean

subscribe()
Parameters

callback

debounce_time?: number

Returns

Unsubscriber

Accessors

abortController

get abortController(): AbortController

Returns

AbortController


store

get store(): Store

Returns

Store

Methods

cancel()

cancel(): void

Returns

void


complete()

complete(return_value?): void

Parameters

return_value?: any

Returns

void


getCtx()

getCtx(): void

Returns

void


run()

run(ctx?): Promise<any>

Parameters

ctx?

Returns

Promise<any>


then()

then(task): this

Parameters

task: Task

Returns

this

Functions

@supercat1337/utilsDocs


@supercat1337/utils / DOMReady

Function: DOMReady()

DOMReady(callback): void

Execute callback after the DOM is loaded

Parameters

callback

Returns

void

@supercat1337/utilsDocs


@supercat1337/utils / bindToAttr

Function: bindToAttr()

bindToAttr(reactive_item, element, attribute_name, custom_value_converter?, debounce_time?): Unsubscriber

Binds the value of a reactive variable to the element's attribute

Parameters

reactive_item: Atom | Computed

element: HTMLElement

attribute_name: string

custom_value_converter?

debounce_time?: number

Returns

Unsubscriber

@supercat1337/utilsDocs


@supercat1337/utils / bindToCheckboxChecked

Function: bindToCheckboxChecked()

bindToCheckboxChecked(reactive_item, element, debounce_time?): Unsubscriber

Synchronizes the value of a reactive variable to the checkbox's "checked" property and vice versa

Parameters

reactive_item: Atom

element: HTMLInputElement

debounce_time?: number

Returns

Unsubscriber

@supercat1337/utilsDocs


@supercat1337/utils / bindToClass

Function: bindToClass()

bindToClass(reactive_item, element, custom_value_converter?, debounce_time?): Unsubscriber

Binds the value of a reactive variable to the element's "className" property

Parameters

reactive_item: Atom | Computed

element: HTMLElement

custom_value_converter?

debounce_time?: number

Returns

Unsubscriber

@supercat1337/utilsDocs


@supercat1337/utils / bindToDisabled

Function: bindToDisabled()

bindToDisabled(reactive_item, element, custom_value_converter?): Unsubscriber

Binds the value of a reactive variable to the element's "disabled" property

Parameters

reactive_item: Atom | Computed

element: HTMLLinkElement | HTMLInputElement | HTMLButtonElement | HTMLFieldSetElement | HTMLOptGroupElement | HTMLOptionElement | HTMLSelectElement | HTMLStyleElement | HTMLTextAreaElement | SVGStyleElement

custom_value_converter?

Returns

Unsubscriber

@supercat1337/utilsDocs


@supercat1337/utils / bindToHtml

Function: bindToHtml()

bindToHtml(reactive_item, element, custom_value_converter?, debounce_time?): Unsubscriber

Binds the value of a reactive variable to the element's "innerHTML" property

Parameters

reactive_item: Atom | Computed

element: HTMLElement

custom_value_converter?

debounce_time?: number

Returns

Unsubscriber

@supercat1337/utilsDocs


@supercat1337/utils / bindToInputValue

Function: bindToInputValue()

bindToInputValue(reactive_item, element, debounce_time?, lazy?): Unsubscriber

Synchronizes the value of a reactive variable to the input's "value" property and vice versa

Parameters

reactive_item: Atom

element: HTMLInputElement | HTMLTextAreaElement

debounce_time?: number

lazy?: boolean

Returns

Unsubscriber

@supercat1337/utilsDocs


@supercat1337/utils / bindToList

Function: bindToList()

bindToList(reactive_item, list_element, item_value_setter, element_item_creator?): Unsubscriber

Binds the array-value of a reactive collection to the element

Parameters

reactive_item: Collection

list_element: HTMLElement

item_value_setter: TypeItemValueSetter

element_item_creator?: TypeItemCreator

Returns

Unsubscriber

@supercat1337/utilsDocs


@supercat1337/utils / bindToListLength

Function: bindToListLength()

bindToListLength(reactive_item, element, custom_value_converter?, debounce_time?): Unsubscriber

Binds the length of a reactive collection to the element's "innerText" property

Parameters

reactive_item: Collection

element: HTMLElement

custom_value_converter?

debounce_time?: number

Returns

Unsubscriber

@supercat1337/utilsDocs


@supercat1337/utils / bindToProperty

Function: bindToProperty()

bindToProperty(reactive_item, element, property_name, custom_value_converter?, debounce_time?): Unsubscriber

Binds the value of a reactive variable to the element's property

Parameters

reactive_item: Atom | Computed

element: HTMLElement

property_name: string

custom_value_converter?

debounce_time?: number

Returns

Unsubscriber

@supercat1337/utilsDocs


@supercat1337/utils / bindToShow

Function: bindToShow()

bindToShow(reactive_item, element, custom_value_converter?, debounce_time?, hide_class_name?): Unsubscriber

Binds the value of a reactive variable to the element's visibility

Parameters

reactive_item: Atom | Computed

element: HTMLElement

custom_value_converter?

debounce_time?: number

hide_class_name?: string

Returns

Unsubscriber

@supercat1337/utilsDocs


@supercat1337/utils / bindToText

Function: bindToText()

bindToText(reactive_item, element, custom_value_converter?, debounce_time?): Unsubscriber

Binds the value of a reactive variable to the element's "innerText" property

Parameters

reactive_item: Atom | Computed

element: HTMLElement

custom_value_converter?

debounce_time?: number

Returns

Unsubscriber

@supercat1337/utilsDocs


@supercat1337/utils / createSingletonFetch

Function: createSingletonFetch()

createSingletonFetch(): (resource, options?) => Promise<Response>

Returns singleton version of function fetch

Returns

Function

Parameters

resource: RequestInfo | URL

options?: RequestInit

Returns

Promise<Response>

@supercat1337/utilsDocs


@supercat1337/utils / escapeHtml

Function: escapeHtml()

escapeHtml(text): string

Escape string for use in HTML

Parameters

text: string

Returns

string

@supercat1337/utilsDocs


@supercat1337/utils / fetchRetry

Function: fetchRetry()

fetchRetry(url, fetchOptions?, delay?, tries?): Promise<Response>

A version of the fetch function that allows you to specify the number of retries if the connection is lost

Parameters

url: RequestInfo | URL

fetchOptions?: RequestInit

delay?: number

tries?: number

Returns

Promise<Response>

@supercat1337/utilsDocs


@supercat1337/utils / getDiffs

Function: getDiffs()

getDiffs<T>(new_object, old_object, custom_compare_function?): { [key in keyof T]: boolean }

Compares two objects and returns information about their differences

Type parameters

T extends object

Parameters

new_object: T

old_object: any

custom_compare_function?

Returns

{ [key in keyof T]: boolean }

@supercat1337/utilsDocs


@supercat1337/utils / getListItem

Function: getListItem()

getListItem(element, attr_name?): Element

Returns the list item element by child node

Parameters

element: HTMLElement

attr_name?: string

Returns

Element

@supercat1337/utilsDocs


@supercat1337/utils / getListItemIndex

Function: getListItemIndex()

getListItemIndex(element): number

Returns the index of the list item element

Parameters

element: HTMLElement

Returns

number

@supercat1337/utilsDocs


@supercat1337/utils / memoize

Function: memoize()

memoize<T>(func): T

An optimization used to speed up consecutive function calls by caching the result of calls with identical input

Type parameters

T extends (...args) => any

Parameters

func: T

Returns

T

@supercat1337/utilsDocs


@supercat1337/utils / selectRefs

Function: selectRefs()

selectRefs(root_element): object

Returns an object of child elements containing the ref attribute

Parameters

root_element: Node

Returns

object

@supercat1337/utilsDocs


@supercat1337/utils / selectRefsExtended

Function: selectRefsExtended()

selectRefsExtended(root_element): object

Parameters

root_element: Node

Returns

object

refs

refs: object

Index signature

[key: string]: HTMLElement

scopes

scopes: object

Index signature

[key: string]: HTMLElement

@supercat1337/utilsDocs


@supercat1337/utils / walkDomScope

Function: walkDomScope()

walkDomScope(root_element, callback): void

Parameters

root_element: Node

callback

Returns

void

Type Aliases

@supercat1337/utilsDocs


@supercat1337/utils / Task

Type alias: Task()

Task: (previous_result, ctx, chain) => any

Parameters

previous_result: any

ctx

chain: Chain

Returns

any

@supercat1337/utilsDocs


@supercat1337/utils / TypeItemCreator

Type alias: TypeItemCreator()

TypeItemCreator: (item_element?) => HTMLElement

Parameters

item_element?: HTMLElement

Returns

HTMLElement

@supercat1337/utilsDocs


@supercat1337/utils / TypeItemValueSetter

Type alias: TypeItemValueSetter()

TypeItemValueSetter: (item_element, index, value, old_value, length) => void

Parameters

item_element: HTMLElement

index: number

value: any

old_value: any

length: number

Returns

void