tiny-essentials 1.21.5 → 1.21.6
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/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/libs/TinyHtml.cjs +15 -11
- package/dist/v1/libs/TinyHtml.d.mts +6 -4
- package/dist/v1/libs/TinyHtml.mjs +15 -9
- package/docs/v1/libs/TinyHtml.md +2 -4
- package/package.json +1 -1
|
@@ -3906,7 +3906,8 @@ class TinyHtml {
|
|
|
3906
3906
|
*/
|
|
3907
3907
|
static setBigInt(el, value) {
|
|
3908
3908
|
if (typeof value !== 'bigint') throw new Error('Value is not a valid BigInt.');
|
|
3909
|
-
|
|
3909
|
+
const data = value.toString();
|
|
3910
|
+
TinyHtml._preElems(el, 'setBigInt').forEach((el) => (el.textContent = data));
|
|
3910
3911
|
return el;
|
|
3911
3912
|
}
|
|
3912
3913
|
|
|
@@ -3949,7 +3950,8 @@ class TinyHtml {
|
|
|
3949
3950
|
static setDate(el, value) {
|
|
3950
3951
|
if (!(value instanceof Date) || Number.isNaN(value.getTime()))
|
|
3951
3952
|
throw new Error('Value is not a valid Date.');
|
|
3952
|
-
|
|
3953
|
+
const data = value.toISOString();
|
|
3954
|
+
TinyHtml._preElems(el, 'setDate').forEach((el) => (el.textContent = data));
|
|
3953
3955
|
return el;
|
|
3954
3956
|
}
|
|
3955
3957
|
|
|
@@ -3989,25 +3991,26 @@ class TinyHtml {
|
|
|
3989
3991
|
/**
|
|
3990
3992
|
* Set JSON content of elements.
|
|
3991
3993
|
* @param {TinyElement|TinyElement[]} el
|
|
3992
|
-
* @param {any} value
|
|
3994
|
+
* @param {any} value - A JavaScript value, usually an object or array, to be converted.
|
|
3995
|
+
* @param {(this: any, key: string, value: any) => any} [replacer] - A function that transforms the results.
|
|
3993
3996
|
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
3994
3997
|
* @returns {TinyElement|TinyElement[]}
|
|
3995
3998
|
*/
|
|
3996
|
-
static setJson(el, value, space) {
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
);
|
|
3999
|
+
static setJson(el, value, replacer, space) {
|
|
4000
|
+
const data = JSON.stringify(value, replacer, space);
|
|
4001
|
+
TinyHtml._preElems(el, 'setJson').forEach((el) => (el.textContent = data));
|
|
4000
4002
|
return el;
|
|
4001
4003
|
}
|
|
4002
4004
|
|
|
4003
4005
|
/**
|
|
4004
4006
|
* Set JSON content of the element.
|
|
4005
|
-
* @param {any} value
|
|
4007
|
+
* @param {any} value - A JavaScript value, usually an object or array, to be converted.
|
|
4008
|
+
* @param {(this: any, key: string, value: any) => any} [replacer] - A function that transforms the results.
|
|
4006
4009
|
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
4007
4010
|
* @returns {TinyElement|TinyElement[]}
|
|
4008
4011
|
*/
|
|
4009
|
-
setJson(value, space) {
|
|
4010
|
-
return TinyHtml.setJson(this, value, space);
|
|
4012
|
+
setJson(value, replacer, space) {
|
|
4013
|
+
return TinyHtml.setJson(this, value, replacer, space);
|
|
4011
4014
|
}
|
|
4012
4015
|
|
|
4013
4016
|
/**
|
|
@@ -4036,7 +4039,8 @@ class TinyHtml {
|
|
|
4036
4039
|
*/
|
|
4037
4040
|
static setNumber(el, value) {
|
|
4038
4041
|
if (typeof value !== 'number') throw new Error('Value is not a valid number.');
|
|
4039
|
-
|
|
4042
|
+
const data = value.toString();
|
|
4043
|
+
TinyHtml._preElems(el, 'setNumber').forEach((el) => (el.textContent = data));
|
|
4040
4044
|
return el;
|
|
4041
4045
|
}
|
|
4042
4046
|
|
|
@@ -1516,11 +1516,12 @@ declare class TinyHtml {
|
|
|
1516
1516
|
/**
|
|
1517
1517
|
* Set JSON content of elements.
|
|
1518
1518
|
* @param {TinyElement|TinyElement[]} el
|
|
1519
|
-
* @param {any} value
|
|
1519
|
+
* @param {any} value - A JavaScript value, usually an object or array, to be converted.
|
|
1520
|
+
* @param {(this: any, key: string, value: any) => any} [replacer] - A function that transforms the results.
|
|
1520
1521
|
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
1521
1522
|
* @returns {TinyElement|TinyElement[]}
|
|
1522
1523
|
*/
|
|
1523
|
-
static setJson(el: TinyElement | TinyElement[], value: any, space?: number | string): TinyElement | TinyElement[];
|
|
1524
|
+
static setJson(el: TinyElement | TinyElement[], value: any, replacer?: (this: any, key: string, value: any) => any, space?: number | string): TinyElement | TinyElement[];
|
|
1524
1525
|
/**
|
|
1525
1526
|
* Returns the number content of the element.
|
|
1526
1527
|
* @param {TinyElement} el - Target element.
|
|
@@ -2711,11 +2712,12 @@ declare class TinyHtml {
|
|
|
2711
2712
|
toJson(): any | null;
|
|
2712
2713
|
/**
|
|
2713
2714
|
* Set JSON content of the element.
|
|
2714
|
-
* @param {any} value
|
|
2715
|
+
* @param {any} value - A JavaScript value, usually an object or array, to be converted.
|
|
2716
|
+
* @param {(this: any, key: string, value: any) => any} [replacer] - A function that transforms the results.
|
|
2715
2717
|
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
2716
2718
|
* @returns {TinyElement|TinyElement[]}
|
|
2717
2719
|
*/
|
|
2718
|
-
setJson(value: any, space?: number | string): TinyElement | TinyElement[];
|
|
2720
|
+
setJson(value: any, replacer?: (this: any, key: string, value: any) => any, space?: number | string): TinyElement | TinyElement[];
|
|
2719
2721
|
/**
|
|
2720
2722
|
* Returns the number content of the element.
|
|
2721
2723
|
* @returns {number|null} The text content or null if none.
|
|
@@ -3499,7 +3499,8 @@ class TinyHtml {
|
|
|
3499
3499
|
static setBigInt(el, value) {
|
|
3500
3500
|
if (typeof value !== 'bigint')
|
|
3501
3501
|
throw new Error('Value is not a valid BigInt.');
|
|
3502
|
-
|
|
3502
|
+
const data = value.toString();
|
|
3503
|
+
TinyHtml._preElems(el, 'setBigInt').forEach((el) => (el.textContent = data));
|
|
3503
3504
|
return el;
|
|
3504
3505
|
}
|
|
3505
3506
|
/**
|
|
@@ -3539,7 +3540,8 @@ class TinyHtml {
|
|
|
3539
3540
|
static setDate(el, value) {
|
|
3540
3541
|
if (!(value instanceof Date) || Number.isNaN(value.getTime()))
|
|
3541
3542
|
throw new Error('Value is not a valid Date.');
|
|
3542
|
-
|
|
3543
|
+
const data = value.toISOString();
|
|
3544
|
+
TinyHtml._preElems(el, 'setDate').forEach((el) => (el.textContent = data));
|
|
3543
3545
|
return el;
|
|
3544
3546
|
}
|
|
3545
3547
|
/**
|
|
@@ -3577,22 +3579,25 @@ class TinyHtml {
|
|
|
3577
3579
|
/**
|
|
3578
3580
|
* Set JSON content of elements.
|
|
3579
3581
|
* @param {TinyElement|TinyElement[]} el
|
|
3580
|
-
* @param {any} value
|
|
3582
|
+
* @param {any} value - A JavaScript value, usually an object or array, to be converted.
|
|
3583
|
+
* @param {(this: any, key: string, value: any) => any} [replacer] - A function that transforms the results.
|
|
3581
3584
|
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
3582
3585
|
* @returns {TinyElement|TinyElement[]}
|
|
3583
3586
|
*/
|
|
3584
|
-
static setJson(el, value, space) {
|
|
3585
|
-
|
|
3587
|
+
static setJson(el, value, replacer, space) {
|
|
3588
|
+
const data = JSON.stringify(value, replacer, space);
|
|
3589
|
+
TinyHtml._preElems(el, 'setJson').forEach((el) => (el.textContent = data));
|
|
3586
3590
|
return el;
|
|
3587
3591
|
}
|
|
3588
3592
|
/**
|
|
3589
3593
|
* Set JSON content of the element.
|
|
3590
|
-
* @param {any} value
|
|
3594
|
+
* @param {any} value - A JavaScript value, usually an object or array, to be converted.
|
|
3595
|
+
* @param {(this: any, key: string, value: any) => any} [replacer] - A function that transforms the results.
|
|
3591
3596
|
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
3592
3597
|
* @returns {TinyElement|TinyElement[]}
|
|
3593
3598
|
*/
|
|
3594
|
-
setJson(value, space) {
|
|
3595
|
-
return TinyHtml.setJson(this, value, space);
|
|
3599
|
+
setJson(value, replacer, space) {
|
|
3600
|
+
return TinyHtml.setJson(this, value, replacer, space);
|
|
3596
3601
|
}
|
|
3597
3602
|
/**
|
|
3598
3603
|
* Returns the number content of the element.
|
|
@@ -3619,7 +3624,8 @@ class TinyHtml {
|
|
|
3619
3624
|
static setNumber(el, value) {
|
|
3620
3625
|
if (typeof value !== 'number')
|
|
3621
3626
|
throw new Error('Value is not a valid number.');
|
|
3622
|
-
|
|
3627
|
+
const data = value.toString();
|
|
3628
|
+
TinyHtml._preElems(el, 'setNumber').forEach((el) => (el.textContent = data));
|
|
3623
3629
|
return el;
|
|
3624
3630
|
}
|
|
3625
3631
|
/**
|
package/docs/v1/libs/TinyHtml.md
CHANGED
|
@@ -1378,15 +1378,13 @@ element.toJson(); // → { a: 1, b: 2 }
|
|
|
1378
1378
|
|
|
1379
1379
|
---
|
|
1380
1380
|
|
|
1381
|
-
### ✍️ `.setJson(value, space)` / `TinyHtml.setJson(el, value, space)`
|
|
1381
|
+
### ✍️ `.setJson(value, replacer, space)` / `TinyHtml.setJson(el, value, replacer, space)`
|
|
1382
1382
|
|
|
1383
1383
|
Sets the **JSON** content of one or more elements.
|
|
1384
|
-
`space` is optional and can be a number or string for indentation.
|
|
1385
1384
|
|
|
1386
1385
|
```js
|
|
1387
1386
|
element.setJson({ a: 1, b: 2 }); // minified
|
|
1388
|
-
element.setJson({ a: 1, b: 2 }, 2); // 2-space indentation
|
|
1389
|
-
element.setJson({ a: 1, b: 2 }, "\t"); // tab indentation
|
|
1387
|
+
element.setJson({ a: 1, b: 2 }, null, 2); // 2-space indentation
|
|
1390
1388
|
```
|
|
1391
1389
|
|
|
1392
1390
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.6",
|
|
4
4
|
"description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "npm run test:mjs && npm run test:cjs && npm run test:js",
|