@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,7 +1,7 @@
1
- import { Arr, Mix, Now, Num, Obj, Str } from "../index.esm.js";
2
- import { PicoNow } from "../utils/Now.js";
1
+ import { Mix, Now, Obj, Str } from "../index.esm.ts";
2
+ import { PicoNow, PicoNowInterface } from "../utils/Now.ts";
3
3
 
4
- export const NOW_MODIFY = {
4
+ export const NOW_MODIFY : any = {
5
5
  'second': /([+-])([0-9]+)\s?seconds?/i,
6
6
  'minute': /([+-])([0-9]+)\s?minutes?/i,
7
7
  'hour': /([+-])([0-9]+)\s?hours?/i,
@@ -10,12 +10,20 @@ export const NOW_MODIFY = {
10
10
  'year': /([+-])([0-9]+)\s?years?/i
11
11
  };
12
12
 
13
+ export interface PicoNowDefault extends PicoNowInterface
14
+ {
15
+ //
16
+ }
17
+
13
18
  /**
14
19
  * @memberof PicoNow
15
- * @extends {PicoNow}
16
20
  */
17
- export class PicoNowDefaultInstance
21
+ export class PicoNowDefault
18
22
  {
23
+ static test(value : any) : boolean
24
+ {
25
+ return value instanceof Date;
26
+ }
19
27
 
20
28
  /**
21
29
  * Get value by scope
@@ -23,9 +31,9 @@ export class PicoNowDefaultInstance
23
31
  * @example Now.get("year") // => 2026
24
32
  *
25
33
  * @param {string} scope Value scope
26
- * @returns {number|PicoNow} Scope value
34
+ * @returns {any} Scope value
27
35
  */
28
- get(scope)
36
+ get(scope : string) : any
29
37
  {
30
38
  if ( scope === 'time' ) {
31
39
  return this.value.getTime();
@@ -71,7 +79,7 @@ export class PicoNowDefaultInstance
71
79
  * @param {string} scope Value scope
72
80
  * @returns {PicoNow} Current instance
73
81
  */
74
- set(value, scope)
82
+ set(value : any, scope : string) : PicoNow
75
83
  {
76
84
  if ( !Mix.isNum(value) ) {
77
85
  value = Mix.int(value);
@@ -115,7 +123,7 @@ export class PicoNowDefaultInstance
115
123
  this.value.setFullYear(value);
116
124
  }
117
125
 
118
- return this;
126
+ return <PicoNow> <unknown> this;
119
127
  }
120
128
 
121
129
  /**
@@ -124,9 +132,9 @@ export class PicoNowDefaultInstance
124
132
  * @example Now.time() // => 1739334660000
125
133
  *
126
134
  * @param {any} [value] New timestamp
127
- * @returns {number|PicoNow} Timestamp or instance
135
+ * @returns {any} Timestamp or instance
128
136
  */
129
- time(value = null)
137
+ time(value : any = null) : any
130
138
  {
131
139
  if ( value == null ) {
132
140
  return this.get('time');
@@ -141,9 +149,9 @@ export class PicoNowDefaultInstance
141
149
  * @example Now.second() // => 45
142
150
  *
143
151
  * @param {any} [value] New seconds
144
- * @returns {number|PicoNow} Seconds or instance
152
+ * @returns {any} Seconds or instance
145
153
  */
146
- second(value = null)
154
+ second(value : any = null) : any
147
155
  {
148
156
  if ( value == null ) {
149
157
  return this.get('second');
@@ -158,9 +166,9 @@ export class PicoNowDefaultInstance
158
166
  * @example Now.minute() // => 30
159
167
  *
160
168
  * @param {any} [value] New minutes
161
- * @returns {number|PicoNow} Minutes or instance
169
+ * @returns {any} Minutes or instance
162
170
  */
163
- minute(value = null)
171
+ minute(value : any = null) : any
164
172
  {
165
173
  if ( value == null ) {
166
174
  return this.get('minute');
@@ -175,9 +183,9 @@ export class PicoNowDefaultInstance
175
183
  * @example Now.hour() // => 12
176
184
  *
177
185
  * @param {any} [value] New hours
178
- * @returns {number|PicoNow} Hours or instance
186
+ * @returns {any} Hours or instance
179
187
  */
180
- hour(value = null)
188
+ hour(value : any = null) : any
181
189
  {
182
190
  if ( value == null ) {
183
191
  return this.get('hour');
@@ -192,9 +200,9 @@ export class PicoNowDefaultInstance
192
200
  * @example Now.day() // => 1
193
201
  *
194
202
  * @param {any} [value] New day
195
- * @returns {number|PicoNow} Day or instance
203
+ * @returns {any} Day or instance
196
204
  */
197
- day(value = null)
205
+ day(value : any = null) : any
198
206
  {
199
207
  if ( value == null ) {
200
208
  return this.get('day');
@@ -209,9 +217,9 @@ export class PicoNowDefaultInstance
209
217
  * @example Now.date() // => 12
210
218
  *
211
219
  * @param {any} [value] New date
212
- * @returns {number|PicoNow} Date or instance
220
+ * @returns {any} Date or instance
213
221
  */
214
- date(value = null)
222
+ date(value : any = null) : any
215
223
  {
216
224
  if ( value == null ) {
217
225
  return this.get('date');
@@ -226,9 +234,9 @@ export class PicoNowDefaultInstance
226
234
  * @example Now.month() // => 2
227
235
  *
228
236
  * @param {any} [value] New month
229
- * @returns {number|PicoNow} Month or instance
237
+ * @returns {any} Month or instance
230
238
  */
231
- month(value = null)
239
+ month(value : any = null) : any
232
240
  {
233
241
  if ( value == null ) {
234
242
  return this.get('month');
@@ -243,9 +251,9 @@ export class PicoNowDefaultInstance
243
251
  * @example Now.year() // => 2026
244
252
  *
245
253
  * @param {any} [value] New year
246
- * @returns {number|PicoNow} Year or instance
254
+ * @returns {any} Year or instance
247
255
  */
248
- year(value = null)
256
+ year(value : any = null) : any
249
257
  {
250
258
  if ( value == null ) {
251
259
  return this.get('year');
@@ -261,9 +269,9 @@ export class PicoNowDefaultInstance
261
269
  *
262
270
  * @returns {string} Short year
263
271
  */
264
- shortyear()
272
+ shortyear() : string
265
273
  {
266
- return this.get('year').toString().slice(- 2);
274
+ return this.get('year').toString().slice(-2);
267
275
  }
268
276
 
269
277
  /**
@@ -271,11 +279,11 @@ export class PicoNowDefaultInstance
271
279
  *
272
280
  * @example Now.add(1, "day")
273
281
  *
274
- * @param {number} value Add value
282
+ * @param {any} value Add value
275
283
  * @param {string} [scope] Target scope
276
284
  * @returns {PicoNow} Current instance
277
285
  */
278
- add(value, scope = 'day')
286
+ add(value : any, scope : string = 'day') : PicoNow
279
287
  {
280
288
  if ( /^days?$/i.test(scope) ) {
281
289
  scope = 'date';
@@ -283,7 +291,7 @@ export class PicoNowDefaultInstance
283
291
 
284
292
  this.set(this.get(scope) + Mix.int(value), scope);
285
293
 
286
- return this;
294
+ return <PicoNow> <unknown> this;
287
295
  }
288
296
 
289
297
  /**
@@ -291,11 +299,11 @@ export class PicoNowDefaultInstance
291
299
  *
292
300
  * @example Now.sub(1, "day")
293
301
  *
294
- * @param {number} value Sub value
302
+ * @param {any} value Sub value
295
303
  * @param {string} [scope] Target scope
296
304
  * @returns {PicoNow} Current instance
297
305
  */
298
- sub(value, scope = 'day')
306
+ sub(value : any, scope : string = 'day') : PicoNow
299
307
  {
300
308
  if ( /^days?$/i.test(scope) ) {
301
309
  scope = 'date';
@@ -303,7 +311,7 @@ export class PicoNowDefaultInstance
303
311
 
304
312
  this.set(this.get(scope) - Mix.int(value), scope);
305
313
 
306
- return this;
314
+ return <PicoNow> <unknown> this;
307
315
  }
308
316
 
309
317
  /**
@@ -314,7 +322,7 @@ export class PicoNowDefaultInstance
314
322
  * @param {string} value Test value
315
323
  * @returns {boolean} Is modifiable
316
324
  */
317
- isModifible(value)
325
+ isModifible(value : string) : boolean
318
326
  {
319
327
  return /^(\s*[+-][0-9]+\s?[a-z]+\s*)+$/i.test(value);
320
328
  }
@@ -327,19 +335,19 @@ export class PicoNowDefaultInstance
327
335
  * @param {string} value Modify string
328
336
  * @returns {PicoNow} Current instance
329
337
  */
330
- modify(value)
338
+ modify(value : string) : PicoNow
331
339
  {
332
340
  if ( Mix.isEmpty(value) ) {
333
- return this;
341
+ return <PicoNow> <unknown> this;
334
342
  }
335
343
 
336
- Obj.each(NOW_MODIFY, (val, key) => {
344
+ Obj.each(NOW_MODIFY, (val : any, key : any) => {
337
345
  Str.match(value, val, ([f, o, c]) => {
338
346
  o === '+' ? this.add(c, key) : this.sub(c, key);
339
347
  });
340
348
  });
341
349
 
342
- return this;
350
+ return <PicoNow> <unknown> this;
343
351
  }
344
352
 
345
353
  /**
@@ -349,10 +357,10 @@ export class PicoNowDefaultInstance
349
357
  *
350
358
  * @param {any} value Source value
351
359
  * @param {string} [format] Source format
352
- * @param {Array<string>} [keys] Scope keys
360
+ * @param {string[]} [keys] Scope keys
353
361
  * @returns {PicoNow} Current instance
354
362
  */
355
- apply(value, format = 'YYYY-MM-DD HH:mm:ss', keys = [])
363
+ apply(value : any, format : string = 'YYYY-MM-DD HH:mm:ss', keys : string[] = []) : PicoNow
356
364
  {
357
365
  value = Now.make(value, format);
358
366
 
@@ -360,7 +368,7 @@ export class PicoNowDefaultInstance
360
368
  this.set(value.get(key), key);
361
369
  }
362
370
 
363
- return this;
371
+ return <PicoNow> <unknown> this;
364
372
  }
365
373
 
366
374
  /**
@@ -372,9 +380,9 @@ export class PicoNowDefaultInstance
372
380
  * @param {string} [format] Source format
373
381
  * @returns {PicoNow} Current instance
374
382
  */
375
- applyDate(value, format = 'YYYY-MM-DD HH:mm:ss')
383
+ applyDate(value : any, format : string = 'YYYY-MM-DD HH:mm:ss') : PicoNow
376
384
  {
377
- return this.apply(value, format, ['date', 'month', 'year']);
385
+ return <PicoNow> this.apply(value, format, ['date', 'month', 'year']);
378
386
  }
379
387
 
380
388
  /**
@@ -386,150 +394,107 @@ export class PicoNowDefaultInstance
386
394
  * @param {string} [format] Source format
387
395
  * @returns {PicoNow} Current instance
388
396
  */
389
- applyTime(value, format = 'YYYY-MM-DD HH:mm:ss')
397
+ applyTime(value : any, format : string = 'YYYY-MM-DD HH:mm:ss') : PicoNow
390
398
  {
391
- return this.apply(value, format, ['hour', 'minute', 'second']);
399
+ return <PicoNow> this.apply(value, format, ['hour', 'minute', 'second']);
392
400
  }
393
401
 
394
402
  }
395
403
 
396
- /**
397
- * @see PicoNow.add
398
- */
399
- PicoNowDefaultInstance.prototype.addSecond = function (value) {
404
+ // @ts-ignore
405
+ PicoNowDefault.prototype.addSecond = function (value : any) {
400
406
  console.warn('Now.addSecond() is deprecated, use Now.add(value, \'second\') instead.');
401
407
  return this.add(value, 'second');
402
408
  }
403
409
 
404
- /**
405
- * @see PicoNow.sub
406
- */
407
- PicoNowDefaultInstance.prototype.subSecond = function (value) {
410
+ // @ts-ignore
411
+ PicoNowDefault.prototype.subSecond = function (value : any) {
408
412
  console.warn('Now.subSecond() is deprecated, use Now.sub(value, \'second\') instead.');
409
413
  return this.sub(value, 'second');
410
414
  }
411
415
 
412
- /**
413
- * @see PicoNow.add
414
- */
415
- PicoNowDefaultInstance.prototype.addMinute = function (value) {
416
+ // @ts-ignore
417
+ PicoNowDefault.prototype.addMinute = function (value : any) {
416
418
  console.warn('Now.addMinute() is deprecated, use Now.add(value, \'minute\') instead.');
417
419
  return this.add(value, 'minute');
418
420
  }
419
421
 
420
- /**
421
- * @see PicoNow.sub
422
- */
423
- PicoNowDefaultInstance.prototype.subMinute = function (value) {
422
+ // @ts-ignore
423
+ PicoNowDefault.prototype.subMinute = function (value : any) {
424
424
  console.warn('Now.subMinute() is deprecated, use Now.sub(value, \'minute\') instead.');
425
425
  return this.sub(value, 'minute');
426
426
  }
427
427
 
428
- /**
429
- * @see PicoNow.add
430
- */
431
- PicoNowDefaultInstance.prototype.addHour = function (value) {
428
+ // @ts-ignore
429
+ PicoNowDefault.prototype.addHour = function (value : any) {
432
430
  console.warn('Now.addHour() is deprecated, use Now.add(value, \'hour\') instead.');
433
431
  return this.add(value, 'hour');
434
432
  }
435
433
 
436
- /**
437
- * @see PicoNow.sub
438
- */
439
- PicoNowDefaultInstance.prototype.subHour = function (value) {
434
+ // @ts-ignore
435
+ PicoNowDefault.prototype.subHour = function (value : any) {
440
436
  console.warn('Now.subHour() is deprecated, use Now.sub(value, \'hour\') instead.');
441
437
  return this.sub(value, 'hour');
442
438
  }
443
439
 
444
- /**
445
- * @see PicoNow.add
446
- */
447
- PicoNowDefaultInstance.prototype.addDates = function (value) {
440
+ // @ts-ignore
441
+ PicoNowDefault.prototype.addDates = function (value : any) {
448
442
  console.warn('Now.addDates() is deprecated, use Now.add(value, \'date\') instead.');
449
443
  return this.add(value, 'date');
450
444
  }
451
445
 
452
- /**
453
- * @see PicoNow.sub
454
- */
455
- PicoNowDefaultInstance.prototype.subDates = function (value) {
446
+ // @ts-ignore
447
+ PicoNowDefault.prototype.subDates = function (value : any) {
456
448
  console.warn('Now.subDates() is deprecated, use Now.sub(value, \'date\') instead.');
457
449
  return this.sub(value, 'date');
458
450
  }
459
451
 
460
- /**
461
- * @see PicoNow.add
462
- */
463
- PicoNowDefaultInstance.prototype.addMonths = function (value) {
452
+ // @ts-ignore
453
+ PicoNowDefault.prototype.addMonths = function (value : any) {
464
454
  console.warn('Now.addMonths() is deprecated, use Now.add(value, \'month\') instead.');
465
455
  return this.add(value, 'month');
466
456
  }
467
457
 
468
- /**
469
- * @see PicoNow.sub
470
- */
471
- PicoNowDefaultInstance.prototype.subMonths = function (value) {
458
+ // @ts-ignore
459
+ PicoNowDefault.prototype.subMonths = function (value : any) {
472
460
  console.warn('Now.subMonths() is deprecated, use Now.sub(value, \'month\') instead.');
473
461
  return this.sub(value, 'month');
474
462
  }
475
463
 
476
- /**
477
- * @see PicoNow.add
478
- */
479
- PicoNowDefaultInstance.prototype.addYears = function (value) {
464
+ // @ts-ignore
465
+ PicoNowDefault.prototype.addYears = function (value : any) {
480
466
  console.warn('Now.addYears() is deprecated, use Now.add(value, \'year\') instead.');
481
467
  return this.add(value, 'year');
482
468
  }
483
469
 
484
- /**
485
- * @see PicoNow.sub
486
- */
487
- PicoNowDefaultInstance.prototype.subYears = function (value) {
470
+ // @ts-ignore
471
+ PicoNowDefault.prototype.subYears = function (value : any) {
488
472
  console.warn('Now.subYears() is deprecated, use Now.sub(value, \'year\') instead.');
489
473
  return this.sub(value, 'year');
490
474
  }
491
475
 
492
- /**
493
- * @see PicoNow.add
494
- */
495
- PicoNowDefaultInstance.prototype.addDecades = function (value) {
476
+ // @ts-ignore
477
+ PicoNowDefault.prototype.addDecades = function (value : any) {
496
478
  console.warn('Now.addDecades() is deprecated, use Now.grid(10 * value, \'year\') instead.');
497
479
  return this.add(10 * value, 'year');
498
480
  }
499
481
 
500
- /**
501
- * @see PicoNow.sub
502
- */
503
- PicoNowDefaultInstance.prototype.subDecades = function (value) {
482
+ // @ts-ignore
483
+ PicoNowDefault.prototype.subDecades = function (value : any) {
504
484
  console.warn('Now.subDecades() is deprecated, use Now.grid(10 * value, \'year\') instead.');
505
485
  return this.sub(10 * value, 'year');
506
486
  }
507
487
 
508
- /**
509
- * @see PicoNow.day
510
- */
511
- PicoNowDefaultInstance.prototype.humanDay = function () {
488
+ // @ts-ignore
489
+ PicoNowDefault.prototype.humanDay = function () {
512
490
  console.warn('Now.humanDay() is deprecated, use Now.day() instead.');
513
491
  return this.day();
514
492
  }
515
493
 
516
- /**
517
- * @see PicoNow.month
518
- */
519
- PicoNowDefaultInstance.prototype.humanMonth = function () {
494
+ // @ts-ignore
495
+ PicoNowDefault.prototype.humanMonth = function () {
520
496
  console.warn('Now.humanMonth() is deprecated, use Now.month() instead.');
521
497
  return this.month();
522
498
  }
523
499
 
524
- /**
525
- * @param {typeof PicoNow} self
526
- * @returns {typeof PicoNow}
527
- */
528
- export const PicoNowDefaultPlugin = function (self) {
529
-
530
- Obj.each(Mix.proto(PicoNowDefaultInstance), (fn, id) => {
531
- self.prototype[id] = fn;
532
- });
533
-
534
- return self;
535
- }
500
+ export default PicoNowDefault;
@@ -1,7 +1,9 @@
1
- import { Arr, Locale, Mix, Num, Obj, Str } from "../index.esm.js";
2
- import { PicoNow } from "../utils/Now.js";
1
+ import { Locale, Mix, Obj, Str } from "../index.esm.ts";
2
+ import { PicoNow, PicoNowInterface } from "../utils/Now.ts";
3
+ import PicoNowDefault from "./NowDefault.js";
4
+ import PicoNowHuman from "./NowHuman.js";
3
5
 
4
- export const NOW_FORMAT = {
6
+ export const NOW_FORMAT : any = {
5
7
  'L': 'DD/MM/YYYY',
6
8
  'LL': 'MMMM DD, YYYY',
7
9
  'LLL': 'MMMM DD, YYYY HH:mm',
@@ -11,7 +13,7 @@ export const NOW_FORMAT = {
11
13
  'LTSD': 'DD/MM/YYYY HH:mm:ss',
12
14
  }
13
15
 
14
- export const NOW_PARSE = {
16
+ export const NOW_PARSE : any = {
15
17
  'second': 'ss',
16
18
  'minute': 'mm',
17
19
  'hour': 'HH',
@@ -20,13 +22,17 @@ export const NOW_PARSE = {
20
22
  'year': 'YYYY'
21
23
  };
22
24
 
25
+ export interface PicoNowFormat extends PicoNowInterface,
26
+ PicoNowDefault, PicoNowHuman
27
+ {
28
+ //
29
+ }
30
+
23
31
  /**
24
32
  * @memberof PicoNow
25
- * @extends {PicoNow}
26
33
  */
27
- export class PicoNowFormatInstance
34
+ export class PicoNowFormat
28
35
  {
29
-
30
36
  /**
31
37
  * Check if value matches format
32
38
  *
@@ -36,7 +42,7 @@ export class PicoNowFormatInstance
36
42
  * @param {string} [format] Date format
37
43
  * @returns {boolean} Is parsable
38
44
  */
39
- isParsable(value, format = 'YYYY-MM-DD HH:mm:ss')
45
+ isParsable(value : string, format : string = 'YYYY-MM-DD HH:mm:ss') : boolean
40
46
  {
41
47
  for ( const key in NOW_PARSE ) {
42
48
  value = Str.replace(value, NOW_PARSE[key], format);
@@ -54,7 +60,7 @@ export class PicoNowFormatInstance
54
60
  * @param {string} [format] Input format
55
61
  * @returns {PicoNow} Current instance
56
62
  */
57
- parse(value, format = 'YYYY-MM-DD HH:mm:ss')
63
+ parse(value : any, format : string = 'YYYY-MM-DD HH:mm:ss') : PicoNow
58
64
  {
59
65
  if ( Mix.isTime(value) ) {
60
66
  format = 'HH:mm:ss';
@@ -68,13 +74,13 @@ export class PicoNowFormatInstance
68
74
  return this.modify(value);
69
75
  }
70
76
 
71
- if ( ! Mix.isIsoDate(value) ) {
77
+ if ( !Mix.isIsoDate(value) ) {
72
78
  return this.parseFormat(value, format);
73
79
  }
74
80
 
75
81
  this.value = new Date(value);
76
82
 
77
- return this;
83
+ return <PicoNow> <unknown> this;
78
84
  }
79
85
 
80
86
  /**
@@ -86,17 +92,17 @@ export class PicoNowFormatInstance
86
92
  * @param {string} format Input format
87
93
  * @returns {PicoNow} Current instance
88
94
  */
89
- parseFormat(value, format)
95
+ parseFormat(value : string, format : string) : PicoNow
90
96
  {
91
97
  if ( !this.isParsable(value, format) ) {
92
- return (this.value = new Date(NaN), this);
98
+ return <PicoNow> <unknown> (this.value = new Date(NaN), this);
93
99
  }
94
100
 
95
101
  for ( const key in NOW_PARSE ) {
96
102
  this.set(Str.extract(value, NOW_PARSE[key], format), key);
97
103
  }
98
104
 
99
- return this;
105
+ return <PicoNow> <unknown> this;
100
106
  }
101
107
 
102
108
  /**
@@ -107,7 +113,7 @@ export class PicoNowFormatInstance
107
113
  * @param {string} [format] Output format
108
114
  * @returns {string} Formatted string
109
115
  */
110
- format(format = 'YYYY-MM-DD HH:mm:ss')
116
+ format(format : string = 'YYYY-MM-DD HH:mm:ss') : string
111
117
  {
112
118
  if ( Obj.has(NOW_FORMAT, format) ) {
113
119
  format = Locale.$text[format] ?? NOW_FORMAT[format];
@@ -180,22 +186,11 @@ export class PicoNowFormatInstance
180
186
  * @param {string} [format] Output format
181
187
  * @returns {number} Formatted integer
182
188
  */
183
- code(format = 'X')
189
+ code(format : string = 'X') : number
184
190
  {
185
191
  return Mix.int(this.format(format));
186
192
  }
187
193
 
188
194
  }
189
195
 
190
- /**
191
- * @param {typeof PicoNow} self
192
- * @returns {typeof PicoNow}
193
- */
194
- export const PicoNowFormatPlugin = function (self) {
195
-
196
- Obj.each(Mix.proto(PicoNowFormatInstance), (fn, id) => {
197
- self.prototype[id] = fn;
198
- });
199
-
200
- return self;
201
- }
196
+ export default PicoNowFormat;