@lisergia/utilities 24.0.0 → 25.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/Polyfill.ts DELETED
@@ -1,51 +0,0 @@
1
- declare interface HTMLElement {
2
- forEach: Function
3
- }
4
-
5
- declare interface NodeList {
6
- filter: Function
7
- find: Function
8
- map: Function
9
- }
10
-
11
- const HTMLElementPrototype = HTMLElement.prototype as {
12
- forEach: Function
13
- }
14
-
15
- const NodeListPrototype = NodeList.prototype as {
16
- filter: Function
17
- find: Function
18
- map: Function
19
- }
20
-
21
- /**
22
- * Allow `forEach` to work with single HTMLElement.
23
- */
24
- if (!HTMLElementPrototype.forEach) {
25
- HTMLElementPrototype.forEach = function (callback: Function, thisArg: any) {
26
- thisArg = thisArg || window
27
-
28
- callback.call(thisArg, this, this, this)
29
- }
30
- }
31
-
32
- /**
33
- * Allow `filter` to work with NodeList.
34
- */
35
- if (!NodeListPrototype.filter) {
36
- NodeListPrototype.filter = Array.prototype.filter
37
- }
38
-
39
- /**
40
- * Allow `find` to work with NodeList.
41
- */
42
- if (!NodeListPrototype.find) {
43
- NodeListPrototype.find = Array.prototype.find
44
- }
45
-
46
- /**
47
- * Allow `map` to work with NodeList.
48
- */
49
- if (!NodeListPrototype.map) {
50
- NodeListPrototype.map = Array.prototype.map
51
- }
package/src/Promises.ts DELETED
@@ -1,43 +0,0 @@
1
- export const createPromise = <T>(): [Promise<T>, (value: T) => void] => {
2
- let resolve: (value: T) => void
3
-
4
- const promise = new Promise<T>((resolvePromise) => {
5
- resolve = resolvePromise
6
- })
7
-
8
- return [promise, resolve!]
9
- }
10
-
11
- export const createPromiseWithReject = <T>(): [Promise<T>, (value: T) => void, (reason?: any) => void] => {
12
- let resolve: (value: T) => void
13
- let reject: (reason?: any) => void
14
-
15
- const promise = new Promise<T>((resolvePromise, rejectPromise) => {
16
- resolve = resolvePromise
17
- reject = rejectPromise
18
- })
19
-
20
- return [promise, resolve!, reject!]
21
- }
22
-
23
- export const createPromiseWithTimeout = <T>(
24
- timeout: number,
25
- ): [Promise<T>, (value: T) => void, (reason?: any) => void] => {
26
- let resolve: (value: T) => void
27
- let reject: (reason?: any) => void
28
-
29
- const promise = new Promise<T>((resolvePromise, rejectPromise) => {
30
- resolve = resolvePromise
31
- reject = rejectPromise
32
- })
33
-
34
- const timer = setTimeout(() => {
35
- reject(new Error('Promise timed out'))
36
- }, timeout)
37
-
38
- promise.finally(() => {
39
- clearTimeout(timer)
40
- })
41
-
42
- return [promise, resolve!, reject!]
43
- }
package/src/Tempus.ts DELETED
@@ -1,23 +0,0 @@
1
- import Tempus, { TempusCallback, TempusOptions } from 'tempus'
2
-
3
- export class TempusUtilsManager {
4
- cache = new Map()
5
-
6
- add(callback: TempusCallback, options?: TempusOptions) {
7
- const cancel = Tempus.add(callback, options)
8
-
9
- this.cache.set(callback, cancel)
10
- }
11
-
12
- remove(callback: TempusCallback) {
13
- const cancel = this.cache.get(callback)
14
-
15
- if (cancel) {
16
- cancel()
17
-
18
- this.cache.delete(callback)
19
- }
20
- }
21
- }
22
-
23
- export const TempusUtils = new TempusUtilsManager()
package/src/index.ts DELETED
@@ -1,7 +0,0 @@
1
- import './Polyfill'
2
-
3
- export * from './Canvas'
4
- export * from './Detection'
5
- export * from './DOM'
6
- export * from './Math'
7
- export * from './Tempus'
package/tsconfig.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@lisergia/config-tsconfig/base.json"
3
- }