@kizmann/pico-js 2.0.7 → 2.0.9

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.
Files changed (97) hide show
  1. package/dist/pico-js.browser.js +1 -1
  2. package/dist/pico-js.browser.js.map +1 -1
  3. package/dist/pico-js.esm.js +1 -1
  4. package/dist/pico-js.esm.js.map +1 -1
  5. package/package.json +4 -6
  6. package/src/dom/{DomAttribute.js → DomAttribute.ts} +40 -63
  7. package/src/dom/{DomBuilder.js → DomBuilder.ts} +27 -44
  8. package/src/dom/{DomEvent.js → DomEvent.ts} +101 -76
  9. package/src/dom/{DomFinder.js → DomFinder.ts} +103 -139
  10. package/src/dom/DomForm.ts +38 -0
  11. package/src/dom/{DomGlobal.js → DomGlobal.ts} +34 -51
  12. package/src/dom/{DomInview.js → DomInview.ts} +37 -57
  13. package/src/dom/DomMeta.ts +48 -0
  14. package/src/dom/DomObserver.ts +17 -0
  15. package/src/dom/{DomPopover.js → DomPopover.ts} +20 -39
  16. package/src/dom/{DomRectangle.js → DomRectangle.ts} +70 -87
  17. package/src/format/{FormatFile.js → FormatFile.ts} +12 -23
  18. package/src/format/{FormatOption.js → FormatOption.ts} +15 -24
  19. package/src/format/{FormatParam.js → FormatParam.ts} +14 -25
  20. package/src/format/{FormatParser.js → FormatParser.ts} +29 -39
  21. package/src/format/{FormatUrl.js → FormatUrl.ts} +9 -21
  22. package/src/index.browser.ts +32 -0
  23. package/src/index.esm.ts +64 -0
  24. package/src/now/{NowDefault.js → NowDefault.ts} +86 -121
  25. package/src/now/{NowFormat.js → NowFormat.ts} +23 -28
  26. package/src/now/{NowGrid.js → NowGrid.ts} +41 -58
  27. package/src/now/{NowHuman.js → NowHuman.ts} +18 -27
  28. package/src/now/{NowMatch.js → NowMatch.ts} +22 -28
  29. package/src/now/{NowRange.js → NowRange.ts} +13 -22
  30. package/src/now/{NowWalker.js → NowWalker.ts} +65 -71
  31. package/src/tool/{scope.js → scope.ts} +41 -11
  32. package/src/utils/{Array.js → Array.ts} +187 -152
  33. package/src/utils/{Cookie.js → Cookie.ts} +15 -12
  34. package/src/utils/{Data.js → Data.ts} +17 -17
  35. package/src/utils/Dom.ts +204 -0
  36. package/src/utils/Format.ts +48 -0
  37. package/src/utils/{Hash.js → Hash.ts} +20 -20
  38. package/src/utils/{Locale.js → Locale.ts} +21 -21
  39. package/src/utils/{Mixed.js → Mixed.ts} +104 -61
  40. package/src/utils/{Now.js → Now.ts} +68 -69
  41. package/src/utils/{Number.js → Number.ts} +34 -36
  42. package/src/utils/{Object.js → Object.ts} +68 -122
  43. package/src/utils/{Route.js → Route.ts} +11 -9
  44. package/src/utils/{Runner.js → Runner.ts} +89 -77
  45. package/src/utils/{Signal.js → Signal.ts} +35 -22
  46. package/src/utils/{String.js → String.ts} +79 -69
  47. package/src/wip/{Element.js → Element.ts} +2 -2
  48. package/src/wip/{Map.js → Map.ts} +1 -1
  49. package/types/dom/DomAttribute.d.ts +16 -27
  50. package/types/dom/DomBuilder.d.ts +6 -9
  51. package/types/dom/DomEvent.d.ts +19 -24
  52. package/types/dom/DomFinder.d.ts +38 -61
  53. package/types/dom/DomForm.d.ts +7 -10
  54. package/types/dom/DomGlobal.d.ts +8 -15
  55. package/types/dom/DomInview.d.ts +9 -19
  56. package/types/dom/DomMeta.d.ts +9 -16
  57. package/types/dom/DomObserver.d.ts +4 -8
  58. package/types/dom/DomPopover.d.ts +8 -11
  59. package/types/dom/DomRectangle.d.ts +21 -35
  60. package/types/format/FormatFile.d.ts +5 -8
  61. package/types/format/FormatOption.d.ts +6 -8
  62. package/types/format/FormatParam.d.ts +6 -9
  63. package/types/format/FormatParser.d.ts +10 -18
  64. package/types/format/FormatUrl.d.ts +5 -8
  65. package/types/index.esm.d.ts +25 -37
  66. package/types/now/NowDefault.d.ts +30 -99
  67. package/types/now/NowFormat.d.ts +8 -21
  68. package/types/now/NowGrid.d.ts +24 -46
  69. package/types/now/NowHuman.d.ts +10 -11
  70. package/types/now/NowMatch.d.ts +6 -4
  71. package/types/now/NowRange.d.ts +5 -8
  72. package/types/now/NowWalker.d.ts +6 -4
  73. package/types/tool/scope.d.ts +11 -3
  74. package/types/utils/Array.d.ts +83 -101
  75. package/types/utils/Cookie.d.ts +11 -8
  76. package/types/utils/Data.d.ts +7 -7
  77. package/types/utils/Dom.d.ts +63 -96
  78. package/types/utils/Format.d.ts +15 -28
  79. package/types/utils/Hash.d.ts +21 -21
  80. package/types/utils/Locale.d.ts +9 -9
  81. package/types/utils/Mixed.d.ts +19 -32
  82. package/types/utils/Now.d.ts +51 -56
  83. package/types/utils/Number.d.ts +9 -20
  84. package/types/utils/Object.d.ts +21 -36
  85. package/types/utils/Route.d.ts +5 -2
  86. package/types/utils/Runner.d.ts +45 -38
  87. package/types/utils/Signal.d.ts +16 -16
  88. package/types/utils/String.d.ts +40 -76
  89. package/src/dom/DomForm.js +0 -59
  90. package/src/dom/DomMeta.js +0 -68
  91. package/src/dom/DomObserver.js +0 -38
  92. package/src/index.browser.js +0 -36
  93. package/src/index.esm.js +0 -80
  94. package/src/utils/Dom.js +0 -214
  95. package/src/utils/Format.js +0 -62
  96. package/types/wip/Element.d.ts +0 -119
  97. package/types/wip/Map.d.ts +0 -254
@@ -1,4 +1,4 @@
1
- export class PicoNumber {
1
+ export declare class PicoNumber {
2
2
  /**
3
3
  * Format number with decimals
4
4
  *
@@ -66,20 +66,20 @@ export class PicoNumber {
66
66
  * @example Num.combine([1, 2]) // => 3
67
67
  * @example Num.combine([5, -2]) // => 3
68
68
  *
69
- * @param {Array<number>} value Number list
69
+ * @param {number[]} value Number list
70
70
  * @returns {number} Sum value
71
71
  */
72
- static combine(value: Array<number>): number;
72
+ static combine(value: number[]): number;
73
73
  /**
74
74
  * Subtract numbers in list
75
75
  *
76
76
  * @example Num.subtract([5, 2]) // => 3
77
77
  * @example Num.subtract([10, 3]) // => 7
78
78
  *
79
- * @param {Array<number>} value Number list
79
+ * @param {number[]} value Number list
80
80
  * @returns {number} Result value
81
81
  */
82
- static subtract(value: Array<number>): number;
82
+ static subtract(value: number[]): number;
83
83
  /**
84
84
  * Get decade base (10s)
85
85
  *
@@ -96,12 +96,11 @@ export class PicoNumber {
96
96
  * @example Num.matrix(5) // => [4, 1]
97
97
  * @example Num.matrix(8) // => [8]
98
98
  *
99
- * @param {number} num Input number
100
- * @param {number} [limit] Unused (legacy)
101
- * @param {Array<number>} [base] Result base
99
+ * @param {any} num Input number
100
+ * @param {number[]} [base] Result base
102
101
  * @returns {Array<number>} Power list
103
102
  */
104
- static matrix(num: number, limit?: number, base?: Array<number>): Array<number>;
103
+ static matrix(num: any, base?: number[]): Array<number>;
105
104
  /**
106
105
  * Calculate distance between coords
107
106
  *
@@ -114,14 +113,4 @@ export class PicoNumber {
114
113
  */
115
114
  static distance(cord1: any, cord2: any, miles?: boolean): number;
116
115
  }
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 Num;
116
+ export default PicoNumber;
@@ -1,4 +1,4 @@
1
- export class PicoObject {
1
+ export declare class PicoObject {
2
2
  /**
3
3
  * Normalize key path to array
4
4
  *
@@ -7,10 +7,10 @@ export class PicoObject {
7
7
  *
8
8
  * @param {any} keys Key path
9
9
  * @param {boolean} [flatten] Flatten keys
10
- * @param {boolean|null} [isstr] Is string flag
10
+ * @param {boolean} [isstr] Is string flag
11
11
  * @returns {Array<any>} Key segments
12
12
  */
13
- static keyoptim(keys: any, flatten?: boolean, isstr?: boolean | null): Array<any>;
13
+ static keyoptim(keys: any, flatten?: boolean, isstr?: boolean): Array<any>;
14
14
  /**
15
15
  * Check if nested key exists
16
16
  *
@@ -88,7 +88,7 @@ export class PicoObject {
88
88
  * @example Obj.each({a:1}, v => v+1) // => {a:2}
89
89
  *
90
90
  * @param {any} value Source object
91
- * @param {function} cb Map callback
91
+ * @param {Function} cb Map callback
92
92
  * @param {any} [retval] Forced return
93
93
  * @returns {any} Mapped object
94
94
  */
@@ -99,7 +99,7 @@ export class PicoObject {
99
99
  * @example Obj.map({a:1}, v => v+1) // => {a:2}
100
100
  *
101
101
  * @param {any} value Source object
102
- * @param {function} cb Map callback
102
+ * @param {Function} cb Map callback
103
103
  * @returns {Record<string, any>} Mapped object
104
104
  */
105
105
  static map(value: any, cb: Function): Record<string, any>;
@@ -130,10 +130,10 @@ export class PicoObject {
130
130
  *
131
131
  * @param {any} value Source object
132
132
  * @param {string} [prefix] Key prefix
133
- * @param {Record<string, any>} [result] Result map
133
+ * @param {any} [result] Result map
134
134
  * @returns {Record<string, any>} Flat map
135
135
  */
136
- static flatten(value: any, prefix?: string, result?: Record<string, any>): Record<string, any>;
136
+ static flatten(value: any, prefix?: string, result?: any): Record<string, any>;
137
137
  /**
138
138
  * Flatten object into form keys
139
139
  *
@@ -141,29 +141,29 @@ export class PicoObject {
141
141
  *
142
142
  * @param {any} value Source object
143
143
  * @param {string} [prefix] Key prefix
144
- * @param {Record<string, any>} [result] Result map
144
+ * @param {any} [result] Result map
145
145
  * @returns {Record<string, any>} Flat map
146
146
  */
147
- static flattenForm(value: any, prefix?: string, result?: Record<string, any>): Record<string, any>;
147
+ static flattenForm(value: any, prefix?: string, result?: any): Record<string, any>;
148
148
  /**
149
149
  * Unpack dotted keys into object
150
150
  *
151
151
  * @example Obj.unpack({"a.b":1}) // => {a:{b:1}}
152
152
  *
153
153
  * @param {any} value Flat key map
154
- * @param {Record<string, any>} [result] Result object
155
- * @returns {Record<string, any>} Unpacked object
154
+ * @param {any} [result] Result object
155
+ * @returns {any} Unpacked object
156
156
  */
157
- static unpack(value: any, result?: Record<string, any>): Record<string, any>;
157
+ static unpack(value: any, result?: any): any;
158
158
  /**
159
159
  * Assign objects (Object.assign)
160
160
  *
161
161
  * @example Obj.assign({}, {a:1}) // => {a:1}
162
162
  *
163
- * @param {...any} args Assign args
163
+ * @param {[...any]} args Assign args
164
164
  * @returns {any} Assigned object
165
165
  */
166
- static assign(...args: any[]): any;
166
+ static assign(...args: [...any]): any;
167
167
  /**
168
168
  * Deep clone primitive/array/object
169
169
  *
@@ -191,22 +191,22 @@ export class PicoObject {
191
191
  * @example Obj.only({a:1,b:2}, ["a"]) // => {a:1}
192
192
  *
193
193
  * @param {any} value Source object
194
- * @param {Array<any>} keys Allowed keys
194
+ * @param {string[]} keys Allowed keys
195
195
  * @param {any} [merge] Merge values
196
- * @returns {Record<string, any>} Picked object
196
+ * @returns {any} Picked object
197
197
  */
198
- static only(value: any, keys: Array<any>, merge?: any): Record<string, any>;
198
+ static only(value: any, keys: string[], merge?: any): any;
199
199
  /**
200
200
  * Pick all keys except given
201
201
  *
202
202
  * @example Obj.except({a:1,b:2}, ["a"]) // => {b:2}
203
203
  *
204
204
  * @param {any} value Source object
205
- * @param {Array<any>} keys Excluded keys
205
+ * @param {string[]} keys Excluded keys
206
206
  * @param {any} [merge] Merge values
207
- * @returns {Record<string, any>} Picked object
207
+ * @returns {any} Picked object
208
208
  */
209
- static except(value: any, keys: Array<any>, merge?: any): Record<string, any>;
209
+ static except(value: any, keys: string[], merge?: any): any;
210
210
  /**
211
211
  * Check if value includes search
212
212
  *
@@ -229,21 +229,6 @@ export class PicoObject {
229
229
  * @returns {boolean} True if matches
230
230
  */
231
231
  static matches(value: any, search: any): boolean;
232
- static sort(obj: any, key: any): any[];
233
- static sortString(obj: any, key: any): any[];
234
- }
235
- export namespace PicoObject {
236
- /**
237
- * @see PicoMixed.vals
238
- */
239
- function values(...args: any[]): any[];
240
- /**
241
- * @see PicoArray.find
242
- */
243
- function find(...args: any[]): any;
244
- /**
245
- * @see PicoArray.findIndex
246
- */
247
- function findIndex(...args: any[]): number;
232
+ static sort(value: any, key: string): any;
248
233
  }
249
234
  export default PicoObject;
@@ -1,5 +1,8 @@
1
- export class PicoRoute {
2
- static $routes: {};
1
+ export declare class PicoRoute {
2
+ /**
3
+ * @type {any}
4
+ */
5
+ static $routes: any;
3
6
  /**
4
7
  * Store route template by key
5
8
  *
@@ -1,23 +1,42 @@
1
- export class PicoRunner {
1
+ export declare class PicoRunner {
2
+ /**
3
+ * @type {any}
4
+ */
2
5
  static $idler: any;
6
+ /**
7
+ * @type {number}
8
+ */
3
9
  static $timer: number;
10
+ /**
11
+ * @type {any[]}
12
+ */
4
13
  static $buffer: any[];
14
+ /**
15
+ * Run interval and return clear function
16
+ *
17
+ * @example Run.interval(cb, 100)
18
+ *
19
+ * @param {Function} fn Callback function
20
+ * @param {number} [intval] Callback interval
21
+ * @returns {Function} Noop clear function
22
+ */
23
+ static interval(fn: Function, intval?: number): Function;
5
24
  /**
6
25
  * Clear timer or call function
7
26
  *
8
27
  * @example Run.clear(timer)
9
28
  *
10
29
  * @param {any} timer Timer ID, array of IDs, or function
11
- * @returns {typeof PicoRunner} Static class
30
+ * @returns {PicoRunner} Static class
12
31
  */
13
- static clear(timer: any): typeof PicoRunner;
32
+ static clear(timer: any): PicoRunner;
14
33
  /**
15
34
  * Request idle callback with fallback
16
35
  *
17
- * @param {function} cb Callback function
18
- * @returns {typeof PicoRunner} Static class
36
+ * @param {Function} cb Callback function
37
+ * @returns {PicoRunner} Static class
19
38
  */
20
- static tryin(cb: Function): typeof PicoRunner;
39
+ static tryin(cb: Function): PicoRunner;
21
40
  /**
22
41
  * Wait for condition to be true
23
42
  *
@@ -26,7 +45,7 @@ export class PicoRunner {
26
45
  * @param {function} fn Condition function
27
46
  * @param {number} [intval] Interval ms
28
47
  * @param {number} [limit] Max iterations
29
- * @returns {function} Clear function
48
+ * @returns {Function} Clear function
30
49
  */
31
50
  static wait(fn: Function, intval?: number, limit?: number): Function;
32
51
  /**
@@ -34,50 +53,37 @@ export class PicoRunner {
34
53
  *
35
54
  * @example Run.frame(cb)
36
55
  *
37
- * @param {function} fn Callback function
38
- * @param {any} [...args] Callback arguments
39
- * @returns {function} Noop clear function
40
- */
41
- static frame(fn: Function, ...args: any[]): Function;
42
- /**
43
- * Run function when browser is idle
44
- *
45
- * @example Run.idle(cb)
46
- *
47
- * @param {function} fn Callback function
48
- * @param {any} [...args] Callback arguments
49
- * @returns {function} Noop clear function
56
+ * @param {Function} fn Callback function
57
+ * @returns {Function} Noop clear function
50
58
  */
51
- static idle(fn: Function, ...args: any[]): Function;
59
+ static frame(fn: Function): Function;
52
60
  /**
53
61
  * Run function asynchronously
54
62
  *
55
63
  * @example Run.async(cb)
56
64
  *
57
- * @param {function} fn Callback function
58
- * @param {any} [...args] Callback arguments
59
- * @returns {function} Noop clear function
65
+ * @param {Function} fn Callback function
66
+ * @returns {Function} Noop clear function
60
67
  */
61
- static async(fn: Function, ...args: any[]): Function;
68
+ static async(fn: Function): Function;
62
69
  /**
63
70
  * Run function after delay
64
71
  *
65
72
  * @example Run.delay(cb, 100)
66
73
  *
67
- * @param {function} fn Callback function
74
+ * @param {Function} fn Callback function
68
75
  * @param {number} [delay] Delay ms
69
- * @param {any} [...args] Callback arguments
70
- * @returns {function} Clear function
76
+ * @returns {Function} Clear function
71
77
  */
72
- static delay(fn: Function, delay?: number, ...args: any[]): Function;
78
+ static delay(fn: Function, delay?: number): Function;
73
79
  /**
74
80
  * Create debounced callback
75
81
  *
76
82
  * @example const fn = Run.debounce(cb, 100)
77
83
  *
78
- * @param {function} cb Callback to run
84
+ * @param {Function} cb Callback to run
79
85
  * @param {number} [timeout] Wait ms
80
- * @returns {function} Debounced fn
86
+ * @returns {Function} Debounced fn
81
87
  */
82
88
  static debounce(cb: Function, timeout?: number): Function;
83
89
  /**
@@ -85,9 +91,9 @@ export class PicoRunner {
85
91
  *
86
92
  * @example const fn = Run.throttle(cb, 100)
87
93
  *
88
- * @param {function} cb Callback to run
94
+ * @param {Function} cb Callback to run
89
95
  * @param {number} [timeout] Wait ms
90
- * @returns {function} Throttled fn
96
+ * @returns {Function} Throttled fn
91
97
  */
92
98
  static throttle(cb: Function, timeout?: number): Function;
93
99
  /**
@@ -95,20 +101,21 @@ export class PicoRunner {
95
101
  *
96
102
  * @example const fn = Run.framerate(cb, 30)
97
103
  *
98
- * @param {function} cb Callback to run
104
+ * @param {Function} cb Callback to run
99
105
  * @param {number} [fps] Max frames per sec
100
- * @returns {function} Rate-limited fn
106
+ * @param {boolean} [finish] Finish last frame
107
+ * @returns {Function} Rate-limited fn
101
108
  */
102
- static framerate(cb: Function, fps?: number): Function;
109
+ static framerate(cb: Function, fps?: number, finish?: boolean): Function;
103
110
  /**
104
111
  * Buffer events into single frame
105
112
  *
106
113
  * @example el.onwheel = Run.framebuffer(cb,"wheel")
107
114
  *
108
- * @param {function} cb Callback to run
115
+ * @param {Function} cb Callback to run
109
116
  * @param {string} key Buffer key
110
117
  * @param {number} [priority] Sort priority
111
- * @returns {function} Buffered handler
118
+ * @returns {Function} Buffered handler
112
119
  */
113
120
  static framebuffer(cb: Function, key: string, priority?: number): Function;
114
121
  /**
@@ -1,4 +1,4 @@
1
- export class PicoSignal {
1
+ export declare class PicoSignal {
2
2
  static $events: any[];
3
3
  /**
4
4
  * Bind callback to event name
@@ -6,24 +6,24 @@ export class PicoSignal {
6
6
  * @example Event.bind("x", cb) // => Event
7
7
  * @example Event.bind(["a","b"], cb) // => Event
8
8
  *
9
- * @param {any} event Event name(s)
10
- * @param {function} cb Event callback
9
+ * @param {string|string[]} event Event name(s)
10
+ * @param {Function} cb Event callback
11
11
  * @param {any} [options] Listener options
12
12
  * @param {boolean} [paused] Start paused
13
- * @returns {typeof PicoSignal} Event class
13
+ * @returns {PicoSignal} Event class
14
14
  */
15
- static bind(event: any, cb: Function, options?: any, paused?: boolean): typeof PicoSignal;
15
+ static bind(event: string | string[], cb: Function, options?: any, paused?: boolean): PicoSignal;
16
16
  /**
17
17
  * Unbind callback(s) from event
18
18
  *
19
19
  * @example Event.unbind("x") // => Event
20
20
  * @example Event.unbind(["a","b"]) // => Event
21
21
  *
22
- * @param {any} event Event name(s)
22
+ * @param {string|string[]} event Event name(s)
23
23
  * @param {any} [options] Listener options
24
- * @returns {typeof PicoSignal} Event class
24
+ * @returns {PicoSignal} Event class
25
25
  */
26
- static unbind(event: any, options?: any): typeof PicoSignal;
26
+ static unbind(event: string | string[], options?: any): PicoSignal;
27
27
  /**
28
28
  * Fire event with arguments
29
29
  *
@@ -31,28 +31,28 @@ export class PicoSignal {
31
31
  *
32
32
  * @param {string} event Event name
33
33
  * @param {...any} args Event args
34
- * @returns {typeof PicoSignal} Event class
34
+ * @returns {PicoSignal} Event class
35
35
  */
36
- static fire(event: string, ...args: any[]): typeof PicoSignal;
36
+ static fire(event: string, ...args: Parameters<any>): PicoSignal;
37
37
  /**
38
38
  * Pause listeners for event
39
39
  *
40
40
  * @example Event.pause("x") // => Event
41
41
  *
42
- * @param {any} event Event name(s)
42
+ * @param {string|string[]} event Event name(s)
43
43
  * @param {any} [options] Listener options
44
- * @returns {typeof PicoSignal} Event class
44
+ * @returns {PicoSignal} Event class
45
45
  */
46
- static pause(event: any, options?: any): typeof PicoSignal;
46
+ static pause(event: string | string[], options?: any): PicoSignal;
47
47
  /**
48
48
  * Unpause listeners for event
49
49
  *
50
50
  * @example Event.unpause("x") // => Event
51
51
  *
52
- * @param {any} event Event name(s)
52
+ * @param {string|string[]} event Event name(s)
53
53
  * @param {any} [options] Listener options
54
- * @returns {typeof PicoSignal} Event class
54
+ * @returns {PicoSignal} Event class
55
55
  */
56
- static unpause(event: any, options?: any): typeof PicoSignal;
56
+ static unpause(event: string | string[], options?: any): PicoSignal;
57
57
  }
58
58
  export default PicoSignal;