@lisergia/utilities 23.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/dist/Canvas.d.ts +5 -0
- package/dist/Canvas.js +51 -0
- package/dist/DOM.d.ts +12 -0
- package/dist/DOM.js +13 -0
- package/dist/Detection.d.ts +4 -0
- package/dist/Detection.js +6 -0
- package/dist/Math.d.ts +11 -0
- package/dist/Math.js +23 -0
- package/dist/Polyfill.d.ts +17 -0
- package/dist/Polyfill.js +29 -0
- package/dist/Promises.d.ts +3 -0
- package/dist/Promises.js +31 -0
- package/dist/Tempus.d.ts +7 -0
- package/dist/Tempus.js +16 -0
- package/dist/index.d.ts +6 -43
- package/dist/index.js +6 -246
- package/package.json +7 -6
- package/.turbo/turbo-build.log +0 -20
- package/CHANGELOG.md +0 -254
- package/dist/index.cjs +0 -279
- package/dist/index.d.cts +0 -43
- package/src/Canvas.ts +0 -65
- package/src/DOM.ts +0 -23
- package/src/Detection.ts +0 -7
- package/src/Math.ts +0 -37
- package/src/Polyfill.ts +0 -51
- package/src/Promises.ts +0 -43
- package/src/Tempus.ts +0 -23
- package/src/index.ts +0 -7
- package/tsconfig.json +0 -3
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
package/tsconfig.json
DELETED