@yamato-daiwa/es-extensions-browserjs
TypeScript icon, indicating that this package has built-in type declarations

1.6.6 • Public • Published

@yamato-daiwa/es-extensions-browserjs

No any type No third-party dependencies NPM Version

Additional to @yamato-daiwa/es-extensions functionality for browser environment.

Helper functions and classes aimed to reduce the routine code. Build-in TypeScript type safety without any type.

Installation

npm i @yamato-daiwa/es-extensions-browserjs @yamato-daiwa/es-extensions -E

Documentation

DOM manipulations

cloneDOM_Element
Clones DOM element herewith tells TypeScript that cloned element has same subtype of the Element as initial instance (it is natural, however the TypeScript typing for the Node.cloneNode() has Node as returned value type; it is the TypeScript issue.
createDOM_ElementFromHTML_Code
Creates the DOM element (Element) or it's inheritor from HTML code, herewith it must be exactly one root element.
createHTML_CollectionFromHTML_Code
Creates the HTMLCollection from HTML code passed as parameter.
getExpectedToBeSingleChildOfTemplateElement
Retrieves the child (of Element type or specified subtype) of template element if this child is exactly one, otherwise throws the error.
getExpectedToBeSingleDOM_Element
Retrieves the element corresponding to specified selector if this element presents in single instance inside specific context, otherwise throws the error.

Events handling

addLeftClickEventHandler
Adds on mouse left click event handler. The main difference with native analogues is addLeftClickEventHandler provides the instance of MouseEvent, not generic Event that is critical for TypeScript.
delegateClickEventHandling
Creates just one click event listener while allowing to handle the click of arbitrary large number of elements what is the optimization measures.

Logging

BasicFrontEndLogger
The implementation of ILogger interface for the Logger facade which could be used as the base of the custom implementation for the frontend side of the websites / web application.

Package Sidebar

Install

npm i @yamato-daiwa/es-extensions-browserjs

Weekly Downloads

5

Version

1.6.6

License

MIT

Unpacked Size

40.6 kB

Total Files

23

Last publish

Collaborators

  • yd-tokugawa_t