@oscarpalmer/atoms 0.75.0 → 0.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/array/chunk.cjs +2 -1
- package/dist/js/array/chunk.js +2 -1
- package/dist/js/array/count.cjs +10 -3
- package/dist/js/array/count.js +10 -3
- package/dist/js/array/exists.cjs +10 -3
- package/dist/js/array/exists.js +10 -3
- package/dist/js/array/filter.cjs +10 -3
- package/dist/js/array/filter.js +10 -3
- package/dist/js/array/find.cjs +10 -3
- package/dist/js/array/find.js +10 -3
- package/dist/js/array/group-by.cjs +18 -16
- package/dist/js/array/group-by.js +18 -16
- package/dist/js/array/index-of.cjs +10 -3
- package/dist/js/array/index-of.js +10 -3
- package/dist/js/array/index.cjs +2 -2
- package/dist/js/array/index.js +2 -2
- package/dist/js/array/insert.cjs +10 -4
- package/dist/js/array/insert.js +10 -4
- package/dist/js/array/splice.cjs +4 -4
- package/dist/js/array/splice.js +4 -4
- package/dist/js/array/to-map.cjs +11 -11
- package/dist/js/array/to-map.js +11 -11
- package/dist/js/array/to-record.cjs +3 -3
- package/dist/js/array/to-record.js +3 -3
- package/dist/js/array/unique.cjs +2 -2
- package/dist/js/array/unique.js +2 -2
- package/dist/js/colour/base.cjs +1 -1
- package/dist/js/colour/base.js +1 -1
- package/dist/js/colour/hex.cjs +2 -2
- package/dist/js/colour/hex.js +2 -2
- package/dist/js/colour/hsl.cjs +13 -7
- package/dist/js/colour/hsl.js +13 -7
- package/dist/js/colour/rgb.cjs +12 -6
- package/dist/js/colour/rgb.js +12 -6
- package/dist/js/emitter.cjs +8 -5
- package/dist/js/emitter.js +8 -5
- package/dist/js/function.cjs +6 -6
- package/dist/js/function.js +6 -6
- package/dist/js/index.cjs +0 -1
- package/dist/js/index.js +1 -2
- package/dist/js/internal/array/callbacks.cjs +23 -0
- package/dist/js/internal/array/callbacks.js +23 -0
- package/dist/js/internal/{array-find.cjs → array/find.cjs} +11 -12
- package/dist/js/internal/{array-find.js → array/find.js} +11 -12
- package/dist/js/logger.cjs +13 -13
- package/dist/js/logger.js +13 -13
- package/dist/js/query.cjs +0 -3
- package/dist/js/query.js +1 -4
- package/dist/js/random.cjs +0 -6
- package/dist/js/random.js +0 -6
- package/dist/js/sized.cjs +1 -1
- package/dist/js/sized.js +1 -1
- package/dist/js/string/index.cjs +7 -1
- package/dist/js/string/index.js +7 -1
- package/dist/js/value/compare.cjs +0 -1
- package/dist/js/value/compare.js +0 -1
- package/dist/js/value/get.cjs +3 -3
- package/dist/js/value/get.js +2 -2
- package/dist/js/value/set.cjs +4 -4
- package/dist/js/value/set.js +2 -2
- package/package.json +3 -2
- package/src/js/array/chunk.ts +6 -5
- package/src/js/array/compact.ts +8 -10
- package/src/js/array/count.ts +39 -19
- package/src/js/array/exists.ts +40 -16
- package/src/js/array/filter.ts +42 -20
- package/src/js/array/find.ts +45 -20
- package/src/js/array/group-by.ts +158 -27
- package/src/js/array/index-of.ts +40 -18
- package/src/js/array/index.ts +10 -9
- package/src/js/array/insert.ts +28 -14
- package/src/js/array/models.ts +18 -15
- package/src/js/array/shuffle.ts +3 -3
- package/src/js/array/sort.ts +28 -34
- package/src/js/array/splice.ts +22 -26
- package/src/js/array/to-map.ts +133 -45
- package/src/js/array/to-record.ts +137 -39
- package/src/js/array/unique.ts +20 -15
- package/src/js/colour/base.ts +3 -3
- package/src/js/colour/functions.ts +4 -6
- package/src/js/colour/hex.ts +5 -5
- package/src/js/colour/hsl.ts +18 -12
- package/src/js/colour/index.ts +1 -1
- package/src/js/colour/is.ts +3 -3
- package/src/js/colour/rgb.ts +17 -11
- package/src/js/emitter.ts +12 -9
- package/src/js/function.ts +12 -12
- package/src/js/index.ts +16 -16
- package/src/js/internal/array/callbacks.ts +33 -0
- package/src/js/internal/{array-find.ts → array/find.ts} +23 -24
- package/src/js/internal/{value-handle.ts → value/handle.ts} +1 -1
- package/src/js/is.ts +2 -2
- package/src/js/logger.ts +14 -14
- package/src/js/math.ts +1 -1
- package/src/js/models.ts +5 -5
- package/src/js/number.ts +2 -2
- package/src/js/query.ts +6 -10
- package/src/js/queue.ts +1 -1
- package/src/js/random.ts +9 -19
- package/src/js/sized.ts +145 -145
- package/src/js/string/case.ts +1 -1
- package/src/js/string/index.ts +13 -7
- package/src/js/string/template.ts +6 -3
- package/src/js/value/clone.ts +3 -7
- package/src/js/value/compare.ts +3 -5
- package/src/js/value/diff.ts +4 -4
- package/src/js/value/equal.ts +2 -2
- package/src/js/value/get.ts +3 -3
- package/src/js/value/index.ts +2 -2
- package/src/js/value/merge.ts +3 -3
- package/src/js/value/set.ts +3 -4
- package/src/js/value/smush.ts +4 -4
- package/src/js/value/unsmush.ts +4 -4
- package/types/array/chunk.d.cts +2 -2
- package/types/array/chunk.d.ts +2 -2
- package/types/array/compact.d.cts +4 -4
- package/types/array/compact.d.ts +4 -4
- package/types/array/count.d.cts +15 -8
- package/types/array/count.d.ts +13 -7
- package/types/array/exists.d.cts +14 -5
- package/types/array/exists.d.ts +12 -4
- package/types/array/filter.d.cts +16 -7
- package/types/array/filter.d.ts +14 -6
- package/types/array/find.d.cts +16 -7
- package/types/array/find.d.ts +14 -6
- package/types/array/group-by.d.cts +51 -5
- package/types/array/group-by.d.ts +49 -5
- package/types/array/index-of.d.cts +16 -7
- package/types/array/index-of.d.ts +14 -6
- package/types/array/index.d.cts +239 -95
- package/types/array/index.d.ts +7 -6
- package/types/array/insert.d.cts +9 -4
- package/types/array/insert.d.ts +10 -5
- package/types/array/models.d.cts +14 -11
- package/types/array/models.d.ts +14 -12
- package/types/array/shuffle.d.cts +2 -2
- package/types/array/shuffle.d.ts +2 -2
- package/types/array/sort.d.cts +11 -11
- package/types/array/sort.d.ts +10 -10
- package/types/array/splice.d.cts +4 -4
- package/types/array/splice.d.ts +4 -4
- package/types/array/to-map.d.cts +44 -20
- package/types/array/to-map.d.ts +42 -20
- package/types/array/to-record.d.cts +44 -20
- package/types/array/to-record.d.ts +42 -20
- package/types/array/unique.d.cts +11 -6
- package/types/array/unique.d.ts +10 -6
- package/types/colour/base.d.cts +28 -16
- package/types/colour/base.d.ts +2 -2
- package/types/colour/functions.d.cts +28 -16
- package/types/colour/functions.d.ts +3 -3
- package/types/colour/hex.d.cts +28 -16
- package/types/colour/hex.d.ts +4 -4
- package/types/colour/hsl.d.cts +28 -16
- package/types/colour/hsl.d.ts +16 -10
- package/types/colour/index.d.cts +28 -16
- package/types/colour/index.d.ts +1 -1
- package/types/colour/is.d.cts +28 -16
- package/types/colour/is.d.ts +3 -3
- package/types/colour/rgb.d.cts +28 -16
- package/types/colour/rgb.d.ts +15 -9
- package/types/emitter.d.cts +11 -8
- package/types/emitter.d.ts +11 -8
- package/types/function.d.cts +10 -10
- package/types/function.d.ts +11 -11
- package/types/index.d.cts +1061 -669
- package/types/index.d.ts +16 -16
- package/types/internal/array/callbacks.d.cts +11 -0
- package/types/internal/array/callbacks.d.ts +2 -0
- package/types/internal/array/find.d.cts +7 -0
- package/types/internal/array/find.d.ts +3 -0
- package/types/internal/{value-handle.d.ts → value/handle.d.ts} +1 -1
- package/types/is.d.ts +1 -1
- package/types/logger.d.cts +13 -13
- package/types/logger.d.ts +13 -13
- package/types/math.d.cts +1 -1
- package/types/math.d.ts +1 -1
- package/types/models.d.cts +4 -4
- package/types/models.d.ts +1 -4
- package/types/number.d.cts +2 -2
- package/types/number.d.ts +2 -2
- package/types/query.d.cts +2 -2
- package/types/query.d.ts +3 -3
- package/types/queue.d.cts +1 -1
- package/types/queue.d.ts +1 -1
- package/types/random.d.cts +8 -12
- package/types/random.d.ts +8 -12
- package/types/sized.d.cts +6 -6
- package/types/sized.d.ts +6 -6
- package/types/string/index.d.cts +6 -3
- package/types/string/index.d.ts +3 -3
- package/types/string/template.d.cts +3 -0
- package/types/string/template.d.ts +4 -1
- package/types/value/clone.d.cts +4 -2
- package/types/value/clone.d.ts +4 -2
- package/types/value/get.d.ts +1 -1
- package/types/value/index.d.cts +8 -6
- package/types/value/index.d.ts +2 -2
- package/types/value/merge.d.cts +1 -1
- package/types/value/merge.d.ts +2 -2
- package/types/value/set.d.ts +1 -1
- package/types/value/smush.d.cts +1 -1
- package/types/value/smush.d.ts +2 -2
- package/types/value/unsmush.d.cts +1 -1
- package/types/value/unsmush.d.ts +2 -2
- package/dist/js/internal/array-callbacks.cjs +0 -18
- package/dist/js/internal/array-callbacks.js +0 -18
- package/src/js/internal/array-callbacks.ts +0 -28
- package/types/internal/array-callbacks.d.cts +0 -13
- package/types/internal/array-callbacks.d.ts +0 -2
- package/types/internal/array-find.d.cts +0 -11
- package/types/internal/array-find.d.ts +0 -4
- /package/dist/js/internal/{value-handle.cjs → value/handle.cjs} +0 -0
- /package/dist/js/internal/{value-handle.js → value/handle.js} +0 -0
- /package/types/internal/{value-handle.d.cts → value/handle.d.cts} +0 -0
package/dist/js/colour/hsl.cjs
CHANGED
|
@@ -5,37 +5,37 @@ const colour_functions = require("./functions.cjs");
|
|
|
5
5
|
const number = require("../number.cjs");
|
|
6
6
|
class HSLColour extends colour_base.Colour {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Get the current hue
|
|
9
9
|
*/
|
|
10
10
|
get hue() {
|
|
11
11
|
return +this.state.value.hue;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Set the current hue
|
|
15
15
|
*/
|
|
16
16
|
set hue(value) {
|
|
17
17
|
this.state.value.hue = number.clamp(value, 0, 360);
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Get the current lightness
|
|
21
21
|
*/
|
|
22
22
|
get lightness() {
|
|
23
23
|
return +this.state.value.lightness;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Set the current lightness
|
|
27
27
|
*/
|
|
28
28
|
set lightness(value) {
|
|
29
29
|
this.state.value.lightness = number.clamp(value, 0, 100);
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Get the current saturation
|
|
33
33
|
*/
|
|
34
34
|
get saturation() {
|
|
35
35
|
return +this.state.value.saturation;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Set the current saturation
|
|
39
39
|
*/
|
|
40
40
|
set saturation(value) {
|
|
41
41
|
this.state.value.saturation = number.clamp(value, 0, 100);
|
|
@@ -43,15 +43,21 @@ class HSLColour extends colour_base.Colour {
|
|
|
43
43
|
constructor(value) {
|
|
44
44
|
super("hsl", value, defaults, properties);
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* @inheritdoc
|
|
48
|
+
*/
|
|
46
49
|
toHex() {
|
|
47
50
|
return HSLColour.toRgb(this.state.value).toHex();
|
|
48
51
|
}
|
|
49
52
|
/**
|
|
50
|
-
*
|
|
53
|
+
* Convert the colour to an RGB-colour
|
|
51
54
|
*/
|
|
52
55
|
toRgb() {
|
|
53
56
|
return HSLColour.toRgb(this.state.value);
|
|
54
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* @inheritdoc
|
|
60
|
+
*/
|
|
55
61
|
toString() {
|
|
56
62
|
return `hsl(${this.state.value.hue}, ${this.state.value.saturation}%, ${this.state.value.lightness}%)`;
|
|
57
63
|
}
|
package/dist/js/colour/hsl.js
CHANGED
|
@@ -3,37 +3,37 @@ import { hslToRgb } from "./functions.js";
|
|
|
3
3
|
import { clamp } from "../number.js";
|
|
4
4
|
class HSLColour extends Colour {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Get the current hue
|
|
7
7
|
*/
|
|
8
8
|
get hue() {
|
|
9
9
|
return +this.state.value.hue;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Set the current hue
|
|
13
13
|
*/
|
|
14
14
|
set hue(value) {
|
|
15
15
|
this.state.value.hue = clamp(value, 0, 360);
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Get the current lightness
|
|
19
19
|
*/
|
|
20
20
|
get lightness() {
|
|
21
21
|
return +this.state.value.lightness;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Set the current lightness
|
|
25
25
|
*/
|
|
26
26
|
set lightness(value) {
|
|
27
27
|
this.state.value.lightness = clamp(value, 0, 100);
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Get the current saturation
|
|
31
31
|
*/
|
|
32
32
|
get saturation() {
|
|
33
33
|
return +this.state.value.saturation;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Set the current saturation
|
|
37
37
|
*/
|
|
38
38
|
set saturation(value) {
|
|
39
39
|
this.state.value.saturation = clamp(value, 0, 100);
|
|
@@ -41,15 +41,21 @@ class HSLColour extends Colour {
|
|
|
41
41
|
constructor(value) {
|
|
42
42
|
super("hsl", value, defaults, properties);
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* @inheritdoc
|
|
46
|
+
*/
|
|
44
47
|
toHex() {
|
|
45
48
|
return HSLColour.toRgb(this.state.value).toHex();
|
|
46
49
|
}
|
|
47
50
|
/**
|
|
48
|
-
*
|
|
51
|
+
* Convert the colour to an RGB-colour
|
|
49
52
|
*/
|
|
50
53
|
toRgb() {
|
|
51
54
|
return HSLColour.toRgb(this.state.value);
|
|
52
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* @inheritdoc
|
|
58
|
+
*/
|
|
53
59
|
toString() {
|
|
54
60
|
return `hsl(${this.state.value.hue}, ${this.state.value.saturation}%, ${this.state.value.lightness}%)`;
|
|
55
61
|
}
|
package/dist/js/colour/rgb.cjs
CHANGED
|
@@ -5,37 +5,37 @@ const colour_functions = require("./functions.cjs");
|
|
|
5
5
|
const number = require("../number.cjs");
|
|
6
6
|
class RGBColour extends colour_base.Colour {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Get the current blue value
|
|
9
9
|
*/
|
|
10
10
|
get blue() {
|
|
11
11
|
return +this.state.value.blue;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Set the current blue value
|
|
15
15
|
*/
|
|
16
16
|
set blue(value) {
|
|
17
17
|
this.state.value.blue = number.clamp(value, 0, 255);
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Get the current green value
|
|
21
21
|
*/
|
|
22
22
|
get green() {
|
|
23
23
|
return +this.state.value.green;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Set the current green value
|
|
27
27
|
*/
|
|
28
28
|
set green(value) {
|
|
29
29
|
this.state.value.green = number.clamp(value, 0, 255);
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Get the current red value
|
|
33
33
|
*/
|
|
34
34
|
get red() {
|
|
35
35
|
return +this.state.value.red;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Set the current red value
|
|
39
39
|
*/
|
|
40
40
|
set red(value) {
|
|
41
41
|
this.state.value.red = number.clamp(value, 0, 255);
|
|
@@ -43,6 +43,9 @@ class RGBColour extends colour_base.Colour {
|
|
|
43
43
|
constructor(value) {
|
|
44
44
|
super("rgb", value, defaults, properties);
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* @inheritdoc
|
|
48
|
+
*/
|
|
46
49
|
toHex() {
|
|
47
50
|
return RGBColour.toHex(this.value);
|
|
48
51
|
}
|
|
@@ -52,6 +55,9 @@ class RGBColour extends colour_base.Colour {
|
|
|
52
55
|
toHsl() {
|
|
53
56
|
return RGBColour.toHsl(this.value);
|
|
54
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* @inheritdoc
|
|
60
|
+
*/
|
|
55
61
|
toString() {
|
|
56
62
|
return `rgb(${this.value.red}, ${this.value.green}, ${this.value.blue})`;
|
|
57
63
|
}
|
package/dist/js/colour/rgb.js
CHANGED
|
@@ -3,37 +3,37 @@ import { rgbToHex, rgbToHsl } from "./functions.js";
|
|
|
3
3
|
import { clamp } from "../number.js";
|
|
4
4
|
class RGBColour extends Colour {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Get the current blue value
|
|
7
7
|
*/
|
|
8
8
|
get blue() {
|
|
9
9
|
return +this.state.value.blue;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Set the current blue value
|
|
13
13
|
*/
|
|
14
14
|
set blue(value) {
|
|
15
15
|
this.state.value.blue = clamp(value, 0, 255);
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Get the current green value
|
|
19
19
|
*/
|
|
20
20
|
get green() {
|
|
21
21
|
return +this.state.value.green;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Set the current green value
|
|
25
25
|
*/
|
|
26
26
|
set green(value) {
|
|
27
27
|
this.state.value.green = clamp(value, 0, 255);
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Get the current red value
|
|
31
31
|
*/
|
|
32
32
|
get red() {
|
|
33
33
|
return +this.state.value.red;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Set the current red value
|
|
37
37
|
*/
|
|
38
38
|
set red(value) {
|
|
39
39
|
this.state.value.red = clamp(value, 0, 255);
|
|
@@ -41,6 +41,9 @@ class RGBColour extends Colour {
|
|
|
41
41
|
constructor(value) {
|
|
42
42
|
super("rgb", value, defaults, properties);
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* @inheritdoc
|
|
46
|
+
*/
|
|
44
47
|
toHex() {
|
|
45
48
|
return RGBColour.toHex(this.value);
|
|
46
49
|
}
|
|
@@ -50,6 +53,9 @@ class RGBColour extends Colour {
|
|
|
50
53
|
toHsl() {
|
|
51
54
|
return RGBColour.toHsl(this.value);
|
|
52
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* @inheritdoc
|
|
58
|
+
*/
|
|
53
59
|
toString() {
|
|
54
60
|
return `rgb(${this.value.red}, ${this.value.green}, ${this.value.blue})`;
|
|
55
61
|
}
|
package/dist/js/emitter.cjs
CHANGED
|
@@ -30,13 +30,13 @@ class Emitter {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* Destroy the emitter
|
|
34
34
|
*/
|
|
35
35
|
destroy() {
|
|
36
36
|
finishEmitter(this.state, false);
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Emit a new value _(and optionally finishes the emitter)_
|
|
40
40
|
*/
|
|
41
41
|
emit(value, finish) {
|
|
42
42
|
var _a;
|
|
@@ -51,7 +51,7 @@ class Emitter {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* Emit an error _(and optionally finishes the emitter)_
|
|
55
55
|
*/
|
|
56
56
|
error(error, finish) {
|
|
57
57
|
var _a;
|
|
@@ -65,7 +65,7 @@ class Emitter {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* Finish the emitter
|
|
69
69
|
*/
|
|
70
70
|
finish() {
|
|
71
71
|
finishEmitter(this.state, true);
|
|
@@ -101,13 +101,16 @@ class Subscription {
|
|
|
101
101
|
var _a;
|
|
102
102
|
return this.state.closed || !(((_a = this.state.emitter) == null ? void 0 : _a.active) ?? false);
|
|
103
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Destroy the subscription
|
|
106
|
+
*/
|
|
104
107
|
destroy() {
|
|
105
108
|
this.unsubscribe();
|
|
106
109
|
this.state.emitter = void 0;
|
|
107
110
|
this.state.observers = void 0;
|
|
108
111
|
}
|
|
109
112
|
/**
|
|
110
|
-
*
|
|
113
|
+
* Unsubscribe from its observable
|
|
111
114
|
*/
|
|
112
115
|
unsubscribe() {
|
|
113
116
|
var _a;
|
package/dist/js/emitter.js
CHANGED
|
@@ -28,13 +28,13 @@ class Emitter {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Destroy the emitter
|
|
32
32
|
*/
|
|
33
33
|
destroy() {
|
|
34
34
|
finishEmitter(this.state, false);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Emit a new value _(and optionally finishes the emitter)_
|
|
38
38
|
*/
|
|
39
39
|
emit(value, finish) {
|
|
40
40
|
var _a;
|
|
@@ -49,7 +49,7 @@ class Emitter {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* Emit an error _(and optionally finishes the emitter)_
|
|
53
53
|
*/
|
|
54
54
|
error(error, finish) {
|
|
55
55
|
var _a;
|
|
@@ -63,7 +63,7 @@ class Emitter {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* Finish the emitter
|
|
67
67
|
*/
|
|
68
68
|
finish() {
|
|
69
69
|
finishEmitter(this.state, true);
|
|
@@ -99,13 +99,16 @@ class Subscription {
|
|
|
99
99
|
var _a;
|
|
100
100
|
return this.state.closed || !(((_a = this.state.emitter) == null ? void 0 : _a.active) ?? false);
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Destroy the subscription
|
|
104
|
+
*/
|
|
102
105
|
destroy() {
|
|
103
106
|
this.unsubscribe();
|
|
104
107
|
this.state.emitter = void 0;
|
|
105
108
|
this.state.observers = void 0;
|
|
106
109
|
}
|
|
107
110
|
/**
|
|
108
|
-
*
|
|
111
|
+
* Unsubscribe from its observable
|
|
109
112
|
*/
|
|
110
113
|
unsubscribe() {
|
|
111
114
|
var _a;
|
package/dist/js/function.cjs
CHANGED
|
@@ -16,21 +16,21 @@ class Memoised {
|
|
|
16
16
|
this.state = { cache, getter };
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Clear the cache
|
|
20
20
|
*/
|
|
21
21
|
clear() {
|
|
22
22
|
var _a;
|
|
23
23
|
(_a = this.state.cache) == null ? void 0 : _a.clear();
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Delete a result from the cache
|
|
27
27
|
*/
|
|
28
28
|
delete(key) {
|
|
29
29
|
var _a;
|
|
30
30
|
return (_a = this.state.cache) == null ? void 0 : _a.delete(key);
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* Destroy the instance, clearing its cache and removing its callback
|
|
34
34
|
*/
|
|
35
35
|
destroy() {
|
|
36
36
|
this.state.cache.clear();
|
|
@@ -38,21 +38,21 @@ class Memoised {
|
|
|
38
38
|
this.state.getter = noop;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* Get a result from the cache if it exists _(or `undefined` otherwise)_
|
|
42
42
|
*/
|
|
43
43
|
get(key) {
|
|
44
44
|
var _a;
|
|
45
45
|
return (_a = this.state.cache) == null ? void 0 : _a.get(key);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Does the result exist?
|
|
49
49
|
*/
|
|
50
50
|
has(key) {
|
|
51
51
|
var _a;
|
|
52
52
|
return ((_a = this.state.cache) == null ? void 0 : _a.has(key)) ?? false;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
55
|
+
* Get the result from the cache if it exists; otherwise runs the callback, caches the result, and returns it
|
|
56
56
|
*/
|
|
57
57
|
run(...parameters) {
|
|
58
58
|
return this.state.getter(...parameters);
|
package/dist/js/function.js
CHANGED
|
@@ -14,21 +14,21 @@ class Memoised {
|
|
|
14
14
|
this.state = { cache, getter };
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Clear the cache
|
|
18
18
|
*/
|
|
19
19
|
clear() {
|
|
20
20
|
var _a;
|
|
21
21
|
(_a = this.state.cache) == null ? void 0 : _a.clear();
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Delete a result from the cache
|
|
25
25
|
*/
|
|
26
26
|
delete(key) {
|
|
27
27
|
var _a;
|
|
28
28
|
return (_a = this.state.cache) == null ? void 0 : _a.delete(key);
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Destroy the instance, clearing its cache and removing its callback
|
|
32
32
|
*/
|
|
33
33
|
destroy() {
|
|
34
34
|
this.state.cache.clear();
|
|
@@ -36,21 +36,21 @@ class Memoised {
|
|
|
36
36
|
this.state.getter = noop;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Get a result from the cache if it exists _(or `undefined` otherwise)_
|
|
40
40
|
*/
|
|
41
41
|
get(key) {
|
|
42
42
|
var _a;
|
|
43
43
|
return (_a = this.state.cache) == null ? void 0 : _a.get(key);
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* Does the result exist?
|
|
47
47
|
*/
|
|
48
48
|
has(key) {
|
|
49
49
|
var _a;
|
|
50
50
|
return ((_a = this.state.cache) == null ? void 0 : _a.has(key)) ?? false;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* Get the result from the cache if it exists; otherwise runs the callback, caches the result, and returns it
|
|
54
54
|
*/
|
|
55
55
|
run(...parameters) {
|
|
56
56
|
return this.state.getter(...parameters);
|
package/dist/js/index.cjs
CHANGED
|
@@ -79,7 +79,6 @@ exports.queue = queue.queue;
|
|
|
79
79
|
exports.getRandomBoolean = random.getRandomBoolean;
|
|
80
80
|
exports.getRandomCharacters = random.getRandomCharacters;
|
|
81
81
|
exports.getRandomColour = random.getRandomColour;
|
|
82
|
-
exports.getRandomDate = random.getRandomDate;
|
|
83
82
|
exports.getRandomFloat = random.getRandomFloat;
|
|
84
83
|
exports.getRandomHex = random.getRandomHex;
|
|
85
84
|
exports.getRandomInteger = random.getRandomInteger;
|
package/dist/js/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { average, max, min, round, sum } from "./math.js";
|
|
|
8
8
|
import { between, clamp, getNumber } from "./number.js";
|
|
9
9
|
import { fromQuery, toQuery } from "./query.js";
|
|
10
10
|
import { queue } from "./queue.js";
|
|
11
|
-
import { getRandomBoolean, getRandomCharacters, getRandomColour,
|
|
11
|
+
import { getRandomBoolean, getRandomCharacters, getRandomColour, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems } from "./random.js";
|
|
12
12
|
import { SizedMap, SizedSet } from "./sized.js";
|
|
13
13
|
import { createUuid, getString, join, parse, truncate, words } from "./string/index.js";
|
|
14
14
|
import "./touch.js";
|
|
@@ -77,7 +77,6 @@ export {
|
|
|
77
77
|
getRandomBoolean,
|
|
78
78
|
getRandomCharacters,
|
|
79
79
|
getRandomColour,
|
|
80
|
-
getRandomDate,
|
|
81
80
|
getRandomFloat,
|
|
82
81
|
getRandomHex,
|
|
83
82
|
getRandomInteger,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function getCallback(value) {
|
|
4
|
+
switch (typeof value) {
|
|
5
|
+
case "function":
|
|
6
|
+
return value;
|
|
7
|
+
case "number":
|
|
8
|
+
case "string":
|
|
9
|
+
return typeof value === "string" && value.includes(".") ? void 0 : (obj) => obj[value];
|
|
10
|
+
default:
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function getCallbacks(bool, key, value) {
|
|
15
|
+
if (typeof bool === "function") {
|
|
16
|
+
return { bool };
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
key: getCallback(key),
|
|
20
|
+
value: getCallback(value)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.getCallbacks = getCallbacks;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function getCallback(value) {
|
|
2
|
+
switch (typeof value) {
|
|
3
|
+
case "function":
|
|
4
|
+
return value;
|
|
5
|
+
case "number":
|
|
6
|
+
case "string":
|
|
7
|
+
return typeof value === "string" && value.includes(".") ? void 0 : (obj) => obj[value];
|
|
8
|
+
default:
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function getCallbacks(bool, key, value) {
|
|
13
|
+
if (typeof bool === "function") {
|
|
14
|
+
return { bool };
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
key: getCallback(key),
|
|
18
|
+
value: getCallback(value)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
getCallbacks
|
|
23
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
function findValue(type, array,
|
|
3
|
+
const internal_array_callbacks = require("./callbacks.cjs");
|
|
4
|
+
function findValue(type, array, bool, key, value) {
|
|
5
5
|
var _a;
|
|
6
|
-
const callbacks =
|
|
6
|
+
const callbacks = internal_array_callbacks.getCallbacks(bool, key);
|
|
7
7
|
if ((callbacks == null ? void 0 : callbacks.bool) == null && (callbacks == null ? void 0 : callbacks.key) == null) {
|
|
8
|
-
return type === "index" ? array.
|
|
8
|
+
return type === "index" ? array.findIndex((item) => item === value) : array.find((item) => item === value);
|
|
9
9
|
}
|
|
10
10
|
if (callbacks.bool != null) {
|
|
11
11
|
const index = array.findIndex(callbacks.bool);
|
|
@@ -20,28 +20,27 @@ function findValue(type, array, value, key) {
|
|
|
20
20
|
}
|
|
21
21
|
return type === "index" ? -1 : void 0;
|
|
22
22
|
}
|
|
23
|
-
function findValues(type, array,
|
|
23
|
+
function findValues(type, array, bool, key, value) {
|
|
24
24
|
var _a;
|
|
25
|
-
const callbacks =
|
|
25
|
+
const callbacks = internal_array_callbacks.getCallbacks(bool, key);
|
|
26
26
|
const { length } = array;
|
|
27
27
|
if (type === "unique" && (callbacks == null ? void 0 : callbacks.key) == null && length >= 100) {
|
|
28
28
|
return Array.from(new Set(array));
|
|
29
29
|
}
|
|
30
|
-
if (
|
|
30
|
+
if ((callbacks == null ? void 0 : callbacks.bool) != null) {
|
|
31
31
|
return array.filter(callbacks.bool);
|
|
32
32
|
}
|
|
33
33
|
if (type === "all" && key == null) {
|
|
34
34
|
return array.filter((item) => item === value);
|
|
35
35
|
}
|
|
36
|
-
const hasCallback = typeof (callbacks == null ? void 0 : callbacks.key) === "function";
|
|
37
36
|
const result = [];
|
|
38
|
-
const values =
|
|
37
|
+
const values = (callbacks == null ? void 0 : callbacks.key) != null ? [] : result;
|
|
39
38
|
for (let index = 0; index < length; index += 1) {
|
|
40
39
|
const item = array[index];
|
|
41
|
-
const
|
|
42
|
-
if (type === "all" &&
|
|
40
|
+
const keyed = ((_a = callbacks == null ? void 0 : callbacks.key) == null ? void 0 : _a.call(callbacks, item, index, array)) ?? item;
|
|
41
|
+
if (type === "all" && keyed === value || type === "unique" && values.indexOf(keyed) === -1) {
|
|
43
42
|
if (values !== result) {
|
|
44
|
-
values.push(
|
|
43
|
+
values.push(keyed);
|
|
45
44
|
}
|
|
46
45
|
result.push(item);
|
|
47
46
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getCallbacks } from "./
|
|
2
|
-
function findValue(type, array,
|
|
1
|
+
import { getCallbacks } from "./callbacks.js";
|
|
2
|
+
function findValue(type, array, bool, key, value) {
|
|
3
3
|
var _a;
|
|
4
|
-
const callbacks = getCallbacks(
|
|
4
|
+
const callbacks = getCallbacks(bool, key);
|
|
5
5
|
if ((callbacks == null ? void 0 : callbacks.bool) == null && (callbacks == null ? void 0 : callbacks.key) == null) {
|
|
6
|
-
return type === "index" ? array.
|
|
6
|
+
return type === "index" ? array.findIndex((item) => item === value) : array.find((item) => item === value);
|
|
7
7
|
}
|
|
8
8
|
if (callbacks.bool != null) {
|
|
9
9
|
const index = array.findIndex(callbacks.bool);
|
|
@@ -18,28 +18,27 @@ function findValue(type, array, value, key) {
|
|
|
18
18
|
}
|
|
19
19
|
return type === "index" ? -1 : void 0;
|
|
20
20
|
}
|
|
21
|
-
function findValues(type, array,
|
|
21
|
+
function findValues(type, array, bool, key, value) {
|
|
22
22
|
var _a;
|
|
23
|
-
const callbacks = getCallbacks(
|
|
23
|
+
const callbacks = getCallbacks(bool, key);
|
|
24
24
|
const { length } = array;
|
|
25
25
|
if (type === "unique" && (callbacks == null ? void 0 : callbacks.key) == null && length >= 100) {
|
|
26
26
|
return Array.from(new Set(array));
|
|
27
27
|
}
|
|
28
|
-
if (
|
|
28
|
+
if ((callbacks == null ? void 0 : callbacks.bool) != null) {
|
|
29
29
|
return array.filter(callbacks.bool);
|
|
30
30
|
}
|
|
31
31
|
if (type === "all" && key == null) {
|
|
32
32
|
return array.filter((item) => item === value);
|
|
33
33
|
}
|
|
34
|
-
const hasCallback = typeof (callbacks == null ? void 0 : callbacks.key) === "function";
|
|
35
34
|
const result = [];
|
|
36
|
-
const values =
|
|
35
|
+
const values = (callbacks == null ? void 0 : callbacks.key) != null ? [] : result;
|
|
37
36
|
for (let index = 0; index < length; index += 1) {
|
|
38
37
|
const item = array[index];
|
|
39
|
-
const
|
|
40
|
-
if (type === "all" &&
|
|
38
|
+
const keyed = ((_a = callbacks == null ? void 0 : callbacks.key) == null ? void 0 : _a.call(callbacks, item, index, array)) ?? item;
|
|
39
|
+
if (type === "all" && keyed === value || type === "unique" && values.indexOf(keyed) === -1) {
|
|
41
40
|
if (values !== result) {
|
|
42
|
-
values.push(
|
|
41
|
+
values.push(keyed);
|
|
43
42
|
}
|
|
44
43
|
result.push(item);
|
|
45
44
|
}
|