@kizmann/pico-js 1.0.13 → 2.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/README.md +27 -7
- package/dist/pico-js.browser.js +2 -0
- package/dist/pico-js.browser.js.map +1 -0
- package/dist/pico-js.esm.js +2 -0
- package/dist/pico-js.esm.js.map +1 -0
- package/package.json +20 -7
- package/src/dom/DomAttribute.js +374 -0
- package/src/dom/DomBuilder.js +152 -0
- package/src/dom/DomEvent.js +253 -0
- package/src/dom/DomFinder.js +669 -0
- package/src/dom/DomForm.js +57 -0
- package/src/dom/DomGlobal.js +193 -0
- package/src/dom/DomInview.js +332 -0
- package/src/dom/DomMeta.js +66 -0
- package/src/dom/DomObserver.js +57 -0
- package/src/dom/DomRectangle.js +657 -0
- package/src/format/FormatFile.js +54 -0
- package/src/format/FormatOption.js +108 -0
- package/src/format/FormatParam.js +107 -0
- package/src/format/FormatParser.js +156 -0
- package/src/format/FormatUrl.js +75 -0
- package/src/index.browser.js +10 -0
- package/src/index.esm.js +138 -0
- package/src/now/NowDefault.js +533 -0
- package/src/now/NowFormat.js +196 -0
- package/src/now/NowGrid.js +251 -0
- package/src/now/NowHuman.js +118 -0
- package/src/now/NowMatch.js +175 -0
- package/src/now/NowRange.js +70 -0
- package/src/now/NowWalker.js +544 -0
- package/src/tool/scope.js +103 -0
- package/src/utils/Array.js +986 -0
- package/src/utils/Cookie.js +184 -0
- package/src/utils/Data.js +200 -0
- package/src/utils/Dom.js +208 -0
- package/src/utils/Event.js +140 -0
- package/src/utils/Format.js +62 -0
- package/src/utils/Hash.js +164 -0
- package/src/utils/Locale.js +229 -0
- package/src/utils/Mixed.js +887 -0
- package/src/utils/Now.js +234 -0
- package/src/utils/Number.js +238 -0
- package/src/utils/Object.js +655 -0
- package/src/utils/Route.js +67 -0
- package/src/utils/Runner.js +327 -0
- package/src/utils/String.js +618 -0
- package/src/{library/element.js → wip/Element.js} +90 -16
- package/src/{library/map.js → wip/Map.js} +256 -40
- package/types/dom/DomAttribute.d.ts +137 -0
- package/types/dom/DomBuilder.d.ts +67 -0
- package/types/dom/DomEvent.d.ts +103 -0
- package/types/dom/DomFinder.d.ts +321 -0
- package/types/dom/DomForm.d.ts +21 -0
- package/types/dom/DomGlobal.d.ts +79 -0
- package/types/dom/DomInview.d.ts +114 -0
- package/types/dom/DomMeta.d.ts +29 -0
- package/types/dom/DomObserver.d.ts +21 -0
- package/types/dom/DomRectangle.d.ts +270 -0
- package/types/format/FormatFile.d.ts +18 -0
- package/types/format/FormatOption.d.ts +40 -0
- package/types/format/FormatParam.d.ts +39 -0
- package/types/format/FormatParser.d.ts +46 -0
- package/types/format/FormatUrl.d.ts +17 -0
- package/types/index.browser.d.ts +1 -0
- package/types/index.esm.d.ts +52 -0
- package/types/now/NowDefault.d.ts +183 -0
- package/types/now/NowFormat.d.ts +70 -0
- package/types/now/NowGrid.d.ts +107 -0
- package/types/now/NowHuman.d.ts +37 -0
- package/types/now/NowMatch.d.ts +108 -0
- package/types/now/NowRange.d.ts +21 -0
- package/types/now/NowWalker.d.ts +301 -0
- package/types/tool/scope.d.ts +24 -0
- package/types/utils/Array.d.ts +480 -0
- package/types/utils/Cookie.d.ts +60 -0
- package/types/utils/Data.d.ts +91 -0
- package/types/utils/Dom.d.ts +138 -0
- package/types/utils/Event.d.ts +58 -0
- package/types/utils/Format.d.ts +37 -0
- package/types/utils/Hash.d.ts +81 -0
- package/types/utils/Locale.d.ts +115 -0
- package/types/utils/Mixed.d.ts +469 -0
- package/types/utils/Now.d.ts +125 -0
- package/types/utils/Number.d.ts +127 -0
- package/types/utils/Object.d.ts +255 -0
- package/types/utils/Route.d.ts +37 -0
- package/types/utils/Runner.d.ts +139 -0
- package/types/utils/String.d.ts +330 -0
- package/types/wip/Element.d.ts +119 -0
- package/types/wip/Map.d.ts +254 -0
- package/dist/.ignore.js +0 -0
- package/dist/pico-js.js +0 -2
- package/dist/pico-js.js.map +0 -1
- package/src/element/default.js +0 -46
- package/src/element/example.js +0 -58
- package/src/index.js +0 -90
- package/src/library/cookie.js +0 -123
- package/src/library/data.js +0 -111
- package/src/library/event.js +0 -91
- package/src/library/locale.js +0 -84
- package/src/library/queue.js +0 -64
- package/src/library/route.js +0 -28
- package/src/utility/any.js +0 -369
- package/src/utility/array.js +0 -410
- package/src/utility/dom.js +0 -1425
- package/src/utility/now.js +0 -544
- package/src/utility/number.js +0 -128
- package/src/utility/object.js +0 -429
- package/src/utility/string.js +0 -328
- package/types/index.d.ts +0 -77
- package/types/library/cookie.d.ts +0 -10
- package/types/library/data.d.ts +0 -15
- package/types/library/element.d.ts +0 -22
- package/types/library/event.d.ts +0 -13
- package/types/library/locale.d.ts +0 -14
- package/types/library/map.d.ts +0 -43
- package/types/library/queue.d.ts +0 -18
- package/types/library/route.d.ts +0 -11
- package/types/utility/any.d.ts +0 -35
- package/types/utility/array.d.ts +0 -46
- package/types/utility/dom.d.ts +0 -101
- package/types/utility/now.d.ts +0 -79
- package/types/utility/number.d.ts +0 -17
- package/types/utility/object.d.ts +0 -29
- package/types/utility/string.d.ts +0 -26
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export class PicoNumber {
|
|
2
|
+
/**
|
|
3
|
+
* Format number with decimals
|
|
4
|
+
*
|
|
5
|
+
* @example Num.fixed(1.234, 2) // => "1.23"
|
|
6
|
+
* @example Num.fixed("2.4", 0) // => "2"
|
|
7
|
+
*
|
|
8
|
+
* @param {any} value Number value
|
|
9
|
+
* @param {number} decimals Decimals count
|
|
10
|
+
* @returns {string} Fixed string
|
|
11
|
+
*/
|
|
12
|
+
static fixed(value: any, decimals?: number): string;
|
|
13
|
+
/**
|
|
14
|
+
* Parse value as float
|
|
15
|
+
*
|
|
16
|
+
* @example Num.float("2.2") // => 2.2
|
|
17
|
+
* @example Num.float(3) // => 3
|
|
18
|
+
*
|
|
19
|
+
* @param {any} value Numeric value
|
|
20
|
+
* @returns {number} Parsed float
|
|
21
|
+
*/
|
|
22
|
+
static float(value: any): number;
|
|
23
|
+
/**
|
|
24
|
+
* Parse value as int
|
|
25
|
+
*
|
|
26
|
+
* @example Num.int("12") // => 12
|
|
27
|
+
* @example Num.int(12.9) // => 12
|
|
28
|
+
*
|
|
29
|
+
* @param {any} value Numeric value
|
|
30
|
+
* @returns {number} Parsed int
|
|
31
|
+
*/
|
|
32
|
+
static int(value: any): number;
|
|
33
|
+
/**
|
|
34
|
+
* Round up to integer
|
|
35
|
+
*
|
|
36
|
+
* @example Num.ceil(1.1) // => 2
|
|
37
|
+
* @example Num.ceil("2.0") // => 2
|
|
38
|
+
*
|
|
39
|
+
* @param {any} value Numeric value
|
|
40
|
+
* @returns {number} Ceil value
|
|
41
|
+
*/
|
|
42
|
+
static ceil(value: any): number;
|
|
43
|
+
/**
|
|
44
|
+
* Round down to integer
|
|
45
|
+
*
|
|
46
|
+
* @example Num.floor(1.9) // => 1
|
|
47
|
+
* @example Num.floor("2.0") // => 2
|
|
48
|
+
*
|
|
49
|
+
* @param {any} value Numeric value
|
|
50
|
+
* @returns {number} Floor value
|
|
51
|
+
*/
|
|
52
|
+
static floor(value: any): number;
|
|
53
|
+
/**
|
|
54
|
+
* Round to nearest integer
|
|
55
|
+
*
|
|
56
|
+
* @example Num.round(1.5) // => 2
|
|
57
|
+
* @example Num.round("2.2") // => 2
|
|
58
|
+
*
|
|
59
|
+
* @param {any} value Numeric value
|
|
60
|
+
* @returns {number} Rounded value
|
|
61
|
+
*/
|
|
62
|
+
static round(value: any): number;
|
|
63
|
+
/**
|
|
64
|
+
* Sum numbers in list
|
|
65
|
+
*
|
|
66
|
+
* @example Num.combine([1, 2]) // => 3
|
|
67
|
+
* @example Num.combine([5, -2]) // => 3
|
|
68
|
+
*
|
|
69
|
+
* @param {Array<number>} value Number list
|
|
70
|
+
* @returns {number} Sum value
|
|
71
|
+
*/
|
|
72
|
+
static combine(value: Array<number>): number;
|
|
73
|
+
/**
|
|
74
|
+
* Subtract numbers in list
|
|
75
|
+
*
|
|
76
|
+
* @example Num.subtract([5, 2]) // => 3
|
|
77
|
+
* @example Num.subtract([10, 3]) // => 7
|
|
78
|
+
*
|
|
79
|
+
* @param {Array<number>} value Number list
|
|
80
|
+
* @returns {number} Result value
|
|
81
|
+
*/
|
|
82
|
+
static subtract(value: Array<number>): number;
|
|
83
|
+
/**
|
|
84
|
+
* Get decade base (10s)
|
|
85
|
+
*
|
|
86
|
+
* @example Num.decade(27) // => 20
|
|
87
|
+
* @example Num.decade("99") // => 90
|
|
88
|
+
*
|
|
89
|
+
* @param {any} value Numeric value
|
|
90
|
+
* @returns {number} Decade value
|
|
91
|
+
*/
|
|
92
|
+
static decade(value: any): number;
|
|
93
|
+
/**
|
|
94
|
+
* Convert number to power-of-2 list
|
|
95
|
+
*
|
|
96
|
+
* @example Num.matrix(5) // => [4, 1]
|
|
97
|
+
* @example Num.matrix(8) // => [8]
|
|
98
|
+
*
|
|
99
|
+
* @param {number} num Input number
|
|
100
|
+
* @param {number} [limit] Unused (legacy)
|
|
101
|
+
* @param {Array<number>} [base] Result base
|
|
102
|
+
* @returns {Array<number>} Power list
|
|
103
|
+
*/
|
|
104
|
+
static matrix(num: number, limit?: number, base?: Array<number>): Array<number>;
|
|
105
|
+
/**
|
|
106
|
+
* Calculate distance between coords
|
|
107
|
+
*
|
|
108
|
+
* @example Num.distance({lat:0,lng:0},{lat:0,lng:1}) // => number
|
|
109
|
+
*
|
|
110
|
+
* @param {any} cord1 First coord
|
|
111
|
+
* @param {any} cord2 Second coord
|
|
112
|
+
* @param {boolean} [miles] Return miles if true
|
|
113
|
+
* @returns {number} Distance value
|
|
114
|
+
*/
|
|
115
|
+
static distance(cord1: any, cord2: any, miles?: boolean): number;
|
|
116
|
+
}
|
|
117
|
+
export namespace PicoNumber {
|
|
118
|
+
/**
|
|
119
|
+
* @see PicoStr.number
|
|
120
|
+
*/
|
|
121
|
+
function format(value: any, ...args: any[]): any;
|
|
122
|
+
/**
|
|
123
|
+
* @see PicoHash.number
|
|
124
|
+
*/
|
|
125
|
+
function random(...args: any[]): number;
|
|
126
|
+
}
|
|
127
|
+
export default PicoNumber;
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
export class PicoObject {
|
|
2
|
+
/**
|
|
3
|
+
* Normalize key path to array
|
|
4
|
+
*
|
|
5
|
+
* @example Obj.keyoptim("a.b") // => ["a","b"]
|
|
6
|
+
* @example Obj.keyoptim(["a","b"]) // => ["a","b"]
|
|
7
|
+
*
|
|
8
|
+
* @param {any} keys Key path
|
|
9
|
+
* @param {boolean} [flatten] Flatten keys
|
|
10
|
+
* @param {boolean|null} [isstr] Is string flag
|
|
11
|
+
* @returns {Array<any>} Key segments
|
|
12
|
+
*/
|
|
13
|
+
static keyoptim(keys: any, flatten?: boolean, isstr?: boolean | null): Array<any>;
|
|
14
|
+
/**
|
|
15
|
+
* Check if nested key exists
|
|
16
|
+
*
|
|
17
|
+
* @example Obj.has({a:{b:1}}, "a.b") // => true
|
|
18
|
+
* @example Obj.has({a:{}}, "a.b") // => false
|
|
19
|
+
*
|
|
20
|
+
* @param {any} target Target object
|
|
21
|
+
* @param {any} keys Key path
|
|
22
|
+
* @param {boolean} [flatten] Flatten keys
|
|
23
|
+
* @returns {boolean} True if exists
|
|
24
|
+
*/
|
|
25
|
+
static has(target: any, keys: any, flatten?: boolean): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Get nested value or fallback
|
|
28
|
+
*
|
|
29
|
+
* @example Obj.get({a:{b:1}}, "a.b") // => 1
|
|
30
|
+
* @example Obj.get({}, "a.b", null) // => null
|
|
31
|
+
*
|
|
32
|
+
* @param {any} target Target object
|
|
33
|
+
* @param {any} keys Key path
|
|
34
|
+
* @param {any} [fallback] Fallback value
|
|
35
|
+
* @param {boolean} [flatten] Flatten keys
|
|
36
|
+
* @returns {any} Nested value
|
|
37
|
+
*/
|
|
38
|
+
static get(target: any, keys: any, fallback?: any, flatten?: boolean): any;
|
|
39
|
+
/**
|
|
40
|
+
* Set nested value (mutates)
|
|
41
|
+
*
|
|
42
|
+
* @example Obj.set({}, "a.b", 1) // => object
|
|
43
|
+
* @example Obj.set({}, ["a","b"], 1) // => object
|
|
44
|
+
*
|
|
45
|
+
* @param {any} target Target object
|
|
46
|
+
* @param {any} keys Key path
|
|
47
|
+
* @param {any} value Value to set
|
|
48
|
+
* @param {boolean} [flatten] Flatten keys
|
|
49
|
+
* @returns {any} Mutated target
|
|
50
|
+
*/
|
|
51
|
+
static set(target: any, keys: any, value: any, flatten?: boolean): any;
|
|
52
|
+
/**
|
|
53
|
+
* Unset nested value (mutates)
|
|
54
|
+
*
|
|
55
|
+
* @example Obj.unset({a:{b:1}}, "a.b")
|
|
56
|
+
* @example Obj.unset({a:{b:1}}, ["a","b"])
|
|
57
|
+
*
|
|
58
|
+
* @param {any} target Target object
|
|
59
|
+
* @param {any} keys Key path
|
|
60
|
+
* @param {boolean} [flatten] Flatten keys
|
|
61
|
+
* @returns {any} Mutated target
|
|
62
|
+
*/
|
|
63
|
+
static unset(target: any, keys: any, flatten?: boolean): any;
|
|
64
|
+
/**
|
|
65
|
+
* Check if nested value is empty
|
|
66
|
+
*
|
|
67
|
+
* @example Obj.empty({a:null}, "a") // => true
|
|
68
|
+
* @example Obj.empty({a:1}, "a") // => false
|
|
69
|
+
*
|
|
70
|
+
* @param {any} target Target object
|
|
71
|
+
* @param {any} key Key path
|
|
72
|
+
* @returns {boolean} True if empty
|
|
73
|
+
*/
|
|
74
|
+
static empty(target: any, key: any): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Unset multiple keys (mutates)
|
|
77
|
+
*
|
|
78
|
+
* @example Obj.remove({a:1,b:2}, ["a"]) // => object
|
|
79
|
+
*
|
|
80
|
+
* @param {any} target Target object
|
|
81
|
+
* @param {any} keys Keys list
|
|
82
|
+
* @returns {any} Mutated target
|
|
83
|
+
*/
|
|
84
|
+
static remove(target: any, keys: any): any;
|
|
85
|
+
/**
|
|
86
|
+
* Map object values to object
|
|
87
|
+
*
|
|
88
|
+
* @example Obj.each({a:1}, v => v+1) // => {a:2}
|
|
89
|
+
*
|
|
90
|
+
* @param {any} value Source object
|
|
91
|
+
* @param {function} cb Map callback
|
|
92
|
+
* @param {any} [retval] Forced return
|
|
93
|
+
* @returns {any} Mapped object
|
|
94
|
+
*/
|
|
95
|
+
static each(value: any, cb: Function, retval?: any): any;
|
|
96
|
+
/**
|
|
97
|
+
* Map object values to object
|
|
98
|
+
*
|
|
99
|
+
* @example Obj.map({a:1}, v => v+1) // => {a:2}
|
|
100
|
+
*
|
|
101
|
+
* @param {any} value Source object
|
|
102
|
+
* @param {function} cb Map callback
|
|
103
|
+
* @returns {Record<string, any>} Mapped object
|
|
104
|
+
*/
|
|
105
|
+
static map(value: any, cb: Function): Record<string, any>;
|
|
106
|
+
/**
|
|
107
|
+
* Get filtered key indexes
|
|
108
|
+
*
|
|
109
|
+
* @example Obj.filterIndex({a:1,b:null}) // => ["a"]
|
|
110
|
+
*
|
|
111
|
+
* @param {any} value Source object
|
|
112
|
+
* @param {any} [filter] Filter spec
|
|
113
|
+
* @returns {Array<any>} Key list
|
|
114
|
+
*/
|
|
115
|
+
static filterIndex(value: any, filter?: any): Array<any>;
|
|
116
|
+
/**
|
|
117
|
+
* Filter object by key filter
|
|
118
|
+
*
|
|
119
|
+
* @example Obj.filter({a:1,b:null}) // => {a:1}
|
|
120
|
+
*
|
|
121
|
+
* @param {any} value Source object
|
|
122
|
+
* @param {any} [filter] Filter spec
|
|
123
|
+
* @returns {Record<string, any>} Filtered object
|
|
124
|
+
*/
|
|
125
|
+
static filter(value: any, filter?: any): Record<string, any>;
|
|
126
|
+
/**
|
|
127
|
+
* Flatten object into dot keys
|
|
128
|
+
*
|
|
129
|
+
* @example Obj.flatten({a:{b:1}}) // => {"a.b":1}
|
|
130
|
+
*
|
|
131
|
+
* @param {any} value Source object
|
|
132
|
+
* @param {string} [prefix] Key prefix
|
|
133
|
+
* @param {Record<string, any>} [result] Result map
|
|
134
|
+
* @returns {Record<string, any>} Flat map
|
|
135
|
+
*/
|
|
136
|
+
static flatten(value: any, prefix?: string, result?: Record<string, any>): Record<string, any>;
|
|
137
|
+
/**
|
|
138
|
+
* Flatten object into form keys
|
|
139
|
+
*
|
|
140
|
+
* @example Obj.flattenForm({a:{b:1}}) // => {"a[b]":1}
|
|
141
|
+
*
|
|
142
|
+
* @param {any} value Source object
|
|
143
|
+
* @param {string} [prefix] Key prefix
|
|
144
|
+
* @param {Record<string, any>} [result] Result map
|
|
145
|
+
* @returns {Record<string, any>} Flat map
|
|
146
|
+
*/
|
|
147
|
+
static flattenForm(value: any, prefix?: string, result?: Record<string, any>): Record<string, any>;
|
|
148
|
+
/**
|
|
149
|
+
* Unpack dotted keys into object
|
|
150
|
+
*
|
|
151
|
+
* @example Obj.unpack({"a.b":1}) // => {a:{b:1}}
|
|
152
|
+
*
|
|
153
|
+
* @param {any} value Flat key map
|
|
154
|
+
* @param {Record<string, any>} [result] Result object
|
|
155
|
+
* @returns {Record<string, any>} Unpacked object
|
|
156
|
+
*/
|
|
157
|
+
static unpack(value: any, result?: Record<string, any>): Record<string, any>;
|
|
158
|
+
/**
|
|
159
|
+
* Assign objects (Object.assign)
|
|
160
|
+
*
|
|
161
|
+
* @example Obj.assign({}, {a:1}) // => {a:1}
|
|
162
|
+
*
|
|
163
|
+
* @param {...any} args Assign args
|
|
164
|
+
* @returns {any} Assigned object
|
|
165
|
+
*/
|
|
166
|
+
static assign(...args: any[]): any;
|
|
167
|
+
/**
|
|
168
|
+
* Deep clone primitive/array/object
|
|
169
|
+
*
|
|
170
|
+
* @example Obj.clone({a:{b:1}}) // => new object
|
|
171
|
+
*
|
|
172
|
+
* @param {any} value Value to clone
|
|
173
|
+
* @param {any} [merge] Merge values
|
|
174
|
+
* @returns {any} Cloned value
|
|
175
|
+
*/
|
|
176
|
+
static clone(value: any, merge?: any): any;
|
|
177
|
+
/**
|
|
178
|
+
* Get and remove nested value
|
|
179
|
+
*
|
|
180
|
+
* @example Obj.pluck({a:1}, "a") // => 1
|
|
181
|
+
*
|
|
182
|
+
* @param {any} value Source object
|
|
183
|
+
* @param {any} key Key path
|
|
184
|
+
* @param {any} [fallback] Fallback value
|
|
185
|
+
* @returns {any} Plucked value
|
|
186
|
+
*/
|
|
187
|
+
static pluck(value: any, key: any, fallback?: any): any;
|
|
188
|
+
/**
|
|
189
|
+
* Pick only given keys
|
|
190
|
+
*
|
|
191
|
+
* @example Obj.only({a:1,b:2}, ["a"]) // => {a:1}
|
|
192
|
+
*
|
|
193
|
+
* @param {any} value Source object
|
|
194
|
+
* @param {Array<any>} keys Allowed keys
|
|
195
|
+
* @param {any} [merge] Merge values
|
|
196
|
+
* @returns {Record<string, any>} Picked object
|
|
197
|
+
*/
|
|
198
|
+
static only(value: any, keys: Array<any>, merge?: any): Record<string, any>;
|
|
199
|
+
/**
|
|
200
|
+
* Pick all keys except given
|
|
201
|
+
*
|
|
202
|
+
* @example Obj.except({a:1,b:2}, ["a"]) // => {b:2}
|
|
203
|
+
*
|
|
204
|
+
* @param {any} value Source object
|
|
205
|
+
* @param {Array<any>} keys Excluded keys
|
|
206
|
+
* @param {any} [merge] Merge values
|
|
207
|
+
* @returns {Record<string, any>} Picked object
|
|
208
|
+
*/
|
|
209
|
+
static except(value: any, keys: Array<any>, merge?: any): Record<string, any>;
|
|
210
|
+
/**
|
|
211
|
+
* Check if value includes search
|
|
212
|
+
*
|
|
213
|
+
* @example Obj.includes({a:1}, {a:1}) // => true
|
|
214
|
+
* @example Obj.includes({a:1}, {a:2}) // => false
|
|
215
|
+
*
|
|
216
|
+
* @param {any} value Source value
|
|
217
|
+
* @param {any} search Search spec
|
|
218
|
+
* @returns {boolean} True if includes
|
|
219
|
+
*/
|
|
220
|
+
static includes(value: any, search: any): boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Check if value matches search
|
|
223
|
+
*
|
|
224
|
+
* @example Obj.matches({a:1}, {a:1}) // => true
|
|
225
|
+
* @example Obj.matches({a:1}, {b:1}) // => false
|
|
226
|
+
*
|
|
227
|
+
* @param {any} value Source value
|
|
228
|
+
* @param {any} search Search spec
|
|
229
|
+
* @returns {boolean} True if matches
|
|
230
|
+
*/
|
|
231
|
+
static matches(value: any, search: any): boolean;
|
|
232
|
+
}
|
|
233
|
+
export namespace PicoObject {
|
|
234
|
+
/**
|
|
235
|
+
* @see PicoMixed.vals
|
|
236
|
+
*/
|
|
237
|
+
function values(...args: any[]): any[];
|
|
238
|
+
/**
|
|
239
|
+
* @see PicoArray.find
|
|
240
|
+
*/
|
|
241
|
+
function find(...args: any[]): any;
|
|
242
|
+
/**
|
|
243
|
+
* @see PicoArray.findIndex
|
|
244
|
+
*/
|
|
245
|
+
function findIndex(...args: any[]): number;
|
|
246
|
+
/**
|
|
247
|
+
* @see PicoArray.sort
|
|
248
|
+
*/
|
|
249
|
+
function sort(...args: any[]): any[];
|
|
250
|
+
/**
|
|
251
|
+
* @see PicoArray.sortDeep
|
|
252
|
+
*/
|
|
253
|
+
function sortString(...args: any[]): any[];
|
|
254
|
+
}
|
|
255
|
+
export default PicoObject;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export class PicoRoute {
|
|
2
|
+
static $routes: {};
|
|
3
|
+
/**
|
|
4
|
+
* Store route template by key
|
|
5
|
+
*
|
|
6
|
+
* @example Route.set("home", "/") // stores
|
|
7
|
+
*
|
|
8
|
+
* @param {string} key Route key
|
|
9
|
+
* @param {string} value Route template
|
|
10
|
+
* @returns {void} No return value
|
|
11
|
+
*/
|
|
12
|
+
static set(key: string, value: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Build route URL from template
|
|
15
|
+
*
|
|
16
|
+
* @example Route.get("home") // => "/"
|
|
17
|
+
* @example Route.get("/u/:id", {id:1}) // => "/u/1"
|
|
18
|
+
*
|
|
19
|
+
* @param {string} key Route key or url
|
|
20
|
+
* @param {any} [values] Token values
|
|
21
|
+
* @param {any} [query] Query params
|
|
22
|
+
* @returns {string} Built url
|
|
23
|
+
*/
|
|
24
|
+
static get(key: string, values?: any, query?: any): string;
|
|
25
|
+
/**
|
|
26
|
+
* Navigate to built route URL
|
|
27
|
+
*
|
|
28
|
+
* @example Route.goto("home")
|
|
29
|
+
*
|
|
30
|
+
* @param {string} key Route key or url
|
|
31
|
+
* @param {any} [values] Token values
|
|
32
|
+
* @param {any} [params] Query params
|
|
33
|
+
* @returns {void} No return value
|
|
34
|
+
*/
|
|
35
|
+
static goto(key: string, values?: any, params?: any): void;
|
|
36
|
+
}
|
|
37
|
+
export default PicoRoute;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
export class PicoRunner {
|
|
2
|
+
static $idler: {
|
|
3
|
+
native: {};
|
|
4
|
+
debounce: {};
|
|
5
|
+
throttle: {};
|
|
6
|
+
};
|
|
7
|
+
static $timer: {
|
|
8
|
+
date: number;
|
|
9
|
+
func: any;
|
|
10
|
+
};
|
|
11
|
+
static $buffer: any[];
|
|
12
|
+
/**
|
|
13
|
+
* Run callback after delay (id)
|
|
14
|
+
*
|
|
15
|
+
* @example Run.timeout(() => {}, 100) // => "t-..."
|
|
16
|
+
*
|
|
17
|
+
* @param {function} fn Callback to run
|
|
18
|
+
* @param {number} [delay] Delay ms
|
|
19
|
+
* @param {string|null} [index] Timer id
|
|
20
|
+
* @returns {string} Timer id
|
|
21
|
+
*/
|
|
22
|
+
static timeout(fn: Function, delay?: number, index?: string | null): string;
|
|
23
|
+
/**
|
|
24
|
+
* Run callback on interval (id)
|
|
25
|
+
*
|
|
26
|
+
* @example Run.interval(() => {}, 250) // => "i-..."
|
|
27
|
+
*
|
|
28
|
+
* @param {function} fn Callback to run
|
|
29
|
+
* @param {number} [intval] Interval ms
|
|
30
|
+
* @param {string|null} [index] Timer id
|
|
31
|
+
* @returns {string} Timer id
|
|
32
|
+
*/
|
|
33
|
+
static interval(fn: Function, intval?: number, index?: string | null): string;
|
|
34
|
+
/**
|
|
35
|
+
* Clear timer(s) by id
|
|
36
|
+
*
|
|
37
|
+
* @example Run.clear("i-abc") // => Run
|
|
38
|
+
* @example Run.clear(["t-a","i-b"]) // => Run
|
|
39
|
+
*
|
|
40
|
+
* @param {string|Array<string>} index Timer id(s)
|
|
41
|
+
* @param {string} [scope] Idler scope key
|
|
42
|
+
* @returns {typeof PicoRunner} Runner class
|
|
43
|
+
*/
|
|
44
|
+
static clear(index: string | Array<string>, scope?: string): typeof PicoRunner;
|
|
45
|
+
/**
|
|
46
|
+
* Poll until callback is true
|
|
47
|
+
*
|
|
48
|
+
* @example Run.wait(() => ready, 50) // polls
|
|
49
|
+
*
|
|
50
|
+
* @param {function} fn Condition callback
|
|
51
|
+
* @param {number} [intval] Poll interval ms
|
|
52
|
+
* @param {number} [limit] Max poll count
|
|
53
|
+
* @returns {void} No return value
|
|
54
|
+
*/
|
|
55
|
+
static wait(fn: Function, intval?: number, limit?: number): void;
|
|
56
|
+
/**
|
|
57
|
+
* Run callback in next frame
|
|
58
|
+
*
|
|
59
|
+
* @example Run.frame(() => {}) // => Run
|
|
60
|
+
*
|
|
61
|
+
* @param {function} fn Callback to run
|
|
62
|
+
* @param {...any} [args] Callback args
|
|
63
|
+
* @returns {typeof PicoRunner} Runner class
|
|
64
|
+
*/
|
|
65
|
+
static frame(fn: Function, ...args?: any[]): typeof PicoRunner;
|
|
66
|
+
/**
|
|
67
|
+
* Run callback async soon
|
|
68
|
+
*
|
|
69
|
+
* @example Run.async(() => {}) // => Run
|
|
70
|
+
*
|
|
71
|
+
* @param {function} fn Callback to run
|
|
72
|
+
* @param {...any} [args] Callback args
|
|
73
|
+
* @returns {typeof PicoRunner} Runner class
|
|
74
|
+
*/
|
|
75
|
+
static async(fn: Function, ...args?: any[]): typeof PicoRunner;
|
|
76
|
+
/**
|
|
77
|
+
* Run callback after delay
|
|
78
|
+
*
|
|
79
|
+
* @example const cancel = Run.delay(() => {}, 50)
|
|
80
|
+
*
|
|
81
|
+
* @param {function} fn Callback to run
|
|
82
|
+
* @param {number} [delay] Delay ms
|
|
83
|
+
* @param {...any} [args] Callback args
|
|
84
|
+
* @returns {function} Cancel function
|
|
85
|
+
*/
|
|
86
|
+
static delay(fn: Function, delay?: number, ...args?: any[]): Function;
|
|
87
|
+
/**
|
|
88
|
+
* Create debounced callback
|
|
89
|
+
*
|
|
90
|
+
* @example const fn = Run.debounce(cb, 100)
|
|
91
|
+
*
|
|
92
|
+
* @param {function} cb Callback to run
|
|
93
|
+
* @param {number} [timeout] Wait ms
|
|
94
|
+
* @param {string|null} [index] Debounce id
|
|
95
|
+
* @returns {function} Debounced fn
|
|
96
|
+
*/
|
|
97
|
+
static debounce(cb: Function, timeout?: number, index?: string | null): Function;
|
|
98
|
+
/**
|
|
99
|
+
* Create throttled callback
|
|
100
|
+
*
|
|
101
|
+
* @example const fn = Run.throttle(cb, 100)
|
|
102
|
+
*
|
|
103
|
+
* @param {function} cb Callback to run
|
|
104
|
+
* @param {number} [timeout] Wait ms
|
|
105
|
+
* @param {string|null} [index] Throttle id
|
|
106
|
+
* @returns {function} Throttled fn
|
|
107
|
+
*/
|
|
108
|
+
static throttle(cb: Function, timeout?: number, index?: string | null): Function;
|
|
109
|
+
/**
|
|
110
|
+
* Create framerate-limited callback
|
|
111
|
+
*
|
|
112
|
+
* @example const fn = Run.framerate(cb, 30)
|
|
113
|
+
*
|
|
114
|
+
* @param {function} cb Callback to run
|
|
115
|
+
* @param {number} [fps] Max frames per sec
|
|
116
|
+
* @returns {function} Rate-limited fn
|
|
117
|
+
*/
|
|
118
|
+
static framerate(cb: Function, fps?: number): Function;
|
|
119
|
+
/**
|
|
120
|
+
* Buffer events into single frame
|
|
121
|
+
*
|
|
122
|
+
* @example el.onwheel = Run.framebuffer(cb,"wheel")
|
|
123
|
+
*
|
|
124
|
+
* @param {function} cb Callback to run
|
|
125
|
+
* @param {string} key Buffer key
|
|
126
|
+
* @param {number} [order] Sort order
|
|
127
|
+
* @returns {function} Buffered handler
|
|
128
|
+
*/
|
|
129
|
+
static framebuffer(cb: Function, key: string, order?: number): Function;
|
|
130
|
+
/**
|
|
131
|
+
* Flush buffered frame events
|
|
132
|
+
*
|
|
133
|
+
* @example Run.runFramebuffer() // flush
|
|
134
|
+
*
|
|
135
|
+
* @returns {void} No return value
|
|
136
|
+
*/
|
|
137
|
+
static runFramebuffer(): void;
|
|
138
|
+
}
|
|
139
|
+
export default PicoRunner;
|