ESL Utils
ESL Utils is a module that contains a set of common utilities for working with DOM, BOM, and other simple but handy things that are used by ESL components, but can also be used in client code.
All ESL Utils helpers are super simple and atomic, be sure that none of the utilities requires the whole library. Even if you use the whole utils module, it is still tiny.
Modules
-
Abstract
-
Observable - a small base class that implements observable pattern.
-
-
Async
-
Aggregate - a throttle function decorator with aggregation.
Limits decorated function calls to one call in passed
time
. The decorated functioncallback
will be called once at the end of the timeout with the list of the first arguments in the calls. -
Debounce - a debounce function decorator.
Debouncing is a pattern commonly used for rate-limiting function calls with a timeout.
-
Delayed Task - a common helper to plan task (function) to be executed with or without a timeout.
New task planning request cancels the previous task in a DelayedTask instance in case it has not happened yet.
-
Promise Utils - a set of Promise helpers.
Allows converting DOM Events, timeouts, pooling checks, etc. to ES6 Promise or create a Deferred object that allows to resolve or reject related Promise.
-
RAF(Rendering callback) Utils - Request Animation Frame common helpers.
Includes RAF Decorator that postpones multiple function calls to a single one before rendering. Also includes
afterNextRender
deferring function. -
Throttle - a throttling function decorator.
Throttling is a pattern that allows limiting function calls to one execution per timeout.
-
-
TS Decorators
-
@attr - a TS decorator to create a property reflected to a DOM element attribute.
-
@bind - a TS decorator to bind method context to current class instance.
-
@boolAttr - a TS decorator to create a boolean property reflected to a DOM element attribute-marker.
-
@decorate - a TS decorator to decorate and bind class method.
-
@jsonAttr - a TS decorator to create an object property reflected to a DOM element attribute with JSON value.
-
@listen - a TS decorator to transform method into event listener descriptor.
-
@memoize - a TS decorator to make method or get accessor memoized.
-
@prop - a TS decorator to define a field on the prototype level.
-
@ready - a TS decorator to postpone method execution until DOM is ready.
See
esl-utils.dom.ready#onDocumentReady
utility function for details.
-
-
DOM Helpers
-
DOM API Utils - a basic dom api helpers.
-
Attributes - utility to work with Element attributes.
-
CSSClass - a utility to work with CSS classes.
Supports JQuery-like enumeration, inversion syntax, and locks.
-
Event Utils - utils to check, dispatch or listen events.
-
Focus - a focus order helpers.
-
Keys - a keyboard keys constants.
-
Ready - a utility to postpone callback to the task after DOM Ready.
-
Rect - a rectangle utility class to provide position calculations.
-
RTL Utils - Utils to detect RTL and RTL-specific browsers behavior.
-
Sanitize - utility to sanitizes html string from malicious attributes, values, and scripts.
Can also filter elements at the top nesting level by tag names.
-
Scripts - a script loading utility to limit and track loading.
-
Scroll - a scroll utility methods like locking, traversing for closest scrollable, etc.
Note: uses scroll.less styles.
-
DOM Traversing - a set of utils to find DOM elements or check their relations.
-
Visible - utility to check whether an element is visible or not.
-
Window - a browser window object utils.
-
-
Environment
-
Device Detector - a set of user agent based checks such as engine or device type.
-
-
Fixes
-
ESLVSizeCSSProxy - an utility to produce device normalized CSS properties for 100vw and 100vh.
-
-
Miscellaneous Utils
-
Array - an array utils (uniq, flat, wrap, etc.).
-
Set - a set or an array with uniq values utils.
-
Format - string format utils.
-
Function - simple functions and types.
-
Memoize - a memoization function decorator.
Memoization pattern allows executing pure function once and then uses the cached result.
-
Object - object common utils.
-
UID - unique identifier generation utils.
-