@design-edito/tools 0.5.1 → 0.5.3
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/agnostic/arrays/index.d.ts +1 -1
- package/agnostic/arrays/index.js +1 -1
- package/agnostic/colors/index.d.ts +1 -1
- package/agnostic/colors/index.js +1 -1
- package/agnostic/css/index.d.ts +1 -1
- package/agnostic/css/index.js +1 -1
- package/agnostic/html/deep-select/index.js +5 -3
- package/agnostic/html/hyper-json/smart-tags/coalesced/index.d.ts +9 -9
- package/agnostic/html/hyper-json/smart-tags/coalesced/index.js +9 -9
- package/agnostic/html/hyper-json/smart-tags/isolated/index.d.ts +1 -1
- package/agnostic/html/hyper-json/smart-tags/isolated/index.js +1 -1
- package/agnostic/html/index.d.ts +3 -3
- package/agnostic/html/index.js +3 -3
- package/agnostic/index.d.ts +3 -3
- package/agnostic/index.js +3 -3
- package/agnostic/misc/index.d.ts +1 -1
- package/agnostic/misc/index.js +1 -1
- package/agnostic/misc/logs/index.d.ts +1 -1
- package/agnostic/misc/logs/index.js +1 -1
- package/agnostic/numbers/index.d.ts +3 -3
- package/agnostic/numbers/index.js +3 -3
- package/agnostic/objects/index.d.ts +3 -3
- package/agnostic/objects/index.js +3 -3
- package/agnostic/random/index.d.ts +1 -1
- package/agnostic/random/index.js +1 -1
- package/agnostic/strings/index.d.ts +3 -3
- package/agnostic/strings/index.js +3 -3
- package/agnostic/time/dates/format-date/index.d.ts +4 -2
- package/agnostic/time/dates/format-date/index.js +43 -94
- package/agnostic/time/dates/format-date/index.test.js +154 -0
- package/agnostic/time/dates/format-date/parts.d.ts +28 -0
- package/agnostic/time/dates/format-date/parts.js +136 -0
- package/agnostic/time/dates/format-date/types.d.ts +84 -0
- package/agnostic/time/dates/format-date/types.js +1 -0
- package/agnostic/time/duration/format-duration/index.d.ts +42 -0
- package/agnostic/time/duration/format-duration/index.js +94 -0
- package/agnostic/time/duration/format-duration/index.test.d.ts +1 -0
- package/agnostic/time/duration/format-duration/index.test.js +148 -0
- package/agnostic/time/duration/format-duration/parts.d.ts +32 -0
- package/agnostic/time/duration/format-duration/parts.js +107 -0
- package/agnostic/time/duration/format-duration/types.d.ts +93 -0
- package/agnostic/time/duration/format-duration/types.js +1 -0
- package/agnostic/time/duration/index.d.ts +6 -1
- package/agnostic/time/duration/index.js +2 -2
- package/agnostic/time/duration/index.test.d.ts +1 -0
- package/agnostic/time/duration/index.test.js +168 -0
- package/components/BeforeAfter/index.controlled.d.ts +25 -25
- package/components/BeforeAfter/index.controlled.js +47 -53
- package/components/BeforeAfter/index.d.ts +20 -23
- package/components/BeforeAfter/index.js +48 -40
- package/components/Button/index.js +1 -1
- package/components/Clippable/index.d.ts +17 -26
- package/components/Clippable/index.js +21 -23
- package/components/Disclaimer/index.d.ts +29 -22
- package/components/Disclaimer/index.js +29 -24
- package/components/Drawer/index.d.ts +45 -25
- package/components/Drawer/index.js +61 -52
- package/components/EventListener/index.d.ts +4 -5
- package/components/Gallery/index.d.ts +14 -16
- package/components/Gallery/index.js +25 -30
- package/components/Iframe/index.js +2 -2
- package/components/Image/index.d.ts +5 -12
- package/components/Image/index.js +11 -32
- package/components/Input/index.d.ts +23 -19
- package/components/Input/index.js +30 -20
- package/components/JsonEditor/index.d.ts +177 -9
- package/components/JsonEditor/index.js +133 -75
- package/components/JsonEditor/types.d.ts +11 -0
- package/components/JsonEditor/types.js +1 -0
- package/components/JsonEditor/utils.d.ts +8 -0
- package/components/JsonEditor/utils.js +23 -0
- package/components/ListLoader/index.controlled.d.ts +78 -0
- package/components/ListLoader/index.controlled.js +99 -0
- package/components/ListLoader/index.d.ts +69 -0
- package/components/ListLoader/index.js +146 -0
- package/components/ListLoader/utils.d.ts +8 -0
- package/components/ListLoader/utils.js +10 -0
- package/components/Overlayer/index.js +4 -4
- package/components/Paginator/index.d.ts +7 -12
- package/components/Paginator/index.js +7 -11
- package/components/ResizeObserver/index.d.ts +14 -3
- package/components/ResizeObserver/index.js +49 -24
- package/components/ResizeObserver/styles.module.css +0 -0
- package/components/Scrllgngn/index.d.ts +17 -13
- package/components/Scrllgngn/index.js +25 -84
- package/components/Scrllgngn/utils.d.ts +52 -0
- package/components/Scrllgngn/utils.js +102 -0
- package/components/ScrollListener/index.d.ts +43 -28
- package/components/ScrollListener/index.js +59 -79
- package/components/ScrollListener/utils.d.ts +37 -16
- package/components/ScrollListener/utils.js +141 -28
- package/components/Select/index.d.ts +24 -20
- package/components/Select/index.js +30 -20
- package/components/Sequencer/index.controlled.d.ts +16 -26
- package/components/Sequencer/index.controlled.js +15 -12
- package/components/Sequencer/index.d.ts +25 -30
- package/components/Sequencer/index.js +20 -34
- package/components/Subtitles/index.d.ts +29 -5
- package/components/Subtitles/index.js +90 -12
- package/components/Textarea/index.d.ts +26 -20
- package/components/Textarea/index.js +40 -21
- package/components/Theatre/index.d.ts +35 -39
- package/components/Theatre/index.js +46 -58
- package/components/UIModule/index.d.ts +25 -29
- package/components/UIModule/index.js +81 -110
- package/components/Video/index.controlled.d.ts +51 -51
- package/components/Video/index.controlled.js +75 -72
- package/components/Video/index.d.ts +12 -14
- package/components/Video/index.js +41 -86
- package/components/Video/utils.d.ts +35 -3
- package/components/Video/utils.js +37 -14
- package/components/index.d.ts +5 -4
- package/components/index.js +5 -4
- package/components/public-classnames.d.ts +1 -0
- package/components/public-classnames.js +1 -0
- package/components/utils/index.d.ts +22 -0
- package/components/utils/index.js +31 -0
- package/node/@google-cloud/storage/directory/index.d.ts +2 -2
- package/node/@google-cloud/storage/directory/index.js +2 -2
- package/node/@google-cloud/storage/file/index.d.ts +2 -2
- package/node/@google-cloud/storage/file/index.js +2 -2
- package/node/@google-cloud/storage/index.d.ts +1 -1
- package/node/@google-cloud/storage/index.js +1 -1
- package/node/cloud-storage/operations/index.d.ts +2 -2
- package/node/cloud-storage/operations/index.js +2 -2
- package/node/ftps/directory/index.d.ts +1 -1
- package/node/ftps/directory/index.js +1 -1
- package/node/ftps/file/index.d.ts +2 -2
- package/node/ftps/file/index.js +2 -2
- package/node/images/index.d.ts +1 -1
- package/node/images/index.js +1 -1
- package/node/images/transform/operations/index.d.ts +3 -3
- package/node/images/transform/operations/index.js +3 -3
- package/node/index.d.ts +2 -2
- package/node/index.js +2 -2
- package/node/process/index.d.ts +1 -1
- package/node/process/index.js +1 -1
- package/node/sftp/directory/index.d.ts +1 -1
- package/node/sftp/directory/index.js +1 -1
- package/node/sftp/file/index.d.ts +1 -1
- package/node/sftp/file/index.js +1 -1
- package/package.json +27 -5
- package/TODO.md +0 -269
- package/components/BeforeAfter/utils.d.ts +0 -4
- package/components/BeforeAfter/utils.js +0 -9
- package/components/Input/index.controlled.d.ts +0 -42
- package/components/Input/index.controlled.js +0 -54
- package/components/Select/index.controlled.d.ts +0 -43
- package/components/Select/index.controlled.js +0 -54
- package/components/Subtitles/types.d.ts +0 -24
- package/components/Subtitles/utils.d.ts +0 -32
- package/components/Subtitles/utils.js +0 -107
- package/components/Textarea/index.controlled.d.ts +0 -50
- package/components/Textarea/index.controlled.js +0 -75
- /package/{components/Subtitles/types.js → agnostic/time/dates/format-date/index.test.d.ts} +0 -0
- /package/components/{ResizeObserver/style.module.css → ListLoader/styles.module.css} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * as dedupe from './dedupe/index.js'
|
|
2
2
|
export * as findDuplicates from './find-duplicates/index.js'
|
|
3
3
|
export * as isArrayOf from './is-array-of/index.js'
|
|
4
|
-
export * as randomPick from './random-pick/index.js'
|
|
5
4
|
export * as make from './make/index.js'
|
|
5
|
+
export * as randomPick from './random-pick/index.js'
|
|
6
6
|
export * as shuffle from './shuffle/index.js'
|
package/agnostic/arrays/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * as dedupe from './dedupe/index.js'
|
|
2
2
|
export * as findDuplicates from './find-duplicates/index.js'
|
|
3
3
|
export * as isArrayOf from './is-array-of/index.js'
|
|
4
|
-
export * as randomPick from './random-pick/index.js'
|
|
5
4
|
export * as make from './make/index.js'
|
|
5
|
+
export * as randomPick from './random-pick/index.js'
|
|
6
6
|
export * as shuffle from './shuffle/index.js'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * as channels from './channels/index.js'
|
|
2
|
-
export * as convert from './convert/index.js'
|
|
3
2
|
export * as contrast from './contrast/index.js'
|
|
3
|
+
export * as convert from './convert/index.js'
|
|
4
4
|
export * as distance from './distance/index.js'
|
|
5
5
|
export * as grayscale from './grayscale/index.js'
|
|
6
6
|
export * as invert from './invert/index.js'
|
package/agnostic/colors/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * as channels from './channels/index.js'
|
|
2
|
-
export * as convert from './convert/index.js'
|
|
3
2
|
export * as contrast from './contrast/index.js'
|
|
3
|
+
export * as convert from './convert/index.js'
|
|
4
4
|
export * as distance from './distance/index.js'
|
|
5
5
|
export * as grayscale from './grayscale/index.js'
|
|
6
6
|
export * as invert from './invert/index.js'
|
package/agnostic/css/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * as isValidCssClassName from './is-valid-css-class-name/index.js'
|
|
2
1
|
export * as bem from './bem/index.js'
|
|
3
2
|
export * as clss from './clss/index.js'
|
|
4
3
|
export * as generateNiceColor from './generate-nice-color/index.js'
|
|
4
|
+
export * as isValidCssClassName from './is-valid-css-class-name/index.js'
|
|
5
5
|
export * as scale from './scale/index.js'
|
|
6
6
|
export * as stylesSet from './styles-set/index.js'
|
package/agnostic/css/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * as isValidCssClassName from './is-valid-css-class-name/index.js'
|
|
2
1
|
export * as bem from './bem/index.js'
|
|
3
2
|
export * as clss from './clss/index.js'
|
|
4
3
|
export * as generateNiceColor from './generate-nice-color/index.js'
|
|
4
|
+
export * as isValidCssClassName from './is-valid-css-class-name/index.js'
|
|
5
5
|
export * as scale from './scale/index.js'
|
|
6
6
|
export * as stylesSet from './styles-set/index.js'
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as Window from '../../misc/crossenv/window/index.js';
|
|
2
2
|
import { deepGetProperty } from '../../objects/deep-get-property/index.js';
|
|
3
|
+
import { isRecord } from '../../objects/is-record/index.js';
|
|
3
4
|
const yieldToMain = async (windowLike) => {
|
|
4
|
-
const
|
|
5
|
-
|
|
5
|
+
const scheduler = deepGetProperty(windowLike, 'scheduler');
|
|
6
|
+
const yild = isRecord(scheduler) ? scheduler.yield : undefined;
|
|
7
|
+
// `scheduler.yield` must run with `scheduler` as its `this` — a detached reference throws "Illegal invocation".
|
|
6
8
|
if (typeof yild === 'function')
|
|
7
|
-
yild();
|
|
9
|
+
await yild.call(scheduler);
|
|
8
10
|
else
|
|
9
11
|
await new Promise(resolve => { setTimeout(resolve, 0); });
|
|
10
12
|
};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
export * as add from './add/index.js'
|
|
2
2
|
export * as addclass from './addclass/index.js'
|
|
3
3
|
export * as and from './and/index.js'
|
|
4
|
+
export * as append from './append/index.js'
|
|
4
5
|
export * as at from './at/index.js'
|
|
5
6
|
export * as call from './call/index.js'
|
|
6
|
-
export * as append from './append/index.js'
|
|
7
7
|
export * as clone from './clone/index.js'
|
|
8
8
|
export * as deleteproperties from './deleteproperties/index.js'
|
|
9
9
|
export * as equals from './equals/index.js'
|
|
10
|
-
export * as getproperties from './getproperties/index.js'
|
|
11
10
|
export * as getattribute from './getattribute/index.js'
|
|
11
|
+
export * as getproperties from './getproperties/index.js'
|
|
12
12
|
export * as getproperty from './getproperty/index.js'
|
|
13
|
-
export * as hjstringify from './hjstringify/index.js'
|
|
14
13
|
export * as hjparse from './hjparse/index.js'
|
|
14
|
+
export * as hjstringify from './hjstringify/index.js'
|
|
15
|
+
export * as if from './if/index.js'
|
|
15
16
|
export * as initialize from './initialize/index.js'
|
|
16
17
|
export * as join from './join/index.js'
|
|
17
18
|
export * as length from './length/index.js'
|
|
@@ -20,7 +21,6 @@ export * as negate from './negate/index.js'
|
|
|
20
21
|
export * as notrailing from './notrailing/index.js'
|
|
21
22
|
export * as or from './or/index.js'
|
|
22
23
|
export * as pickrandom from './pickrandom/index.js'
|
|
23
|
-
export * as if from './if/index.js'
|
|
24
24
|
export * as populate from './populate/index.js'
|
|
25
25
|
export * as print from './print/index.js'
|
|
26
26
|
export * as push from './push/index.js'
|
|
@@ -30,23 +30,23 @@ export * as removeattribute from './removeattribute/index.js'
|
|
|
30
30
|
export * as removeclass from './removeclass/index.js'
|
|
31
31
|
export * as renameproperty from './renameproperty/index.js'
|
|
32
32
|
export * as replace from './replace/index.js'
|
|
33
|
+
export * as select from './select/index.js'
|
|
34
|
+
export * as set from './set/index.js'
|
|
33
35
|
export * as setattribute from './setattribute/index.js'
|
|
34
36
|
export * as setproperty from './setproperty/index.js'
|
|
35
37
|
export * as sorton from './sorton/index.js'
|
|
36
38
|
export * as split from './split/index.js'
|
|
37
39
|
export * as spread from './spread/index.js'
|
|
38
|
-
export * as set from './set/index.js'
|
|
39
40
|
export * as toarray from './toarray/index.js'
|
|
40
41
|
export * as toboolean from './toboolean/index.js'
|
|
41
|
-
export * as select from './select/index.js'
|
|
42
42
|
export * as toelement from './toelement/index.js'
|
|
43
|
-
export * as
|
|
43
|
+
export * as toggleclass from './toggleclass/index.js'
|
|
44
44
|
export * as tonodelist from './tonodelist/index.js'
|
|
45
45
|
export * as tonull from './tonull/index.js'
|
|
46
|
-
export * as
|
|
46
|
+
export * as tonumber from './tonumber/index.js'
|
|
47
|
+
export * as torecord from './torecord/index.js'
|
|
47
48
|
export * as toref from './toref/index.js'
|
|
48
49
|
export * as tostring from './tostring/index.js'
|
|
49
50
|
export * as totext from './totext/index.js'
|
|
50
51
|
export * as transformselected from './transformselected/index.js'
|
|
51
52
|
export * as trim from './trim/index.js'
|
|
52
|
-
export * as torecord from './torecord/index.js'
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
export * as add from './add/index.js'
|
|
2
2
|
export * as addclass from './addclass/index.js'
|
|
3
3
|
export * as and from './and/index.js'
|
|
4
|
+
export * as append from './append/index.js'
|
|
4
5
|
export * as at from './at/index.js'
|
|
5
6
|
export * as call from './call/index.js'
|
|
6
|
-
export * as append from './append/index.js'
|
|
7
7
|
export * as clone from './clone/index.js'
|
|
8
8
|
export * as deleteproperties from './deleteproperties/index.js'
|
|
9
9
|
export * as equals from './equals/index.js'
|
|
10
|
-
export * as getproperties from './getproperties/index.js'
|
|
11
10
|
export * as getattribute from './getattribute/index.js'
|
|
11
|
+
export * as getproperties from './getproperties/index.js'
|
|
12
12
|
export * as getproperty from './getproperty/index.js'
|
|
13
|
-
export * as hjstringify from './hjstringify/index.js'
|
|
14
13
|
export * as hjparse from './hjparse/index.js'
|
|
14
|
+
export * as hjstringify from './hjstringify/index.js'
|
|
15
|
+
export * as if from './if/index.js'
|
|
15
16
|
export * as initialize from './initialize/index.js'
|
|
16
17
|
export * as join from './join/index.js'
|
|
17
18
|
export * as length from './length/index.js'
|
|
@@ -20,7 +21,6 @@ export * as negate from './negate/index.js'
|
|
|
20
21
|
export * as notrailing from './notrailing/index.js'
|
|
21
22
|
export * as or from './or/index.js'
|
|
22
23
|
export * as pickrandom from './pickrandom/index.js'
|
|
23
|
-
export * as if from './if/index.js'
|
|
24
24
|
export * as populate from './populate/index.js'
|
|
25
25
|
export * as print from './print/index.js'
|
|
26
26
|
export * as push from './push/index.js'
|
|
@@ -30,23 +30,23 @@ export * as removeattribute from './removeattribute/index.js'
|
|
|
30
30
|
export * as removeclass from './removeclass/index.js'
|
|
31
31
|
export * as renameproperty from './renameproperty/index.js'
|
|
32
32
|
export * as replace from './replace/index.js'
|
|
33
|
+
export * as select from './select/index.js'
|
|
34
|
+
export * as set from './set/index.js'
|
|
33
35
|
export * as setattribute from './setattribute/index.js'
|
|
34
36
|
export * as setproperty from './setproperty/index.js'
|
|
35
37
|
export * as sorton from './sorton/index.js'
|
|
36
38
|
export * as split from './split/index.js'
|
|
37
39
|
export * as spread from './spread/index.js'
|
|
38
|
-
export * as set from './set/index.js'
|
|
39
40
|
export * as toarray from './toarray/index.js'
|
|
40
41
|
export * as toboolean from './toboolean/index.js'
|
|
41
|
-
export * as select from './select/index.js'
|
|
42
42
|
export * as toelement from './toelement/index.js'
|
|
43
|
-
export * as
|
|
43
|
+
export * as toggleclass from './toggleclass/index.js'
|
|
44
44
|
export * as tonodelist from './tonodelist/index.js'
|
|
45
45
|
export * as tonull from './tonull/index.js'
|
|
46
|
-
export * as
|
|
46
|
+
export * as tonumber from './tonumber/index.js'
|
|
47
|
+
export * as torecord from './torecord/index.js'
|
|
47
48
|
export * as toref from './toref/index.js'
|
|
48
49
|
export * as tostring from './tostring/index.js'
|
|
49
50
|
export * as totext from './totext/index.js'
|
|
50
51
|
export * as transformselected from './transformselected/index.js'
|
|
51
52
|
export * as trim from './trim/index.js'
|
|
52
|
-
export * as torecord from './torecord/index.js'
|
|
@@ -3,8 +3,8 @@ export * as array from './array/index.js'
|
|
|
3
3
|
export * as boolean from './boolean/index.js'
|
|
4
4
|
export * as element from './element/index.js'
|
|
5
5
|
export * as get from './get/index.js'
|
|
6
|
-
export * as nodelist from './nodelist/index.js'
|
|
7
6
|
export * as guess from './guess/index.js'
|
|
7
|
+
export * as nodelist from './nodelist/index.js'
|
|
8
8
|
export * as null from './null/index.js'
|
|
9
9
|
export * as number from './number/index.js'
|
|
10
10
|
export * as record from './record/index.js'
|
|
@@ -3,8 +3,8 @@ export * as array from './array/index.js'
|
|
|
3
3
|
export * as boolean from './boolean/index.js'
|
|
4
4
|
export * as element from './element/index.js'
|
|
5
5
|
export * as get from './get/index.js'
|
|
6
|
-
export * as nodelist from './nodelist/index.js'
|
|
7
6
|
export * as guess from './guess/index.js'
|
|
7
|
+
export * as nodelist from './nodelist/index.js'
|
|
8
8
|
export * as null from './null/index.js'
|
|
9
9
|
export * as number from './number/index.js'
|
|
10
10
|
export * as record from './record/index.js'
|
package/agnostic/html/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * as getNodeAncestors from './get-node-ancestors/index.js'
|
|
2
1
|
export * as deepSelect from './deep-select/index.js'
|
|
2
|
+
export * as getNodeAncestors from './get-node-ancestors/index.js'
|
|
3
3
|
export * as getPositionInsideParent from './get-position-inside-parent/index.js'
|
|
4
4
|
export * as hyperJson from './hyper-json/index.js'
|
|
5
5
|
export * as insertNode from './insert-node/index.js'
|
|
6
|
-
export * as replaceInElement from './replace-in-element/index.js'
|
|
7
6
|
export * as placeholders from './placeholders/index.js'
|
|
8
|
-
export * as
|
|
7
|
+
export * as replaceInElement from './replace-in-element/index.js'
|
|
9
8
|
export * as selectorToElement from './selector-to-element/index.js'
|
|
9
|
+
export * as stringToNodes from './string-to-nodes/index.js'
|
|
10
10
|
export * as watchSelection from './watch-selection/index.js'
|
package/agnostic/html/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * as getNodeAncestors from './get-node-ancestors/index.js'
|
|
2
1
|
export * as deepSelect from './deep-select/index.js'
|
|
2
|
+
export * as getNodeAncestors from './get-node-ancestors/index.js'
|
|
3
3
|
export * as getPositionInsideParent from './get-position-inside-parent/index.js'
|
|
4
4
|
export * as hyperJson from './hyper-json/index.js'
|
|
5
5
|
export * as insertNode from './insert-node/index.js'
|
|
6
|
-
export * as replaceInElement from './replace-in-element/index.js'
|
|
7
6
|
export * as placeholders from './placeholders/index.js'
|
|
8
|
-
export * as
|
|
7
|
+
export * as replaceInElement from './replace-in-element/index.js'
|
|
9
8
|
export * as selectorToElement from './selector-to-element/index.js'
|
|
9
|
+
export * as stringToNodes from './string-to-nodes/index.js'
|
|
10
10
|
export * as watchSelection from './watch-selection/index.js'
|
package/agnostic/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
export * as arrays from './arrays/index.js'
|
|
1
2
|
export * as booleans from './booleans/index.js'
|
|
2
3
|
export * as colors from './colors/index.js'
|
|
3
|
-
export * as arrays from './arrays/index.js'
|
|
4
4
|
export * as css from './css/index.js'
|
|
5
5
|
export * as errors from './errors/index.js'
|
|
6
|
-
export * as misc from './misc/index.js'
|
|
7
6
|
export * as html from './html/index.js'
|
|
7
|
+
export * as misc from './misc/index.js'
|
|
8
8
|
export * as numbers from './numbers/index.js'
|
|
9
9
|
export * as objects from './objects/index.js'
|
|
10
10
|
export * as optim from './optim/index.js'
|
|
11
11
|
export * as random from './random/index.js'
|
|
12
|
+
export * as regexps from './regexps/index.js'
|
|
12
13
|
export * as sanitization from './sanitization/index.js'
|
|
13
14
|
export * as strings from './strings/index.js'
|
|
14
|
-
export * as regexps from './regexps/index.js'
|
|
15
15
|
export * as time from './time/index.js'
|
|
16
16
|
export * as typescript from './typescript/index.js'
|
package/agnostic/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
export * as arrays from './arrays/index.js'
|
|
1
2
|
export * as booleans from './booleans/index.js'
|
|
2
3
|
export * as colors from './colors/index.js'
|
|
3
|
-
export * as arrays from './arrays/index.js'
|
|
4
4
|
export * as css from './css/index.js'
|
|
5
5
|
export * as errors from './errors/index.js'
|
|
6
|
-
export * as misc from './misc/index.js'
|
|
7
6
|
export * as html from './html/index.js'
|
|
7
|
+
export * as misc from './misc/index.js'
|
|
8
8
|
export * as numbers from './numbers/index.js'
|
|
9
9
|
export * as objects from './objects/index.js'
|
|
10
10
|
export * as optim from './optim/index.js'
|
|
11
11
|
export * as random from './random/index.js'
|
|
12
|
+
export * as regexps from './regexps/index.js'
|
|
12
13
|
export * as sanitization from './sanitization/index.js'
|
|
13
14
|
export * as strings from './strings/index.js'
|
|
14
|
-
export * as regexps from './regexps/index.js'
|
|
15
15
|
export * as time from './time/index.js'
|
|
16
16
|
export * as typescript from './typescript/index.js'
|
package/agnostic/misc/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export * as crossenv from './crossenv/index.js'
|
|
|
6
6
|
export * as dataSize from './data-size/index.js'
|
|
7
7
|
export * as isConstructorFunction from './is-constructor-function/index.js'
|
|
8
8
|
export * as isNullish from './is-nullish/index.js'
|
|
9
|
-
export * as outcome from './outcome/index.js'
|
|
10
9
|
export * as logs from './logs/index.js'
|
|
11
10
|
export * as loremIpsum from './lorem-ipsum/index.js'
|
|
12
11
|
export * as normalizeExtension from './normalize-extension/index.js'
|
|
12
|
+
export * as outcome from './outcome/index.js'
|
package/agnostic/misc/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export * as crossenv from './crossenv/index.js'
|
|
|
6
6
|
export * as dataSize from './data-size/index.js'
|
|
7
7
|
export * as isConstructorFunction from './is-constructor-function/index.js'
|
|
8
8
|
export * as isNullish from './is-nullish/index.js'
|
|
9
|
-
export * as outcome from './outcome/index.js'
|
|
10
9
|
export * as logs from './logs/index.js'
|
|
11
10
|
export * as loremIpsum from './lorem-ipsum/index.js'
|
|
12
11
|
export * as normalizeExtension from './normalize-extension/index.js'
|
|
12
|
+
export * as outcome from './outcome/index.js'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * as clamp from './clamp/index.js'
|
|
2
|
-
export * as approximateRational from './approximate-rational/index.js'
|
|
3
1
|
export * as absoluteModulo from './absolute-modulo/index.js'
|
|
2
|
+
export * as approximateRational from './approximate-rational/index.js'
|
|
3
|
+
export * as clamp from './clamp/index.js'
|
|
4
|
+
export * as interpolate from './interpolate/index.js'
|
|
4
5
|
export * as geometricProgressions from './geometric-progressions/index.js'
|
|
5
6
|
export * as round from './round/index.js'
|
|
6
|
-
export * as interpolate from './interpolate/index.js'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * as clamp from './clamp/index.js'
|
|
2
|
-
export * as approximateRational from './approximate-rational/index.js'
|
|
3
1
|
export * as absoluteModulo from './absolute-modulo/index.js'
|
|
2
|
+
export * as approximateRational from './approximate-rational/index.js'
|
|
3
|
+
export * as clamp from './clamp/index.js'
|
|
4
|
+
export * as interpolate from './interpolate/index.js'
|
|
4
5
|
export * as geometricProgressions from './geometric-progressions/index.js'
|
|
5
6
|
export * as round from './round/index.js'
|
|
6
|
-
export * as interpolate from './interpolate/index.js'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * as enums from './enums/index.js'
|
|
2
1
|
export * as deepGetProperty from './deep-get-property/index.js'
|
|
2
|
+
export * as enums from './enums/index.js'
|
|
3
3
|
export * as flattenGetters from './flatten-getters/index.js'
|
|
4
|
-
export * as isRecord from './is-record/index.js'
|
|
5
4
|
export * as isObject from './is-object/index.js'
|
|
6
|
-
export * as
|
|
5
|
+
export * as isRecord from './is-record/index.js'
|
|
7
6
|
export * as recordFormat from './record-format/index.js'
|
|
7
|
+
export * as recordMap from './record-map/index.js'
|
|
8
8
|
export * as sortKeys from './sort-keys/index.js'
|
|
9
9
|
export * as validation from './validation/index.js'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * as enums from './enums/index.js'
|
|
2
1
|
export * as deepGetProperty from './deep-get-property/index.js'
|
|
2
|
+
export * as enums from './enums/index.js'
|
|
3
3
|
export * as flattenGetters from './flatten-getters/index.js'
|
|
4
|
-
export * as isRecord from './is-record/index.js'
|
|
5
4
|
export * as isObject from './is-object/index.js'
|
|
6
|
-
export * as
|
|
5
|
+
export * as isRecord from './is-record/index.js'
|
|
7
6
|
export * as recordFormat from './record-format/index.js'
|
|
7
|
+
export * as recordMap from './record-map/index.js'
|
|
8
8
|
export * as sortKeys from './sort-keys/index.js'
|
|
9
9
|
export * as validation from './validation/index.js'
|
package/agnostic/random/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * as matches from './matches/index.js'
|
|
2
1
|
export * as charCodes from './char-codes/index.js'
|
|
3
|
-
export * as
|
|
2
|
+
export * as matches from './matches/index.js'
|
|
3
|
+
export * as normalizeIndent from './normalize-indent/index.js'
|
|
4
4
|
export * as parseTable from './parse-table/index.js'
|
|
5
5
|
export * as replaceAll from './replace-all/index.js'
|
|
6
|
+
export * as splitTrim from './split-trim/index.js'
|
|
6
7
|
export * as toAlphanum from './to-alphanum/index.js'
|
|
7
|
-
export * as normalizeIndent from './normalize-indent/index.js'
|
|
8
8
|
export * as trim from './trim/index.js'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * as matches from './matches/index.js'
|
|
2
1
|
export * as charCodes from './char-codes/index.js'
|
|
3
|
-
export * as
|
|
2
|
+
export * as matches from './matches/index.js'
|
|
3
|
+
export * as normalizeIndent from './normalize-indent/index.js'
|
|
4
4
|
export * as parseTable from './parse-table/index.js'
|
|
5
5
|
export * as replaceAll from './replace-all/index.js'
|
|
6
|
+
export * as splitTrim from './split-trim/index.js'
|
|
6
7
|
export * as toAlphanum from './to-alphanum/index.js'
|
|
7
|
-
export * as normalizeIndent from './normalize-indent/index.js'
|
|
8
8
|
export * as trim from './trim/index.js'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Formats a `Date`
|
|
2
|
+
* Formats a `Date` into a string according to a custom template and locale.
|
|
3
3
|
*
|
|
4
4
|
* Supported tokens (placeholders must be wrapped in `{{...}}`):
|
|
5
5
|
*
|
|
@@ -42,7 +42,9 @@
|
|
|
42
42
|
* @param date - The `Date` object to format.
|
|
43
43
|
* @param format - The template string containing tokens.
|
|
44
44
|
* @param locale - Optional locale code (default: `'en'`).
|
|
45
|
-
* @returns Formatted date string.
|
|
45
|
+
* @returns Formatted date string. An unknown token is left untouched, braces
|
|
46
|
+
* included.
|
|
47
|
+
* @see {@link getDateParts} to reach the same parts as plain values, unpadded.
|
|
46
48
|
*
|
|
47
49
|
* @example
|
|
48
50
|
* formatDate(new Date(2026, 0, 1, 15, 5), '{{YYYY}}-{{MM}}-{{DD}} {{hh}}:{{mm}} {{A}}')
|
|
@@ -1,5 +1,42 @@
|
|
|
1
|
+
import { getDateParts } from './parts.js';
|
|
2
|
+
// Alternation is ordered, and the first branch that fits wins — so the longest
|
|
3
|
+
// tokens come first. `MM` ahead of `MMMM` would only work by backtracking off the
|
|
4
|
+
// closing braces, which is true but not something a reader should have to derive.
|
|
5
|
+
const tokenRegexp = /\{\{(MMMM|YYYY|MMM|DD|dd|MM|YY|HH|hh|mm|ss|th|ms|D|d|M|H|h|m|s|A|a)\}\}/gv;
|
|
6
|
+
function pad(value, length) {
|
|
7
|
+
return `${value}`.padStart(length, '0');
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* How each token renders the parts it reads. This is where padding and
|
|
11
|
+
* truncation live — {@link getDateParts} hands over plain quantities, and the
|
|
12
|
+
* padded tokens are the same quantity written differently.
|
|
13
|
+
*/
|
|
14
|
+
const renderers = {
|
|
15
|
+
'D': parts => `${parts.D}`,
|
|
16
|
+
'DD': parts => pad(parts.D, 2),
|
|
17
|
+
'd': parts => parts.d,
|
|
18
|
+
'dd': parts => parts.dd,
|
|
19
|
+
'M': parts => `${parts.M}`,
|
|
20
|
+
'MM': parts => pad(parts.M, 2),
|
|
21
|
+
'MMM': parts => parts.MMM,
|
|
22
|
+
'MMMM': parts => parts.MMMM,
|
|
23
|
+
'YY': parts => `${parts.YYYY}`.slice(-2),
|
|
24
|
+
'YYYY': parts => `${parts.YYYY}`,
|
|
25
|
+
'H': parts => `${parts.H}`,
|
|
26
|
+
'HH': parts => pad(parts.H, 2),
|
|
27
|
+
'h': parts => `${parts.h}`,
|
|
28
|
+
'hh': parts => pad(parts.h, 2),
|
|
29
|
+
'm': parts => `${parts.m}`,
|
|
30
|
+
'mm': parts => pad(parts.m, 2),
|
|
31
|
+
's': parts => `${parts.s}`,
|
|
32
|
+
'ss': parts => pad(parts.s, 2),
|
|
33
|
+
'ms': parts => pad(parts.ms, 3),
|
|
34
|
+
'A': parts => parts.A,
|
|
35
|
+
'a': parts => parts.a,
|
|
36
|
+
'th': parts => parts.th
|
|
37
|
+
};
|
|
1
38
|
/**
|
|
2
|
-
* Formats a `Date`
|
|
39
|
+
* Formats a `Date` into a string according to a custom template and locale.
|
|
3
40
|
*
|
|
4
41
|
* Supported tokens (placeholders must be wrapped in `{{...}}`):
|
|
5
42
|
*
|
|
@@ -42,103 +79,15 @@
|
|
|
42
79
|
* @param date - The `Date` object to format.
|
|
43
80
|
* @param format - The template string containing tokens.
|
|
44
81
|
* @param locale - Optional locale code (default: `'en'`).
|
|
45
|
-
* @returns Formatted date string.
|
|
82
|
+
* @returns Formatted date string. An unknown token is left untouched, braces
|
|
83
|
+
* included.
|
|
84
|
+
* @see {@link getDateParts} to reach the same parts as plain values, unpadded.
|
|
46
85
|
*
|
|
47
86
|
* @example
|
|
48
87
|
* formatDate(new Date(2026, 0, 1, 15, 5), '{{YYYY}}-{{MM}}-{{DD}} {{hh}}:{{mm}} {{A}}')
|
|
49
88
|
* // => "2026-01-01 03:05 PM"
|
|
50
89
|
*/
|
|
51
90
|
export function formatDate(date, format, locale = 'en') {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.supportedLocalesOf(locale).length === 0) {
|
|
55
|
-
// eslint-disable-next-line no-param-reassign
|
|
56
|
-
locale = 'en';
|
|
57
|
-
}
|
|
58
|
-
const day = date.getDate();
|
|
59
|
-
const dayOfWeek = date.getDay();
|
|
60
|
-
const month = date.getMonth();
|
|
61
|
-
const year = date.getFullYear();
|
|
62
|
-
const hours = date.getHours();
|
|
63
|
-
const minutes = date.getMinutes();
|
|
64
|
-
const seconds = date.getSeconds();
|
|
65
|
-
const isPM = hours >= 12;
|
|
66
|
-
const shortDateNames = [...Array(7)].map((_, i) => new Intl.DateTimeFormat(locale, { weekday: 'short' }).format(new Date(2023, 0, i + 1)));
|
|
67
|
-
const dateNames = [...Array(7)].map((_, i) => new Intl.DateTimeFormat(locale, { weekday: 'long' }).format(new Date(2023, 0, i + 1)));
|
|
68
|
-
const shortMonthNames = [...Array(12)].map((_, i) => new Intl.DateTimeFormat(locale, { month: 'short' }).format(new Date(2023, i, 1)));
|
|
69
|
-
const monthNames = [...Array(12)].map((_, i) => new Intl.DateTimeFormat(locale, { month: 'long' }).format(new Date(2023, i, 1)));
|
|
70
|
-
const replacements = {
|
|
71
|
-
'DD': () => String(day).padStart(2, '0'),
|
|
72
|
-
'D': () => String(day),
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
74
|
-
'dd': () => dateNames[dayOfWeek],
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
76
|
-
'd': () => shortDateNames[dayOfWeek],
|
|
77
|
-
'MM': () => String(month + 1).padStart(2, '0'),
|
|
78
|
-
'M': () => String(month + 1),
|
|
79
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
80
|
-
'MMMM': () => monthNames[month],
|
|
81
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
82
|
-
'MMM': () => shortMonthNames[month],
|
|
83
|
-
'YYYY': () => String(year),
|
|
84
|
-
'YY': () => String(year).slice(-2),
|
|
85
|
-
'hh': () => String(hours % 12 !== 0 ? hours % 12 : 12).padStart(2, '0'),
|
|
86
|
-
'h': () => String(hours % 12 !== 0 ? hours % 12 : 12),
|
|
87
|
-
'HH': () => String(hours).padStart(2, '0'),
|
|
88
|
-
'H': () => String(hours),
|
|
89
|
-
'mm': () => String(minutes).padStart(2, '0'),
|
|
90
|
-
'm': () => String(minutes),
|
|
91
|
-
'ss': () => String(seconds).padStart(2, '0'),
|
|
92
|
-
's': () => String(seconds),
|
|
93
|
-
'ms': () => String(date.getMilliseconds()).padStart(3, '0'),
|
|
94
|
-
'A': () => (isPM ? 'PM' : 'AM'),
|
|
95
|
-
'a': () => (isPM ? 'pm' : 'am'),
|
|
96
|
-
'th': () => {
|
|
97
|
-
if (locale.startsWith('fr') && day === 1)
|
|
98
|
-
return 'er';
|
|
99
|
-
if (locale.startsWith('en')) {
|
|
100
|
-
const mod10 = day % 10;
|
|
101
|
-
const mod100 = day % 100;
|
|
102
|
-
if (mod10 === 1 && mod100 !== 11)
|
|
103
|
-
return 'st';
|
|
104
|
-
if (mod10 === 2 && mod100 !== 12)
|
|
105
|
-
return 'nd';
|
|
106
|
-
if (mod10 === 3 && mod100 !== 13)
|
|
107
|
-
return 'rd';
|
|
108
|
-
return 'th';
|
|
109
|
-
}
|
|
110
|
-
return '';
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
const regexp = /\{\{(DD|D|dd|d|MM|M|MMMM|MMM|YYYY|YY|HH|H|hh|h|mm|m|ss|s|A|a|th|ms)\}\}/gv;
|
|
114
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
115
|
-
return format.replace(regexp, (match, token) => replacements[token]?.() ?? match);
|
|
91
|
+
const parts = getDateParts(date, locale);
|
|
92
|
+
return format.replace(tokenRegexp, (_match, token) => renderers[token](parts));
|
|
116
93
|
}
|
|
117
|
-
// [WIP] this was removed since JavaScript's Date object don't hold timezone data
|
|
118
|
-
// those templates would only reflect the curent client's timezone, no matter what the input Date obj was
|
|
119
|
-
// 'ZZ': () => {
|
|
120
|
-
// const timezoneOffset = date.getTimezoneOffset()
|
|
121
|
-
// const offsetHours = Math.floor(Math.abs(timezoneOffset) / 60)
|
|
122
|
-
// const offsetMinutes = Math.abs(timezoneOffset) % 60
|
|
123
|
-
// const sign = timezoneOffset > 0 ? '-' : '+'
|
|
124
|
-
// return `${sign}${String(offsetHours).padStart(2, '0')}:${String(offsetMinutes).padStart(2, '0')}`
|
|
125
|
-
// },
|
|
126
|
-
// 'Z': () => {
|
|
127
|
-
// const timezoneOffset = date.getTimezoneOffset()
|
|
128
|
-
// if (timezoneOffset === 0) return 'Z'
|
|
129
|
-
// const offsetHours = Math.floor(Math.abs(timezoneOffset) / 60)
|
|
130
|
-
// const offsetMinutes = Math.abs(timezoneOffset) % 60
|
|
131
|
-
// const sign = timezoneOffset > 0 ? '-' : '+'
|
|
132
|
-
// return `${sign}${String(offsetHours).padStart(2, '0')}:${String(offsetMinutes).padStart(2, '0')}`
|
|
133
|
-
// },
|
|
134
|
-
// 'z': () => {
|
|
135
|
-
// return Intl.DateTimeFormat(locale, { timeZoneName: 'short' })
|
|
136
|
-
// .formatToParts(date)
|
|
137
|
-
// .find(part => part.type === 'timeZoneName')?.value || ''
|
|
138
|
-
// },
|
|
139
|
-
// 'zz': () => {
|
|
140
|
-
// return Intl.DateTimeFormat(locale, { timeZoneName: 'long' })
|
|
141
|
-
// .formatToParts(date)
|
|
142
|
-
// .find(part => part.type === 'timeZoneName')?.value || ''
|
|
143
|
-
// },
|
|
144
|
-
// 'tz': () => Intl.DateTimeFormat().resolvedOptions().timeZone || ''
|