@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,469 @@
|
|
|
1
|
+
export namespace MIX_REGEX {
|
|
2
|
+
let iso: RegExp;
|
|
3
|
+
}
|
|
4
|
+
export class PicoMixed {
|
|
5
|
+
/**
|
|
6
|
+
* Check if the value is empty
|
|
7
|
+
*
|
|
8
|
+
* @example Mix.isEmpty('') // => true
|
|
9
|
+
* @example Mix.isEmpty(null) // => true
|
|
10
|
+
* @example Mix.isEmpty([]) // => true
|
|
11
|
+
* @example Mix.isEmpty({}) // => true
|
|
12
|
+
* @example Mix.isEmpty(false) // => false
|
|
13
|
+
*
|
|
14
|
+
* @param {any} value The value to test
|
|
15
|
+
* @returns {boolean} Returns true if value is not empty
|
|
16
|
+
*/
|
|
17
|
+
static isEmpty(value: any): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Check if the value is null
|
|
20
|
+
*
|
|
21
|
+
* @example Mix.isNull(null) // => true
|
|
22
|
+
* @example Mix.isNull(undefined) // => false
|
|
23
|
+
* @example Mix.isNull(0) // => false
|
|
24
|
+
* @example Mix.isNull('') // => false
|
|
25
|
+
*
|
|
26
|
+
* @param {any} value The value to test
|
|
27
|
+
* @returns {boolean} Return true if null
|
|
28
|
+
*/
|
|
29
|
+
static isNull(value: any): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Check if the value is undefined
|
|
32
|
+
*
|
|
33
|
+
* @example Mix.isUndef(undefined) // => true
|
|
34
|
+
* @example Mix.isUndef(null) // => false
|
|
35
|
+
* @example Mix.isUndef(0) // => false
|
|
36
|
+
* @example Mix.isUndef('') // => false
|
|
37
|
+
*
|
|
38
|
+
* @param {any} value The value to test
|
|
39
|
+
* @returns {boolean} Return true if undefined
|
|
40
|
+
*/
|
|
41
|
+
static isUndef(value: any): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Check if the value is null or undefined
|
|
44
|
+
*
|
|
45
|
+
* @example Mix.isNix(null) // => true
|
|
46
|
+
* @example Mix.isNix(undefined) // => true
|
|
47
|
+
* @example Mix.isNix(0) // => false
|
|
48
|
+
* @example Mix.isNix('') // => false
|
|
49
|
+
*
|
|
50
|
+
* @param {any} value The value to test
|
|
51
|
+
* @returns {boolean} Return true if null or undefined
|
|
52
|
+
*/
|
|
53
|
+
static isNix(value: any): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Check if the value is string or number
|
|
56
|
+
*
|
|
57
|
+
* @example Mix.isPrim('foo') // => true
|
|
58
|
+
* @example Mix.isPrim(2.2) // => true
|
|
59
|
+
* @example Mix.isPrim([]) // => false
|
|
60
|
+
* @example Mix.isPrim(null) // => false
|
|
61
|
+
*
|
|
62
|
+
* @param {any} value The value to test
|
|
63
|
+
* @returns {boolean} Return true if typeof string or number
|
|
64
|
+
*/
|
|
65
|
+
static isPrim(value: any): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* @see PicoMixed.isPrim
|
|
68
|
+
*/
|
|
69
|
+
static isPrimitive: typeof PicoMixed.isPrim;
|
|
70
|
+
/**
|
|
71
|
+
* Check if the value is a string
|
|
72
|
+
*
|
|
73
|
+
* @example Mix.isStr('foo') // => true
|
|
74
|
+
* @example Mix.isStr(1) // => false
|
|
75
|
+
*
|
|
76
|
+
* @param {any} value The value to test
|
|
77
|
+
* @returns {boolean} Return true if is string
|
|
78
|
+
*/
|
|
79
|
+
static isStr(value: any): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* @see PicoMixed.isStr
|
|
82
|
+
*/
|
|
83
|
+
static isString: typeof PicoMixed.isStr;
|
|
84
|
+
/**
|
|
85
|
+
* Check if the value is a number
|
|
86
|
+
*
|
|
87
|
+
* @example Mix.isNum(12.2) // => true
|
|
88
|
+
* @example Mix.isNum('-4.3') // => true
|
|
89
|
+
* @example Mix.isNum('13f') // => false
|
|
90
|
+
*
|
|
91
|
+
* @param {any} value The value to test
|
|
92
|
+
* @returns {boolean} Return true if is number
|
|
93
|
+
*/
|
|
94
|
+
static isNum(value: any): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* @see PicoMixed.isNum
|
|
97
|
+
*/
|
|
98
|
+
static isNumber: typeof PicoMixed.isNum;
|
|
99
|
+
/**
|
|
100
|
+
* Check if the value is an integer
|
|
101
|
+
*
|
|
102
|
+
* @example Mix.isInt(12) // => true
|
|
103
|
+
* @example Mix.isInt('4') // => true
|
|
104
|
+
* @example Mix.isInt('-4.3') // => false
|
|
105
|
+
* @example Mix.isInt(3.4) // => false
|
|
106
|
+
*
|
|
107
|
+
* @param {any} value The value to test
|
|
108
|
+
* @returns {boolean} Return true if is integer
|
|
109
|
+
*/
|
|
110
|
+
static isInt(value: any): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* @see PicoMixed.isInt
|
|
113
|
+
*/
|
|
114
|
+
static isInteger: typeof PicoMixed.isInt;
|
|
115
|
+
/**
|
|
116
|
+
* Check if the value is a boolean
|
|
117
|
+
*
|
|
118
|
+
* @example Mix.isBool(false) // => true
|
|
119
|
+
* @example Mix.isBool('true') // => true
|
|
120
|
+
* @example Mix.isBool(1) // => false
|
|
121
|
+
* @example Mix.isBool('1') // => false
|
|
122
|
+
*
|
|
123
|
+
* @param {any} value The value to test
|
|
124
|
+
* @returns {boolean} Return true if is boolean
|
|
125
|
+
*/
|
|
126
|
+
static isBool(value: any): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* @see PicoMixed.isBool
|
|
129
|
+
*/
|
|
130
|
+
static isBoolean: typeof PicoMixed.isBool;
|
|
131
|
+
/**
|
|
132
|
+
* Check if the value is a function
|
|
133
|
+
*
|
|
134
|
+
* @example Mix.isFunc(() => {}) // => true
|
|
135
|
+
* @example Mix.isFunc(Mix.isFunc) // => true
|
|
136
|
+
* @example Mix.isFunc({}) // => false
|
|
137
|
+
* @example Mix.isFunc('1') // => false
|
|
138
|
+
*
|
|
139
|
+
* @param {any} value The value to test
|
|
140
|
+
* @returns {boolean} Return true if is function
|
|
141
|
+
*/
|
|
142
|
+
static isFunc(value: any): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* @see PicoMixed.isFunc
|
|
145
|
+
*/
|
|
146
|
+
static isFunction: typeof PicoMixed.isFunc;
|
|
147
|
+
/**
|
|
148
|
+
* Check if the value is object
|
|
149
|
+
*
|
|
150
|
+
* @example Mix.isRef({}) // => true
|
|
151
|
+
* @example Mix.isRef([]) // => true
|
|
152
|
+
* @example Mix.isRef(() => {}) // => false
|
|
153
|
+
* @example Mix.isRef(null) // => false
|
|
154
|
+
* @example Mix.isRef(undefined) // => false
|
|
155
|
+
*
|
|
156
|
+
* @param {any} value The value to test
|
|
157
|
+
* @returns {boolean} Returns true if is an object
|
|
158
|
+
*/
|
|
159
|
+
static isRef(value: any): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* @see PicoMixed.isRef
|
|
162
|
+
*/
|
|
163
|
+
static isReference: typeof PicoMixed.isRef;
|
|
164
|
+
/**
|
|
165
|
+
* Check if the value is plain object
|
|
166
|
+
*
|
|
167
|
+
* @example Mix.isObj({}) // => true
|
|
168
|
+
* @example Mix.isObj([]) // => false
|
|
169
|
+
*
|
|
170
|
+
* @param {any} value The value to test
|
|
171
|
+
* @returns {boolean} Returns true if is plain object
|
|
172
|
+
*/
|
|
173
|
+
static isObj(value: any): boolean;
|
|
174
|
+
/**
|
|
175
|
+
* @see PicoMixed.isObj
|
|
176
|
+
*/
|
|
177
|
+
static isObject: typeof PicoMixed.isObj;
|
|
178
|
+
/**
|
|
179
|
+
* Check if the value is array object
|
|
180
|
+
*
|
|
181
|
+
* @example Mix.isArr([]) // => true
|
|
182
|
+
* @example Mix.isArr({}) // => false
|
|
183
|
+
*
|
|
184
|
+
* @param {any} value The Value to test
|
|
185
|
+
* @returns {boolean} Returns true if is array object
|
|
186
|
+
*/
|
|
187
|
+
static isArr(value: any): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* @see PicoMixed.isArr
|
|
190
|
+
*/
|
|
191
|
+
static isArray: typeof PicoMixed.isArr;
|
|
192
|
+
/**
|
|
193
|
+
* Check if the value is iterable object
|
|
194
|
+
*
|
|
195
|
+
* @example Mix.isIter(new FormData()) // => true
|
|
196
|
+
* @example Mix.isIter({}) // => false
|
|
197
|
+
*
|
|
198
|
+
* @param {any} value The Value to test
|
|
199
|
+
* @returns {boolean} Returns true if is iterable object
|
|
200
|
+
*/
|
|
201
|
+
static isIter(value: any): boolean;
|
|
202
|
+
/**
|
|
203
|
+
* @see PicoMixed.isIter
|
|
204
|
+
*/
|
|
205
|
+
static isIterable: typeof PicoMixed.isIter;
|
|
206
|
+
/**
|
|
207
|
+
* Check if the value is iso date
|
|
208
|
+
*
|
|
209
|
+
* @example Mix.isIsoDate(new Date()) // => true
|
|
210
|
+
* @example Mix.isIsoDate(new Date()) // => true
|
|
211
|
+
* @example Mix.isIsoDate('2023-01-01 00:00:00') // => true
|
|
212
|
+
*
|
|
213
|
+
* @param {any} value The Value to test
|
|
214
|
+
* @returns {boolean} Returns true if is iso date
|
|
215
|
+
*/
|
|
216
|
+
static isIsoDate(value: any): boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Check if the value is valid date
|
|
219
|
+
*
|
|
220
|
+
* @example Mix.isIsoDate(new Date()) // => true
|
|
221
|
+
* @example Mix.isIsoDate('2023-01-01') // => true
|
|
222
|
+
* @example Mix.isIsoDate('2023-01-01 00:00:00') // => false
|
|
223
|
+
*
|
|
224
|
+
* @param {any} value The Value to test
|
|
225
|
+
* @returns {boolean} Returns true if is valid date
|
|
226
|
+
*/
|
|
227
|
+
static isDate(value: any): boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Check if the value is valid time
|
|
230
|
+
*
|
|
231
|
+
* @example Mix.isIsoDate(new Date()) // => true
|
|
232
|
+
* @example Mix.isIsoDate('00:00:00') // => true
|
|
233
|
+
* @example Mix.isIsoDate('2023-01-01 00:00:00') // => false
|
|
234
|
+
*
|
|
235
|
+
* @param {any} value The Value to test
|
|
236
|
+
* @returns {boolean} Returns true if is valid time
|
|
237
|
+
*/
|
|
238
|
+
static isTime(value: any): boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Check if value is equal
|
|
241
|
+
*
|
|
242
|
+
* @example Mix.isEqual(el, el) // => true
|
|
243
|
+
*
|
|
244
|
+
* @param {any} obj Source value
|
|
245
|
+
* @param {any} val Compare value
|
|
246
|
+
* @returns {boolean} True if equal
|
|
247
|
+
*/
|
|
248
|
+
static isEqual(obj: any, val: any): boolean;
|
|
249
|
+
/**
|
|
250
|
+
* Convert iterable object to a regular object
|
|
251
|
+
*
|
|
252
|
+
* @example Mix.iter(new FormData()) // => {}
|
|
253
|
+
*
|
|
254
|
+
* @param {any} value Value to convert
|
|
255
|
+
* @returns {Record<string, any>} Converted object
|
|
256
|
+
*/
|
|
257
|
+
static iter(value: any): Record<string, any>;
|
|
258
|
+
/**
|
|
259
|
+
* Get keys of an object
|
|
260
|
+
*
|
|
261
|
+
* @example Mix.keys({a: 'v1', b: 'v2'}) // => ['a', 'b']
|
|
262
|
+
* @example Mix.keys(['v1', 'v2']) // => ['0', '1']
|
|
263
|
+
*
|
|
264
|
+
* @param {any} value Object to iterate
|
|
265
|
+
* @returns {Array<any>} Returns array with keys
|
|
266
|
+
*/
|
|
267
|
+
static keys(value: any): Array<any>;
|
|
268
|
+
/**
|
|
269
|
+
* Get values of an object
|
|
270
|
+
*
|
|
271
|
+
* @example Mix.vals({a: 'v1', b: 'v2'}) // => ['v1', 'v2']
|
|
272
|
+
* @example Mix.vals(['v1', 'v2']) // => ['v1', 'v2']
|
|
273
|
+
*
|
|
274
|
+
* @param {any} value Object to iterate
|
|
275
|
+
* @returns {Array<any>} Returns array with values
|
|
276
|
+
*/
|
|
277
|
+
static vals(value: any): Array<any>;
|
|
278
|
+
/**
|
|
279
|
+
* Cast to array
|
|
280
|
+
*
|
|
281
|
+
* @example Mix.nodes(nodeList) // => []
|
|
282
|
+
*
|
|
283
|
+
* @param {any} value Source value
|
|
284
|
+
* @returns {Array<any>} Array result
|
|
285
|
+
*/
|
|
286
|
+
static nodes(value: any): Array<any>;
|
|
287
|
+
/**
|
|
288
|
+
* Get own props excluding keys
|
|
289
|
+
*
|
|
290
|
+
* @example Mix.props(Math, ["PI"]) // => {}
|
|
291
|
+
*
|
|
292
|
+
* @param {any} value Source object
|
|
293
|
+
* @param {Array<any>} [exclude] Exclude keys
|
|
294
|
+
* @returns {Record<string, any>} Props map
|
|
295
|
+
*/
|
|
296
|
+
static props(value: any, exclude?: Array<any>): Record<string, any>;
|
|
297
|
+
/**
|
|
298
|
+
* Get static class props
|
|
299
|
+
*
|
|
300
|
+
* @example Mix.class(MyClass) // => {}
|
|
301
|
+
*
|
|
302
|
+
* @param {any} value Source class
|
|
303
|
+
* @param {Array<any>} [exclude] Exclude keys
|
|
304
|
+
* @returns {Record<string, any>} Props map
|
|
305
|
+
*/
|
|
306
|
+
static class(value: any, exclude?: Array<any>): Record<string, any>;
|
|
307
|
+
/**
|
|
308
|
+
* Get prototype props
|
|
309
|
+
*
|
|
310
|
+
* @example Mix.proto(MyClass) // => {}
|
|
311
|
+
*
|
|
312
|
+
* @param {any} value Source class
|
|
313
|
+
* @param {Array<any>} [exclude] Exclude keys
|
|
314
|
+
* @returns {Record<string, any>} Props map
|
|
315
|
+
*/
|
|
316
|
+
static proto(value: any, exclude?: Array<any>): Record<string, any>;
|
|
317
|
+
/**
|
|
318
|
+
* Create form data
|
|
319
|
+
*
|
|
320
|
+
* @example Mix.form({ a: 1 }) // => FormData
|
|
321
|
+
*
|
|
322
|
+
* @param {any} value Source object
|
|
323
|
+
* @returns {FormData} Form instance
|
|
324
|
+
*/
|
|
325
|
+
static form(value: any): FormData;
|
|
326
|
+
/**
|
|
327
|
+
* Loop over items
|
|
328
|
+
*
|
|
329
|
+
* @example Mix.vals(FormData, (val, key) => null) // => Mix
|
|
330
|
+
* @example Mix.vals(NodeList, (val, key) => null) // => Mix
|
|
331
|
+
*
|
|
332
|
+
* @param {any} value Value to loop
|
|
333
|
+
* @param {function} cb Callback for each loop
|
|
334
|
+
* @returns {PicoMixed} Returns Mix instance
|
|
335
|
+
*/
|
|
336
|
+
static each(value: any, cb: Function): PicoMixed;
|
|
337
|
+
/**
|
|
338
|
+
* Get length of value
|
|
339
|
+
*
|
|
340
|
+
* @example Mix.len({a: 'v1', b: 'v2'}) // => 2
|
|
341
|
+
* @example Mix.len(['v1', 'v2']) // => 2
|
|
342
|
+
* @example Mix.len('foobar') // => 6
|
|
343
|
+
* @example Mix.len(12) // => 2
|
|
344
|
+
*
|
|
345
|
+
* @param {any} value The value to count
|
|
346
|
+
* @returns {number} Returns length of value
|
|
347
|
+
*/
|
|
348
|
+
static len(value: any): number;
|
|
349
|
+
/**
|
|
350
|
+
* @see PicoMixed.length
|
|
351
|
+
*/
|
|
352
|
+
static length: typeof PicoMixed.len;
|
|
353
|
+
/**
|
|
354
|
+
* Compare two objects (used for natural array sort)
|
|
355
|
+
*
|
|
356
|
+
* @param {any} value First compare value
|
|
357
|
+
* @param {any} compare Second compare value
|
|
358
|
+
* @returns {number} Returns sort position
|
|
359
|
+
*/
|
|
360
|
+
static compare(value: any, compare: any): number;
|
|
361
|
+
/**
|
|
362
|
+
* Get value as null
|
|
363
|
+
*
|
|
364
|
+
* @example Mix.null("null") // => null
|
|
365
|
+
*
|
|
366
|
+
* @param {any} value Input value
|
|
367
|
+
* @param {any} [fallback] Fallback value
|
|
368
|
+
* @returns {any} Null or fallback
|
|
369
|
+
*/
|
|
370
|
+
static null(value: any, fallback?: any): any;
|
|
371
|
+
/**
|
|
372
|
+
* Cast to array
|
|
373
|
+
*
|
|
374
|
+
* @example Mix.arr("a,b") // => ["a", "b"]
|
|
375
|
+
*
|
|
376
|
+
* @param {any} value Source value
|
|
377
|
+
* @returns {Array<any>} Array result
|
|
378
|
+
*/
|
|
379
|
+
static arr(value: any): Array<any>;
|
|
380
|
+
/**
|
|
381
|
+
* @see PicoMixed.arr
|
|
382
|
+
*/
|
|
383
|
+
static array: typeof PicoMixed.arr;
|
|
384
|
+
/**
|
|
385
|
+
* Convert value to string
|
|
386
|
+
*
|
|
387
|
+
* @example Mix.str('foobar') // => 'foobar'
|
|
388
|
+
* @example Mix.str(12) // => '12'
|
|
389
|
+
* @example Mix.str(true) // => 'true'
|
|
390
|
+
* @example Mix.str(null) // => 'null'
|
|
391
|
+
* @example Mix.str(undefined) // => 'undefined'
|
|
392
|
+
*
|
|
393
|
+
* @param {any} value The value to convert
|
|
394
|
+
* @returns {string} Return value as string
|
|
395
|
+
*/
|
|
396
|
+
static str(value: any): string;
|
|
397
|
+
/**
|
|
398
|
+
* @see PicoMixed.str
|
|
399
|
+
*/
|
|
400
|
+
static string: typeof PicoMixed.str;
|
|
401
|
+
/**
|
|
402
|
+
* Convert value to number
|
|
403
|
+
*
|
|
404
|
+
* @example Mix.num('-2.2') // => -2.2
|
|
405
|
+
* @example Mix.num(12) // => 12
|
|
406
|
+
* @example Mix.num('foobar') // => NaN
|
|
407
|
+
* @example Mix.num(true) // => NaN
|
|
408
|
+
*
|
|
409
|
+
* @param {any} value The value to convert
|
|
410
|
+
* @param {any} fallback Fallback incase it is not primitive
|
|
411
|
+
* @returns {number|any} Return value as number
|
|
412
|
+
*/
|
|
413
|
+
static num(value: any, fallback?: any): number | any;
|
|
414
|
+
/**
|
|
415
|
+
* @see PicoMixed.num
|
|
416
|
+
*/
|
|
417
|
+
static number: typeof PicoMixed.num;
|
|
418
|
+
/**
|
|
419
|
+
* Convert value to integer
|
|
420
|
+
*
|
|
421
|
+
* @example Mix.int('-2.2') // => -2
|
|
422
|
+
* @example Mix.int(12) // => 12
|
|
423
|
+
* @example Mix.int('foobar') // => NaN
|
|
424
|
+
* @example Mix.int(true) // => NaN
|
|
425
|
+
*
|
|
426
|
+
* @param {any} value The value to convert
|
|
427
|
+
* @param {any} fallback Fallback incase it is not primitive
|
|
428
|
+
* @returns {number|any} Return value as integer
|
|
429
|
+
*/
|
|
430
|
+
static int(value: any, fallback?: any): number | any;
|
|
431
|
+
/**
|
|
432
|
+
* @see PicoMixed.int
|
|
433
|
+
*/
|
|
434
|
+
static integer: typeof PicoMixed.int;
|
|
435
|
+
/**
|
|
436
|
+
* Convert value to boolean
|
|
437
|
+
*
|
|
438
|
+
* @example Mix.int(true) // => true
|
|
439
|
+
* @example Mix.int(12) // => true
|
|
440
|
+
* @example Mix.int(0) // => false
|
|
441
|
+
* @example Mix.int('yes') // => true
|
|
442
|
+
* @example Mix.int('foobar') // => false
|
|
443
|
+
* @example Mix.int(['v1']) // => true
|
|
444
|
+
* @example Mix.int({}) // => false
|
|
445
|
+
*
|
|
446
|
+
* @param {any} value The value to convert
|
|
447
|
+
* @returns {boolean} Return value as boolean
|
|
448
|
+
*/
|
|
449
|
+
static bool(value: any): boolean;
|
|
450
|
+
/**
|
|
451
|
+
* @see PicoMixed.bool
|
|
452
|
+
*/
|
|
453
|
+
static boolean: typeof PicoMixed.bool;
|
|
454
|
+
}
|
|
455
|
+
export namespace PicoMixed {
|
|
456
|
+
function global(...args: any[]): any;
|
|
457
|
+
function isPlain(...args: any[]): boolean;
|
|
458
|
+
function float(...args: any[]): any;
|
|
459
|
+
function delay(...args: any[]): Function;
|
|
460
|
+
function async(...args: any[]): typeof import("./Runner.js").PicoRunner;
|
|
461
|
+
function debounce(...args: any[]): Function;
|
|
462
|
+
function throttle(...args: any[]): Function;
|
|
463
|
+
function framerate(...args: any[]): Function;
|
|
464
|
+
function convertString(...args: any[]): string;
|
|
465
|
+
function convertDatetime(...args: any[]): string;
|
|
466
|
+
function convertBool(...args: any[]): any;
|
|
467
|
+
function convertBoolean(...args: any[]): any;
|
|
468
|
+
}
|
|
469
|
+
export default PicoMixed;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @returns {typeof PicoNow}
|
|
3
|
+
*/
|
|
4
|
+
export function PicoNowBuilder(): typeof PicoNow;
|
|
5
|
+
export const PicoNowPlugins: ((self: any) => typeof import("./Now.js").PicoNow)[];
|
|
6
|
+
/**
|
|
7
|
+
* @class PicoNow
|
|
8
|
+
*
|
|
9
|
+
* @typedef {import('#src/now/NowMatch.js').PicoNowMatchInstance} PicoNowMatchInstance
|
|
10
|
+
* @typedef {import('#src/now/NowFormat.js').PicoNowFormatInstance} PicoNowFormatInstance
|
|
11
|
+
* @typedef {import('#src/now/NowMatch.js').PicoNowMatchInstance} PicoNowMatchInstance
|
|
12
|
+
* @typedef {import('#src/now/NowGrid.js').PicoNowGridInstance} PicoNowGridInstance
|
|
13
|
+
* @typedef {import('#src/now/NowWalker.js').PicoNowWalkerInstance} PicoNowWalkerInstance
|
|
14
|
+
* @typedef {import('#src/now/NowRange.js').PicoNowRangeInstance} PicoNowRangeInstance
|
|
15
|
+
* @typedef {import('#src/now/NowHuman.js').PicoNowHumanInstance} PicoNowHumanInstance
|
|
16
|
+
*
|
|
17
|
+
* @extends PicoNowDefaultInstance
|
|
18
|
+
* @extends PicoNowFormatInstance
|
|
19
|
+
* @extends PicoNowMatchInstance
|
|
20
|
+
* @extends PicoNowGridInstance
|
|
21
|
+
* @extends PicoNowWalkerInstance
|
|
22
|
+
* @extends PicoNowRangeInstance
|
|
23
|
+
* @extends PicoNowHumanInstance
|
|
24
|
+
*/
|
|
25
|
+
export class PicoNow {
|
|
26
|
+
/**
|
|
27
|
+
* Init hooks for instance
|
|
28
|
+
*
|
|
29
|
+
* @type {Array<function>}
|
|
30
|
+
*/
|
|
31
|
+
static init: Array<Function>;
|
|
32
|
+
/**
|
|
33
|
+
* Extend Now with a plugin
|
|
34
|
+
*
|
|
35
|
+
* @example Now.extend(fn)
|
|
36
|
+
*
|
|
37
|
+
* @param {function} plugin Plugin function
|
|
38
|
+
* @returns {void} No return value
|
|
39
|
+
*/
|
|
40
|
+
static extend(plugin: Function): void;
|
|
41
|
+
/**
|
|
42
|
+
* Create Now instance helper
|
|
43
|
+
*
|
|
44
|
+
* @example Now.make("now") // => Now
|
|
45
|
+
*
|
|
46
|
+
* @param {any} [value] Date input
|
|
47
|
+
* @param {string} [format] Input format
|
|
48
|
+
* @returns {PicoNow} Now instance
|
|
49
|
+
*/
|
|
50
|
+
static make(value?: any, format?: string): PicoNow;
|
|
51
|
+
/**
|
|
52
|
+
* Create Now instance from input
|
|
53
|
+
*
|
|
54
|
+
* @example new Now().toUTC() // => string
|
|
55
|
+
*
|
|
56
|
+
* @param {any} [value] Date input
|
|
57
|
+
* @param {string} [format] Input format
|
|
58
|
+
*/
|
|
59
|
+
constructor(value?: any, format?: string);
|
|
60
|
+
/**
|
|
61
|
+
* Original input value
|
|
62
|
+
*
|
|
63
|
+
* @type {any}
|
|
64
|
+
*/
|
|
65
|
+
input: any;
|
|
66
|
+
/**
|
|
67
|
+
* Current Date instance
|
|
68
|
+
*
|
|
69
|
+
* @type {Date}
|
|
70
|
+
*/
|
|
71
|
+
value: Date;
|
|
72
|
+
/**
|
|
73
|
+
* Reset date parts to start
|
|
74
|
+
*
|
|
75
|
+
* @example Now.make().reset() // => Now
|
|
76
|
+
*
|
|
77
|
+
* @param {any} [config] Reset flags
|
|
78
|
+
* @returns {PicoNow} Now instance
|
|
79
|
+
*/
|
|
80
|
+
reset(config?: any): PicoNow;
|
|
81
|
+
/**
|
|
82
|
+
* Clone Now instance
|
|
83
|
+
*
|
|
84
|
+
* @example Now.make().clone() // => Now
|
|
85
|
+
*
|
|
86
|
+
* @param {boolean} [reset] Reset clone
|
|
87
|
+
* @returns {PicoNow} New instance
|
|
88
|
+
*/
|
|
89
|
+
clone(reset?: boolean): PicoNow;
|
|
90
|
+
/**
|
|
91
|
+
* Check if input is valid date
|
|
92
|
+
*
|
|
93
|
+
* @example Now.make("x").valid() // => false
|
|
94
|
+
*
|
|
95
|
+
* @returns {boolean} True if valid
|
|
96
|
+
*/
|
|
97
|
+
valid(): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Get Date instance
|
|
100
|
+
*
|
|
101
|
+
* @example Now.make().toDate() // => Date
|
|
102
|
+
*
|
|
103
|
+
* @returns {Date} Date instance
|
|
104
|
+
*/
|
|
105
|
+
toDate(): Date;
|
|
106
|
+
/**
|
|
107
|
+
* Get UTC string
|
|
108
|
+
*
|
|
109
|
+
* @example Now.make().toUTC() // => string
|
|
110
|
+
*
|
|
111
|
+
* @returns {string} UTC string
|
|
112
|
+
*/
|
|
113
|
+
toUTC(): string;
|
|
114
|
+
/**
|
|
115
|
+
* @see PicoNow.reset
|
|
116
|
+
*/
|
|
117
|
+
resetTime(): PicoNow;
|
|
118
|
+
}
|
|
119
|
+
export default PicoNowBuilder;
|
|
120
|
+
export type PicoNowMatchInstance = import("#src/now/NowMatch.js").PicoNowMatchInstance;
|
|
121
|
+
export type PicoNowFormatInstance = import("#src/now/NowFormat.js").PicoNowFormatInstance;
|
|
122
|
+
export type PicoNowGridInstance = import("#src/now/NowGrid.js").PicoNowGridInstance;
|
|
123
|
+
export type PicoNowWalkerInstance = import("#src/now/NowWalker.js").PicoNowWalkerInstance;
|
|
124
|
+
export type PicoNowRangeInstance = import("#src/now/NowRange.js").PicoNowRangeInstance;
|
|
125
|
+
export type PicoNowHumanInstance = import("#src/now/NowHuman.js").PicoNowHumanInstance;
|