@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.
Files changed (125) hide show
  1. package/README.md +27 -7
  2. package/dist/pico-js.browser.js +2 -0
  3. package/dist/pico-js.browser.js.map +1 -0
  4. package/dist/pico-js.esm.js +2 -0
  5. package/dist/pico-js.esm.js.map +1 -0
  6. package/package.json +20 -7
  7. package/src/dom/DomAttribute.js +374 -0
  8. package/src/dom/DomBuilder.js +152 -0
  9. package/src/dom/DomEvent.js +253 -0
  10. package/src/dom/DomFinder.js +669 -0
  11. package/src/dom/DomForm.js +57 -0
  12. package/src/dom/DomGlobal.js +193 -0
  13. package/src/dom/DomInview.js +332 -0
  14. package/src/dom/DomMeta.js +66 -0
  15. package/src/dom/DomObserver.js +57 -0
  16. package/src/dom/DomRectangle.js +657 -0
  17. package/src/format/FormatFile.js +54 -0
  18. package/src/format/FormatOption.js +108 -0
  19. package/src/format/FormatParam.js +107 -0
  20. package/src/format/FormatParser.js +156 -0
  21. package/src/format/FormatUrl.js +75 -0
  22. package/src/index.browser.js +10 -0
  23. package/src/index.esm.js +138 -0
  24. package/src/now/NowDefault.js +533 -0
  25. package/src/now/NowFormat.js +196 -0
  26. package/src/now/NowGrid.js +251 -0
  27. package/src/now/NowHuman.js +118 -0
  28. package/src/now/NowMatch.js +175 -0
  29. package/src/now/NowRange.js +70 -0
  30. package/src/now/NowWalker.js +544 -0
  31. package/src/tool/scope.js +103 -0
  32. package/src/utils/Array.js +986 -0
  33. package/src/utils/Cookie.js +184 -0
  34. package/src/utils/Data.js +200 -0
  35. package/src/utils/Dom.js +208 -0
  36. package/src/utils/Event.js +140 -0
  37. package/src/utils/Format.js +62 -0
  38. package/src/utils/Hash.js +164 -0
  39. package/src/utils/Locale.js +229 -0
  40. package/src/utils/Mixed.js +887 -0
  41. package/src/utils/Now.js +234 -0
  42. package/src/utils/Number.js +238 -0
  43. package/src/utils/Object.js +655 -0
  44. package/src/utils/Route.js +67 -0
  45. package/src/utils/Runner.js +327 -0
  46. package/src/utils/String.js +618 -0
  47. package/src/{library/element.js → wip/Element.js} +90 -16
  48. package/src/{library/map.js → wip/Map.js} +256 -40
  49. package/types/dom/DomAttribute.d.ts +137 -0
  50. package/types/dom/DomBuilder.d.ts +67 -0
  51. package/types/dom/DomEvent.d.ts +103 -0
  52. package/types/dom/DomFinder.d.ts +321 -0
  53. package/types/dom/DomForm.d.ts +21 -0
  54. package/types/dom/DomGlobal.d.ts +79 -0
  55. package/types/dom/DomInview.d.ts +114 -0
  56. package/types/dom/DomMeta.d.ts +29 -0
  57. package/types/dom/DomObserver.d.ts +21 -0
  58. package/types/dom/DomRectangle.d.ts +270 -0
  59. package/types/format/FormatFile.d.ts +18 -0
  60. package/types/format/FormatOption.d.ts +40 -0
  61. package/types/format/FormatParam.d.ts +39 -0
  62. package/types/format/FormatParser.d.ts +46 -0
  63. package/types/format/FormatUrl.d.ts +17 -0
  64. package/types/index.browser.d.ts +1 -0
  65. package/types/index.esm.d.ts +52 -0
  66. package/types/now/NowDefault.d.ts +183 -0
  67. package/types/now/NowFormat.d.ts +70 -0
  68. package/types/now/NowGrid.d.ts +107 -0
  69. package/types/now/NowHuman.d.ts +37 -0
  70. package/types/now/NowMatch.d.ts +108 -0
  71. package/types/now/NowRange.d.ts +21 -0
  72. package/types/now/NowWalker.d.ts +301 -0
  73. package/types/tool/scope.d.ts +24 -0
  74. package/types/utils/Array.d.ts +480 -0
  75. package/types/utils/Cookie.d.ts +60 -0
  76. package/types/utils/Data.d.ts +91 -0
  77. package/types/utils/Dom.d.ts +138 -0
  78. package/types/utils/Event.d.ts +58 -0
  79. package/types/utils/Format.d.ts +37 -0
  80. package/types/utils/Hash.d.ts +81 -0
  81. package/types/utils/Locale.d.ts +115 -0
  82. package/types/utils/Mixed.d.ts +469 -0
  83. package/types/utils/Now.d.ts +125 -0
  84. package/types/utils/Number.d.ts +127 -0
  85. package/types/utils/Object.d.ts +255 -0
  86. package/types/utils/Route.d.ts +37 -0
  87. package/types/utils/Runner.d.ts +139 -0
  88. package/types/utils/String.d.ts +330 -0
  89. package/types/wip/Element.d.ts +119 -0
  90. package/types/wip/Map.d.ts +254 -0
  91. package/dist/.ignore.js +0 -0
  92. package/dist/pico-js.js +0 -2
  93. package/dist/pico-js.js.map +0 -1
  94. package/src/element/default.js +0 -46
  95. package/src/element/example.js +0 -58
  96. package/src/index.js +0 -90
  97. package/src/library/cookie.js +0 -123
  98. package/src/library/data.js +0 -111
  99. package/src/library/event.js +0 -91
  100. package/src/library/locale.js +0 -84
  101. package/src/library/queue.js +0 -64
  102. package/src/library/route.js +0 -28
  103. package/src/utility/any.js +0 -369
  104. package/src/utility/array.js +0 -410
  105. package/src/utility/dom.js +0 -1425
  106. package/src/utility/now.js +0 -544
  107. package/src/utility/number.js +0 -128
  108. package/src/utility/object.js +0 -429
  109. package/src/utility/string.js +0 -328
  110. package/types/index.d.ts +0 -77
  111. package/types/library/cookie.d.ts +0 -10
  112. package/types/library/data.d.ts +0 -15
  113. package/types/library/element.d.ts +0 -22
  114. package/types/library/event.d.ts +0 -13
  115. package/types/library/locale.d.ts +0 -14
  116. package/types/library/map.d.ts +0 -43
  117. package/types/library/queue.d.ts +0 -18
  118. package/types/library/route.d.ts +0 -11
  119. package/types/utility/any.d.ts +0 -35
  120. package/types/utility/array.d.ts +0 -46
  121. package/types/utility/dom.d.ts +0 -101
  122. package/types/utility/now.d.ts +0 -79
  123. package/types/utility/number.d.ts +0 -17
  124. package/types/utility/object.d.ts +0 -29
  125. package/types/utility/string.d.ts +0 -26
@@ -0,0 +1,480 @@
1
+ export class PicoArray {
2
+ /**
3
+ * Wrap value into an array
4
+ *
5
+ * @example Arr.all(1) // => [1]
6
+ * @example Arr.all([1]) // => [1]
7
+ *
8
+ * @param {any} value Value to wrap
9
+ * @returns {Array<any>} Wrapped array
10
+ */
11
+ static all(value: any): Array<any>;
12
+ /**
13
+ * Get item at index or fallback
14
+ *
15
+ * @example Arr.get(["a"], 0) // => "a"
16
+ * @example Arr.get(["a"], 9, null) // => null
17
+ *
18
+ * @param {any} value Array-like value
19
+ * @param {number} index Index to read
20
+ * @param {any} [fallback] Fallback value
21
+ * @returns {any} Item or fallback
22
+ */
23
+ static get(value: any, index: number, fallback?: any): any;
24
+ /**
25
+ * Set item at index (mutates)
26
+ *
27
+ * @example Arr.set([1,2], 0, 9) // => [9,2]
28
+ *
29
+ * @param {Array<any>} target Target array
30
+ * @param {number} index Index to set
31
+ * @param {any} value Value to set
32
+ * @returns {any} Splice result
33
+ */
34
+ static set(target: Array<any>, index: number, value: any): any;
35
+ /**
36
+ * Remove item at index (mutates)
37
+ *
38
+ * @example Arr.unset([1,2], 0) // => [1]
39
+ *
40
+ * @param {Array<any>} target Target array
41
+ * @param {number} index Index to remove
42
+ * @returns {any} Splice result
43
+ */
44
+ static unset(target: Array<any>, index: number): any;
45
+ /**
46
+ * Create array with callback values
47
+ *
48
+ * @example Arr.make(3) // => [0,1,2]
49
+ * @example Arr.make(2, "x") // => ["x","x"]
50
+ *
51
+ * @param {number} length Array length
52
+ * @param {any} [cb] Value or mapper
53
+ * @returns {Array<any>} Generated array
54
+ */
55
+ static make(length: number, cb?: any): Array<any>;
56
+ /**
57
+ * Check if array has value
58
+ *
59
+ * @example Arr.has([1,2], 2) // => true
60
+ * @example Arr.has([{id:1}], {id:1}) // => true
61
+ *
62
+ * @param {any} value List to search
63
+ * @param {any} search Search value
64
+ * @returns {boolean} True if found
65
+ */
66
+ static has(value: any, search: any): boolean;
67
+ /**
68
+ * Get unique values as strings
69
+ *
70
+ * @example Arr.unique(["a","a"]) // => ["a"]
71
+ *
72
+ * @param {Array<any>} value Input list
73
+ * @returns {Array<any>} Unique list
74
+ */
75
+ static unique(value: Array<any>): Array<any>;
76
+ /**
77
+ * Check equal lengths for arrays
78
+ *
79
+ * @example Arr.lengths([1],[2]) // => true
80
+ *
81
+ * @param {Array<any>} value Base array
82
+ * @param {...Array<any>} args Other arrays
83
+ * @returns {boolean} True if equal
84
+ */
85
+ static lengths(value: Array<any>, ...args: Array<any>[]): boolean;
86
+ /**
87
+ * Get first item or fallback
88
+ *
89
+ * @example Arr.first([1,2]) // => 1
90
+ *
91
+ * @param {Array<any>} value Input array
92
+ * @param {any} [fallback] Fallback value
93
+ * @returns {any} First item
94
+ */
95
+ static first(value: Array<any>, fallback?: any): any;
96
+ /**
97
+ * Get second item or fallback
98
+ *
99
+ * @example Arr.second([1,2]) // => 2
100
+ *
101
+ * @param {Array<any>} value Input array
102
+ * @param {any} [fallback] Fallback value
103
+ * @returns {any} Second item
104
+ */
105
+ static second(value: Array<any>, fallback?: any): any;
106
+ /**
107
+ * Get third item or fallback
108
+ *
109
+ * @example Arr.third([1,2,3]) // => 3
110
+ *
111
+ * @param {Array<any>} value Input array
112
+ * @param {any} [fallback] Fallback value
113
+ * @returns {any} Third item
114
+ */
115
+ static third(value: Array<any>, fallback?: any): any;
116
+ /**
117
+ * Get last item or fallback
118
+ *
119
+ * @example Arr.last([1,2]) // => 2
120
+ *
121
+ * @param {Array<any>} value Input array
122
+ * @param {any} [fallback] Fallback value
123
+ * @returns {any} Last item
124
+ */
125
+ static last(value: Array<any>, fallback?: any): any;
126
+ /**
127
+ * Map values to new array
128
+ *
129
+ * @example Arr.each([1], v => v+1) // => [2]
130
+ *
131
+ * @param {any} value Input list
132
+ * @param {function} cb Map callback
133
+ * @param {any} [retval] Forced return
134
+ * @returns {any} Mapped array
135
+ */
136
+ static each(value: any, cb: Function, retval?: any): any;
137
+ /**
138
+ * Map values in place (mutates)
139
+ *
140
+ * @example Arr.map([1], v => v+1) // => [2]
141
+ *
142
+ * @param {any} value Input list
143
+ * @param {function} cb Map callback
144
+ * @returns {any} Mutated input
145
+ */
146
+ static map(value: any, cb: Function): any;
147
+ /**
148
+ * Recursively map nested arrays
149
+ *
150
+ * @example Arr.recursive([{c:[]}], "c", () => 1) // => list
151
+ *
152
+ * @param {any} value Input list
153
+ * @param {string} key Child key
154
+ * @param {function} cb Node callback
155
+ * @param {Array<any>} [cascade] Parent chain
156
+ * @returns {any} Mapped tree
157
+ */
158
+ static recursive(value: any, key: string, cb: Function, cascade?: Array<any>): any;
159
+ /**
160
+ * Get matching indexes by filter
161
+ *
162
+ * @example Arr.filterIndex([0,1], v => v) // => ["1"]
163
+ *
164
+ * @param {any} value Input list
165
+ * @param {any} [filter] Filter spec
166
+ * @returns {Array<string>} Matching keys
167
+ */
168
+ static filterIndex(value: any, filter?: any): Array<string>;
169
+ /**
170
+ * Filter values by filter
171
+ *
172
+ * @example Arr.filter([0,1], v => v) // => [1]
173
+ *
174
+ * @param {any} value Input list
175
+ * @param {any} [filter] Filter spec
176
+ * @returns {Array<any>} Filtered values
177
+ */
178
+ static filter(value: any, filter?: any): Array<any>;
179
+ /**
180
+ * Find index matching filter
181
+ *
182
+ * @example Arr.findIndex([1,2], 2) // => 1
183
+ *
184
+ * @param {Array<any>} value Input array
185
+ * @param {any} [filter] Filter spec
186
+ * @param {number} [fallback] Fallback index
187
+ * @returns {number} Found index
188
+ */
189
+ static findIndex(value: Array<any>, filter?: any, fallback?: number): number;
190
+ /**
191
+ * Find value matching filter
192
+ *
193
+ * @example Arr.find([1,2], 2) // => 2
194
+ *
195
+ * @param {Array<any>} value Input array
196
+ * @param {any} [filter] Filter spec
197
+ * @param {any} [fallback] Fallback value
198
+ * @returns {any} Found value
199
+ */
200
+ static find(value: Array<any>, filter?: any, fallback?: any): any;
201
+ /**
202
+ * Sort array by key or callback
203
+ *
204
+ * @example Arr.sort([{n:2},{n:1}], "n") // => list
205
+ *
206
+ * @param {any} value Input list
207
+ * @param {any} [key] Key or compare fn
208
+ * @returns {Array<any>} Sorted list
209
+ */
210
+ static sort(value: any, key?: any): Array<any>;
211
+ /**
212
+ * Sort by compare callback
213
+ *
214
+ * @example Arr.sortFunc([2,1], (a,b)=>a-b) // => [1,2]
215
+ *
216
+ * @param {any} value Input list
217
+ * @param {function} cb Compare callback
218
+ * @returns {Array<any>} Sorted list
219
+ */
220
+ static sortFunc(value: any, cb: Function): Array<any>;
221
+ /**
222
+ * Sort by nested key value
223
+ *
224
+ * @example Arr.sortDeep([{a:{n:2}},{a:{n:1}}], "a.n") // => list
225
+ *
226
+ * @param {any} value Input list
227
+ * @param {any} key Key path
228
+ * @returns {Array<any>} Sorted list
229
+ */
230
+ static sortDeep(value: any, key: any): Array<any>;
231
+ /**
232
+ * Sort by primitive key order
233
+ *
234
+ * @example Arr.sortPrim(["b","a"]) // => ["a","b"]
235
+ *
236
+ * @param {any} value Input list
237
+ * @returns {Array<any>} Sorted list
238
+ */
239
+ static sortPrim(value: any): Array<any>;
240
+ /**
241
+ * Merge arrays (concat)
242
+ *
243
+ * @example Arr.merge([1],[2]) // => [1,2]
244
+ *
245
+ * @param {Array<any>} value Base array
246
+ * @param {...any} args Arrays to add
247
+ * @returns {Array<any>} Merged array
248
+ */
249
+ static merge(value: Array<any>, ...args: any[]): Array<any>;
250
+ /**
251
+ * Prepend items (mutates)
252
+ *
253
+ * @example Arr.prepend([2], 1) // => [1,2]
254
+ *
255
+ * @param {Array<any>} value Target array
256
+ * @param {...any} args Items to add
257
+ * @returns {Array<any>} Mutated array
258
+ */
259
+ static prepend(value: Array<any>, ...args: any[]): Array<any>;
260
+ /**
261
+ * Append items (mutates)
262
+ *
263
+ * @example Arr.append([1], 2) // => [1,2]
264
+ *
265
+ * @param {Array<any>} value Target array
266
+ * @param {...any} args Items to add
267
+ * @returns {Array<any>} Mutated array
268
+ */
269
+ static append(value: Array<any>, ...args: any[]): Array<any>;
270
+ /**
271
+ * Add item if not present
272
+ *
273
+ * @example Arr.add([1], 2) // => [1,2]
274
+ *
275
+ * @param {Array<any>} value Target array
276
+ * @param {any} target Item to add
277
+ * @param {any} [finder] Finder value
278
+ * @returns {Array<any>} Mutated array
279
+ */
280
+ static add(value: Array<any>, target: any, finder?: any): Array<any>;
281
+ /**
282
+ * Replace existing item or add
283
+ *
284
+ * @example Arr.replace([1], 2) // => [1,2]
285
+ *
286
+ * @param {Array<any>} value Target array
287
+ * @param {any} target Item to add
288
+ * @param {any} [finder] Finder value
289
+ * @returns {Array<any>} Mutated array
290
+ */
291
+ static replace(value: Array<any>, target: any, finder?: any): Array<any>;
292
+ /**
293
+ * Remove item if present
294
+ *
295
+ * @example Arr.remove([1,2], 1) // => [2]
296
+ *
297
+ * @param {Array<any>} value Target array
298
+ * @param {any} target Item to remove
299
+ * @param {any} [finder] Finder value
300
+ * @returns {Array<any>} Mutated array
301
+ */
302
+ static remove(value: Array<any>, target: any, finder?: any): Array<any>;
303
+ /**
304
+ * Toggle item in array
305
+ *
306
+ * @example Arr.toggle([1], 1) // => []
307
+ * @example Arr.toggle([], 1) // => [1]
308
+ *
309
+ * @param {Array<any>} value Target array
310
+ * @param {any} target Item to toggle
311
+ * @param {any} [finder] Finder value
312
+ * @returns {Array<any>} Mutated array
313
+ */
314
+ static toggle(value: Array<any>, target: any, finder?: any): Array<any>;
315
+ /**
316
+ * Insert item at index (mutates)
317
+ *
318
+ * @example Arr.insert([1,3], 1, 2) // => [1,2,3]
319
+ *
320
+ * @param {Array<any>} value Target array
321
+ * @param {number} index Insert index
322
+ * @param {any} target Item to insert
323
+ * @returns {Array<any>} Mutated array
324
+ */
325
+ static insert(value: Array<any>, index: number, target: any): Array<any>;
326
+ /**
327
+ * Slice array from index
328
+ *
329
+ * @example Arr.slice([1,2,3], 1, 2) // => [2,3]
330
+ *
331
+ * @param {Array<any>} value Source array
332
+ * @param {number} index Start index
333
+ * @param {number} [length] Slice length
334
+ * @returns {Array<any>} Sliced array
335
+ */
336
+ static slice(value: Array<any>, index: number, length?: number): Array<any>;
337
+ /**
338
+ * Splice array (mutates)
339
+ *
340
+ * @example Arr.splice([1,2], 0, 1) // => [1]
341
+ *
342
+ * @param {Array<any>} value Target array
343
+ * @param {number} index Start index
344
+ * @param {number} [length] Remove count
345
+ * @param {...any} args Items to add
346
+ * @returns {any} Splice result
347
+ */
348
+ static splice(value: Array<any>, index: number, length?: number, ...args: any[]): any;
349
+ /**
350
+ * Splice multiple indexes
351
+ *
352
+ * @example Arr.splices([1,2,3],[0,2]) // => [2]
353
+ *
354
+ * @param {Array<any>} value Target array
355
+ * @param {Array<number>} indexies Index list
356
+ * @param {number} [length] Remove count
357
+ * @returns {Array<any>} Mutated array
358
+ */
359
+ static splices(value: Array<any>, indexies: Array<number>, length?: number): Array<any>;
360
+ /**
361
+ * Deep clone array/object
362
+ *
363
+ * @example Arr.clone([1,{a:1}]) // => new array
364
+ *
365
+ * @param {any} value Value to clone
366
+ * @returns {any} Cloned value
367
+ */
368
+ static clone(value: any): any;
369
+ /**
370
+ * Get items not in others
371
+ *
372
+ * @example Arr.diff([1,2],[2]) // => [1]
373
+ *
374
+ * @param {...Array<any>} args Arrays to diff
375
+ * @returns {Array<any>} Difference list
376
+ */
377
+ static diff(...args: Array<any>[]): Array<any>;
378
+ /**
379
+ * Get intersecting items
380
+ *
381
+ * @example Arr.isect([1,2],[2,3]) // => [2]
382
+ *
383
+ * @param {...Array<any>} args Arrays to intersect
384
+ * @returns {Array<any>} Intersection list
385
+ */
386
+ static isect(...args: Array<any>[]): Array<any>;
387
+ /**
388
+ * Extract property values from list
389
+ *
390
+ * @example Arr.extract([{id:1}], "id") // => [1]
391
+ *
392
+ * @param {Array<any>} value Input list
393
+ * @param {any} key Key path
394
+ * @returns {Array<any>} Extracted list
395
+ */
396
+ static extract(value: Array<any>, key: any): Array<any>;
397
+ /**
398
+ * Reduce list values
399
+ *
400
+ * @example Arr.reduce([1,2], (a,c)=>a+c, 0) // => 3
401
+ *
402
+ * @param {any} value Input list
403
+ * @param {function} callback Reducer callback
404
+ * @param {any} accumulator Start value
405
+ * @returns {any} Reduced value
406
+ */
407
+ static reduce(value: any, callback: Function, accumulator: any): any;
408
+ /**
409
+ * Split array into chunks
410
+ *
411
+ * @example Arr.chunk([1,2,3], 2) // => [[1,2],[3]]
412
+ *
413
+ * @param {Array<any>} value Source array
414
+ * @param {number} [chunk] Chunk size
415
+ * @returns {Array<Array<any>>} Chunked list
416
+ */
417
+ static chunk(value: Array<any>, chunk?: number): Array<Array<any>>;
418
+ /**
419
+ * Check if value includes search
420
+ *
421
+ * @example Arr.includes([1,2], 2) // => true
422
+ * @example Arr.includes([{a:1}], {a:1}) // => true
423
+ *
424
+ * @param {any} value Target value
425
+ * @param {any} search Search spec
426
+ * @returns {boolean} True if includes
427
+ */
428
+ static includes(value: any, search: any): boolean;
429
+ /**
430
+ * Check array contains all values
431
+ *
432
+ * @example Arr.contains([1,2], [2]) // => true
433
+ *
434
+ * @param {any} arr Target array
435
+ * @param {any} val Required values
436
+ * @returns {boolean} True if contains
437
+ */
438
+ static contains(arr: any, val: any): boolean;
439
+ /**
440
+ * Check arrays match (set-like)
441
+ *
442
+ * @example Arr.matches([1,2], [2,1]) // => true
443
+ *
444
+ * @param {any} value Target list
445
+ * @param {any} search Search spec
446
+ * @returns {boolean} True if matches
447
+ */
448
+ static matches(value: any, search: any): boolean;
449
+ }
450
+ export namespace PicoArray {
451
+ /**
452
+ * @see PicoArray.unset
453
+ */
454
+ function removeIndex(...args: any[]): any;
455
+ /**
456
+ * @see PicoArray.sortPrim
457
+ */
458
+ function sortString(...args: any[]): any[];
459
+ /**
460
+ * @see PicoArray.append
461
+ */
462
+ function push(...args: any[]): any[];
463
+ /**
464
+ * @see PicoArray.merge
465
+ */
466
+ function concat(...args: any[]): any[];
467
+ /**
468
+ * @see PicoArray.matches
469
+ */
470
+ function equal(...args: any[]): boolean;
471
+ /**
472
+ * @see PicoArray.diff
473
+ */
474
+ function diffrence(...args: any[]): any[];
475
+ /**
476
+ * @see PicoArray.isect
477
+ */
478
+ function intersect(...args: any[]): any[];
479
+ }
480
+ export default PicoArray;
@@ -0,0 +1,60 @@
1
+ export namespace COOKIE_REGEX {
2
+ let entry: RegExp;
3
+ }
4
+ export class PicoCookie {
5
+ static $cookie: any;
6
+ /**
7
+ * Read raw document.cookie
8
+ *
9
+ * @example Cookie.global() // => "a=b; c=d"
10
+ *
11
+ * @returns {string} Cookie string
12
+ */
13
+ static global(): string;
14
+ /**
15
+ * Parse cookies into object
16
+ *
17
+ * @example Cookie.parse() // => {a:"b"}
18
+ * @example Cookie.parse(true) // force parse
19
+ *
20
+ * @param {boolean} [fresh] Force refresh
21
+ * @returns {Record<string, any>} Cookie map
22
+ */
23
+ static parse(fresh?: boolean): Record<string, any>;
24
+ /**
25
+ * Get cookie value by key
26
+ *
27
+ * @example Cookie.get("foo") // => "bar"
28
+ * @example Cookie.get("x", null, "bool") // => true
29
+ *
30
+ * @param {string} key Cookie key
31
+ * @param {any} [fallback] Fallback value
32
+ * @param {string} [decode] Decode mode
33
+ * @returns {any} Cookie value
34
+ */
35
+ static get(key: string, fallback?: any, decode?: string): any;
36
+ /**
37
+ * Set cookie value with options
38
+ *
39
+ * @example Cookie.set("a", "b") // => Cookie
40
+ * @example Cookie.set("a", {x:1}) // => Cookie
41
+ *
42
+ * @param {string} key Cookie key
43
+ * @param {any} value Cookie value
44
+ * @param {any} [expire] Expire date spec
45
+ * @param {any} [options] Cookie options
46
+ * @returns {typeof PicoCookie} Cookie class
47
+ */
48
+ static set(key: string, value: any, expire?: any, options?: any): typeof PicoCookie;
49
+ /**
50
+ * Remove cookie by key
51
+ *
52
+ * @example Cookie.forget("a") // => Cookie
53
+ *
54
+ * @param {string} key Cookie key
55
+ * @param {any} [options] Cookie options
56
+ * @returns {typeof PicoCookie} Cookie class
57
+ */
58
+ static forget(key: string, options?: any): typeof PicoCookie;
59
+ }
60
+ export default PicoCookie;
@@ -0,0 +1,91 @@
1
+ export class PicoData {
2
+ /**
3
+ * In-memory data store
4
+ *
5
+ * @type {Record<string, any>}
6
+ */
7
+ static $data: Record<string, any>;
8
+ /**
9
+ * Check if store key exists
10
+ *
11
+ * @example Data.has(["x"]) // => true|false
12
+ *
13
+ * @param {any} input Store key input
14
+ * @returns {boolean} True if exists
15
+ */
16
+ static has(input: any): boolean;
17
+ /**
18
+ * Set store key and fire event
19
+ *
20
+ * @example Data.set(["x"], 1)
21
+ * @example Data.set(["x"], {a:1})
22
+ *
23
+ * @param {any} input Store key input
24
+ * @param {any} value Value to set
25
+ * @returns {void} No return value
26
+ */
27
+ static set(input: any, value: any): void;
28
+ /**
29
+ * Remove store key
30
+ *
31
+ * @example Data.unset(["x"])
32
+ *
33
+ * @param {any} input Store key input
34
+ * @returns {void} No return value
35
+ */
36
+ static unset(input: any): void;
37
+ /**
38
+ * Get stored value (cloned)
39
+ *
40
+ * @example Data.get(["x"], null) // => value
41
+ * @example Data.get(["x"], 1, true) // set+get
42
+ *
43
+ * @param {any} input Store key input
44
+ * @param {any} [fallback] Fallback value
45
+ * @param {boolean} [forceSet] Set if missing
46
+ * @returns {any} Stored value
47
+ */
48
+ static get(input: any, fallback?: any, forceSet?: boolean): any;
49
+ /**
50
+ * Find item by id in array store
51
+ *
52
+ * @example Data.find(["list"], {id:1})
53
+ *
54
+ * @param {any} input Store key input
55
+ * @param {any} value Search value
56
+ * @param {any} [fallback] Fallback value
57
+ * @returns {any} Found item
58
+ */
59
+ static find(input: any, value: any, fallback?: any): any;
60
+ /**
61
+ * Replace item by id in array store
62
+ *
63
+ * @example Data.replace(["list"], {id:1})
64
+ *
65
+ * @param {any} input Store key input
66
+ * @param {any} value Item to replace
67
+ * @returns {void} No return value
68
+ */
69
+ static replace(input: any, value: any): void;
70
+ /**
71
+ * Add items to array store
72
+ *
73
+ * @example Data.add(["list"], 1, 2)
74
+ *
75
+ * @param {any} input Store key input
76
+ * @param {...any} args Items to add
77
+ * @returns {void} No return value
78
+ */
79
+ static add(input: any, ...args: any[]): void;
80
+ /**
81
+ * Remove items from array store
82
+ *
83
+ * @example Data.remove(["list"], 1)
84
+ *
85
+ * @param {any} input Store key input
86
+ * @param {...any} args Items to remove
87
+ * @returns {void} No return value
88
+ */
89
+ static remove(input: any, ...args: any[]): void;
90
+ }
91
+ export default PicoData;