toosoon-utils 3.0.4 → 4.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.
package/README.md CHANGED
@@ -651,6 +651,144 @@ Smoothly interpolate a number toward another.
651
651
  damp(value: number, target: number, damping: number, delta: number): number;
652
652
  ```
653
653
 
654
+ ### Random
655
+
656
+ ##### randomBoolean(probability)
657
+
658
+ Generate a random boolean (true or false).
659
+
660
+ - `[probability=0.5]`: Probability to get true.
661
+
662
+ ```ts
663
+ randomBoolean(probability?: number): boolean;
664
+ ```
665
+
666
+ ##### randomSign(probability)
667
+
668
+ Generate a random sign (1 or -1).
669
+
670
+ - `[probability=0.5]`: Probability to get 1.
671
+
672
+ ```ts
673
+ randomSign(probability?: number): number;
674
+ ```
675
+
676
+ ##### randomFloat(min, max)
677
+
678
+ Generate a random floating-point number within a specified range.
679
+
680
+ - `[min=0]`: Minimum boundary.
681
+ - `[max=1]`: Maximum boundary.
682
+ - `[precision=2]`: Number of digits after the decimal point.
683
+
684
+ ```ts
685
+ randomFloat(min?: number, max?: number, precision?: number): number;
686
+ ```
687
+
688
+ ##### randomInt(min, max)
689
+
690
+ Generate a random integer number within a specified range.
691
+
692
+ - `min`: Minimum boundary.
693
+ - `max`: Maximum boundary.
694
+
695
+ ```ts
696
+ randomInt(min: number, max: number): number;
697
+ ```
698
+
699
+ ##### randomHexColor()
700
+
701
+ Generate a random hexadecimal color.
702
+
703
+ ```ts
704
+ randomHexColor(): string;
705
+ ```
706
+
707
+ ##### randomItem(array)
708
+
709
+ Pick a random item from a given array.
710
+
711
+ - `array`: Array to pick the item from.
712
+
713
+ ```ts
714
+ randomItem<T>(array: T[]): T | undefined;
715
+ ```
716
+
717
+ ##### randomObjectProperty(object)
718
+
719
+ Pick a random property value from a given object.
720
+
721
+ - `object`: Object to pick the property from.
722
+
723
+ ```ts
724
+ randomObjectProperty<T>(object: Record<string, T>): T | undefined;
725
+ ```
726
+
727
+ ##### randomIndex(weights)
728
+
729
+ Select a random index from an array of weighted items.
730
+
731
+ - `weights`: Array of weights.
732
+
733
+ ```ts
734
+ randomIndex(weights: number[]): number;
735
+ ```
736
+
737
+ ##### randomGaussian(mean, spread)
738
+
739
+ Generate a random number fitting a Gaussian (normal) distribution.
740
+
741
+ - `[mean=0]`: Central value.
742
+ - `[spread=1]`: Standard deviation.
743
+
744
+ ```ts
745
+ randomGaussian(mean?: number, spread?: number): number;
746
+ ```
747
+
748
+ ##### onCircle(radius)
749
+
750
+ Produce a random 2D point around the perimiter of a unit circle.
751
+
752
+ - `[radius=1]`: Radius of the circle.
753
+ - `[target]`: Target vector.
754
+
755
+ ```ts
756
+ onCircle(radius?: number, target?: Vector2): Vector2;
757
+ ```
758
+
759
+ ##### insideCircle(radius)
760
+
761
+ Produce a random 2D point inside a unit circle.
762
+
763
+ - `[radius=1]`: Radius of the circle.
764
+ - `[target]` Target vector.
765
+
766
+ ```ts
767
+ insideCircle(radius?: number, target?: Vector2): Vector2;
768
+ ```
769
+
770
+ ##### onSphere(radius)
771
+
772
+ Produce a random 3D point on the surface of a unit sphere.
773
+
774
+ - `[radius=1]`: Radius of the sphere.
775
+ - `[target]`: Target vector.
776
+
777
+ ```ts
778
+ onSphere(radius?: number, target?: Vector3): Vector3;
779
+ ```
780
+
781
+ ##### insideSphere(radius)
782
+
783
+ Produce a random 3D point inside a unit sphere.
784
+
785
+ - `[radius=1]`: Radius of the sphere.
786
+ - `[target]`: Target vector.
787
+
788
+ ```ts
789
+ insideSphere(radius?: number, target?: Vector3): Vector3;
790
+ ```
791
+
654
792
  ### Pseudo-Random Number Generator (PRNG)
655
793
 
656
794
  #### PRNG Algorithms
@@ -709,7 +847,7 @@ xoshiro128ss(a: number, b: number, c: number, d: number): number;
709
847
 
710
848
  #### PRNG functions
711
849
 
712
- Thanks to the above algorithms, a seed-based version of most of the [random functions](#random) are exist with additionnal parameters for a `seed` string and a PRNG `algorithm` function.
850
+ Thanks to the above algorithms, a seed-based version of most of the [random functions](#random) exist with additionnal parameters for a `seed` string and a PRNG `algorithm` function.
713
851
 
714
852
  PRNG parameters:
715
853
 
@@ -829,164 +967,143 @@ Generate a pseudo-random number fitting a Gaussian (normal) distribution.
829
967
  randomGaussian(prng: string | object, mean?: number, spread?: number): number;
830
968
  ```
831
969
 
832
- ### Random
970
+ ### Query parameters
833
971
 
834
- ##### randomBoolean(probability)
972
+ ##### getQuery(property)
835
973
 
836
- Generate a random boolean (true or false).
974
+ Get a query parameter.
837
975
 
838
- - `[probability=0.5]`: Probability to get true.
976
+ - `property`: Query property to check.
839
977
 
840
978
  ```ts
841
- randomBoolean(probability?: number): boolean;
979
+ getQuery(property: string): string | null;
842
980
  ```
843
981
 
844
- ##### randomSign(probability)
982
+ ##### setQuery(property)
845
983
 
846
- Generate a random sign (1 or -1).
984
+ Set a query parameter.
847
985
 
848
- - `[probability=0.5]`: Probability to get 1.
986
+ - `property`: Query property to set.
987
+ - `value`: Value to set.
849
988
 
850
989
  ```ts
851
- randomSign(probability?: number): number;
990
+ setQuery(property: string, value: string): void;
852
991
  ```
853
992
 
854
- ##### randomFloat(min, max)
993
+ ##### hasQuery(property)
855
994
 
856
- Generate a random floating-point number within a specified range.
995
+ Check if a query parameter exists.
857
996
 
858
- - `[min=0]`: Minimum boundary.
859
- - `[max=1]`: Maximum boundary.
860
- - `[precision=2]`: Number of digits after the decimal point.
997
+ - `property`: Query property to check.
861
998
 
862
999
  ```ts
863
- randomFloat(min?: number, max?: number, precision?: number): number;
1000
+ hasQuery(property: string): boolean;
864
1001
  ```
865
1002
 
866
- ##### randomInt(min, max)
867
-
868
- Generate a random integer number within a specified range.
1003
+ ### Strings
869
1004
 
870
- - `min`: Minimum boundary.
871
- - `max`: Maximum boundary.
1005
+ #### Cases
872
1006
 
873
- ```ts
874
- randomInt(min: number, max: number): number;
875
- ```
1007
+ ##### capitalize(string)
876
1008
 
877
- ##### randomHexColor()
1009
+ Capitalize a string.
878
1010
 
879
- Generate a random hexadecimal color.
1011
+ - `string`: String to capitalize.
880
1012
 
881
1013
  ```ts
882
- randomHexColor(): string;
1014
+ capitalize(string: string): string;
883
1015
  ```
884
1016
 
885
- ##### randomItem(array)
1017
+ ##### toKebabCase(string)
886
1018
 
887
- Pick a random item from a given array.
1019
+ Convert a string to kebab-case: 'Hello world' -> 'hello-world'.
888
1020
 
889
- - `array`: Array to pick the item from.
1021
+ - `string`: String to convert.
890
1022
 
891
1023
  ```ts
892
- randomItem<T>(array: T[]): T | undefined;
1024
+ toKebabCase(string: string): string;
893
1025
  ```
894
1026
 
895
- ##### randomObjectProperty(object)
1027
+ ##### toSnakeCase(string)
896
1028
 
897
- Pick a random property value from a given object.
1029
+ Convert a string to snake_case: 'Hello world' -> 'hello_world'.
898
1030
 
899
- - `object`: Object to pick the property from.
1031
+ - `string`: String to convert.
900
1032
 
901
1033
  ```ts
902
- randomObjectProperty<T>(object: Record<string, T>): T | undefined;
1034
+ toSnakeCase(string: string): string;
903
1035
  ```
904
1036
 
905
- ##### randomIndex(weights)
1037
+ ##### toCamelCase(string)
906
1038
 
907
- Select a random index from an array of weighted items.
1039
+ Convert a string to camelCase: 'Hello world' -> 'helloWorld'.
908
1040
 
909
- - `weights`: Array of weights.
1041
+ - `string`: String to convert.
910
1042
 
911
1043
  ```ts
912
- randomIndex(weights: number[]): number;
1044
+ toCamelCase(string: string): string;
913
1045
  ```
914
1046
 
915
- ##### randomGaussian(mean, spread)
1047
+ ##### toPascalCase(string)
916
1048
 
917
- Generate a random number fitting a Gaussian (normal) distribution.
1049
+ Convert a string to PascalCase: 'Hello world' -> 'HelloWorld'.
918
1050
 
919
- - `[mean=0]`: Central value.
920
- - `[spread=1]`: Standard deviation.
1051
+ - `string`: String to convert.
921
1052
 
922
1053
  ```ts
923
- randomGaussian(mean?: number, spread?: number): number;
1054
+ toPascalCase(string: string): string;
924
1055
  ```
925
1056
 
926
- ##### onCircle(radius)
1057
+ ##### toTrainCase(string)
927
1058
 
928
- Produce a random 2D point around the perimiter of a unit circle.
1059
+ Convert a string to Train-Case: 'Hello world' -> 'Hello-World'.
929
1060
 
930
- - `[radius=1]`: Radius of the circle.
931
- - `[target]`: Target vector.
1061
+ - `string`: String to convert.
932
1062
 
933
1063
  ```ts
934
- onCircle(radius?: number, target?: Vector2): Vector2;
1064
+ toTrainCase(string: string): string;
935
1065
  ```
936
1066
 
937
- ##### insideCircle(radius)
1067
+ ##### toConstantCase(string)
938
1068
 
939
- Produce a random 2D point inside a unit circle.
1069
+ Convert a string to CONSTANT_CASE: 'Hello world' -> 'HELLO_WORLD'.
940
1070
 
941
- - `[radius=1]`: Radius of the circle.
942
- - `[target]` Target vector.
1071
+ - `string`: String to convert.
943
1072
 
944
1073
  ```ts
945
- insideCircle(radius?: number, target?: Vector2): Vector2;
1074
+ toConstantCase(string: string): string;
946
1075
  ```
947
1076
 
948
- ##### onSphere(radius)
949
-
950
- Produce a random 3D point on the surface of a unit sphere.
951
-
952
- - `[radius=1]`: Radius of the sphere.
953
- - `[target]`: Target vector.
954
-
955
- ```ts
956
- onSphere(radius?: number, target?: Vector3): Vector3;
957
- ```
1077
+ #### Paths
958
1078
 
959
- ##### insideSphere(radius)
1079
+ ##### cleanPath(path)
960
1080
 
961
- Produce a random 3D point inside a unit sphere.
1081
+ Clean a path by removing its parameters.
962
1082
 
963
- - `[radius=1]`: Radius of the sphere.
964
- - `[target]`: Target vector.
1083
+ - `path`: Path to clean.
965
1084
 
966
1085
  ```ts
967
- insideSphere(radius?: number, target?: Vector3): Vector3;
1086
+ cleanPath(path: string): string;
968
1087
  ```
969
1088
 
970
- ### Strings
1089
+ ##### addTrailingSlash(path)
971
1090
 
972
- ##### capitalize(string)
1091
+ Convert a path by ensuring it has a trailing slash.
973
1092
 
974
- Capitalize a string.
975
-
976
- - `string`: String to capitalize.
1093
+ - `path`: Path to convert.
977
1094
 
978
1095
  ```ts
979
- capitalize(string: string): string;
1096
+ addTrailingSlash(path: string): string;
980
1097
  ```
981
1098
 
982
- ##### cleanPath(path)
1099
+ ##### removeTrailingSlash(path)
983
1100
 
984
- Clean a path by removing params.
1101
+ Convert a path by ensuring it has not a trailing slash.
985
1102
 
986
- - `path`: Path to clean.
1103
+ - `path`: Path to convert.
987
1104
 
988
1105
  ```ts
989
- cleanPath(path: string): string;
1106
+ removeTrailingSlash(path: string): string;
990
1107
  ```
991
1108
 
992
1109
  ## Utility classes
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  // *********************
3
2
  // WIP
4
3
  // *********************
@@ -22,9 +21,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
22
21
  }
23
22
  return to.concat(ar || Array.prototype.slice.call(from));
24
23
  };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.defaultSettings = void 0;
27
- exports.defaultSettings = {
24
+ export var defaultSettings = {
28
25
  max: Infinity
29
26
  };
30
27
  /**
@@ -35,10 +32,10 @@ exports.defaultSettings = {
35
32
  */
36
33
  var Pool = /** @class */ (function () {
37
34
  function Pool(settings) {
38
- if (settings === void 0) { settings = __assign({}, exports.defaultSettings); }
35
+ if (settings === void 0) { settings = __assign({}, defaultSettings); }
39
36
  this.items = [];
40
37
  this.pool = [];
41
- this.settings = __assign({}, exports.defaultSettings);
38
+ this.settings = __assign({}, defaultSettings);
42
39
  this.settings = Object.assign(this.settings, settings);
43
40
  }
44
41
  /**
@@ -92,4 +89,4 @@ var Pool = /** @class */ (function () {
92
89
  };
93
90
  return Pool;
94
91
  }());
95
- exports.default = Pool;
92
+ export default Pool;
@@ -1,4 +1,4 @@
1
- import { ColorRepresentation } from '../types';
1
+ import type { ColorRepresentation } from '../types';
2
2
  export type ColorScaleSettings = {
3
3
  colorSpace: 'rgb';
4
4
  } | {
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __assign = (this && this.__assign) || function () {
3
2
  __assign = Object.assign || function(t) {
4
3
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -10,11 +9,9 @@ var __assign = (this && this.__assign) || function () {
10
9
  };
11
10
  return __assign.apply(this, arguments);
12
11
  };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.defaultSettings = void 0;
15
- var maths_1 = require("../maths");
16
- var colors_1 = require("../colors");
17
- exports.defaultSettings = {
12
+ import { lerp, triLerp } from '../maths';
13
+ import { hclToRgb, hsbToRgb, hslToRgb, normalizeColor, rgbToHcl, rgbToHsb, rgbToHsl } from '../colors';
14
+ export var defaultSettings = {
18
15
  colorSpace: 'rgb'
19
16
  };
20
17
  /**
@@ -32,7 +29,7 @@ var ColorScale = /** @class */ (function () {
32
29
  */
33
30
  function ColorScale(input, target, length, settings) {
34
31
  if (length === void 0) { length = 5; }
35
- if (settings === void 0) { settings = __assign({}, exports.defaultSettings); }
32
+ if (settings === void 0) { settings = __assign({}, defaultSettings); }
36
33
  /**
37
34
  * Array of colors composing the color scale
38
35
  */
@@ -49,10 +46,10 @@ var ColorScale = /** @class */ (function () {
49
46
  * @returns {Array<[number, number, number]>} Color scale colors
50
47
  */
51
48
  ColorScale.generate = function (input, target, length, settings) {
52
- if (settings === void 0) { settings = __assign({}, exports.defaultSettings); }
49
+ if (settings === void 0) { settings = __assign({}, defaultSettings); }
53
50
  var colors = [];
54
- var inputColor = (0, colors_1.normalizeColor)(input);
55
- var targetColor = (0, colors_1.normalizeColor)(target);
51
+ var inputColor = normalizeColor(input);
52
+ var targetColor = normalizeColor(target);
56
53
  for (var i = 0; i < length; i++) {
57
54
  var value = i / Math.floor(length);
58
55
  colors.push(ColorScale.interpolate(inputColor, targetColor, value, settings));
@@ -70,45 +67,45 @@ var ColorScale = /** @class */ (function () {
70
67
  */
71
68
  ColorScale.interpolate = function (inputColor, targetColor, value, settings) {
72
69
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
73
- if (settings === void 0) { settings = __assign({}, exports.defaultSettings); }
70
+ if (settings === void 0) { settings = __assign({}, defaultSettings); }
74
71
  switch (settings.colorSpace) {
75
72
  case 'rgb': {
76
- var r = (0, maths_1.lerp)(value, inputColor[0], targetColor[0]);
77
- var g = (0, maths_1.lerp)(value, inputColor[1], targetColor[1]);
78
- var b = (0, maths_1.lerp)(value, inputColor[2], targetColor[2]);
73
+ var r = lerp(value, inputColor[0], targetColor[0]);
74
+ var g = lerp(value, inputColor[1], targetColor[1]);
75
+ var b = lerp(value, inputColor[2], targetColor[2]);
79
76
  return [r, g, b];
80
77
  }
81
78
  case 'hsl': {
82
- var inputHsl = (0, colors_1.rgbToHsl)(inputColor);
83
- var targetHsl = (0, colors_1.rgbToHsl)(targetColor);
79
+ var inputHsl = rgbToHsl(inputColor);
80
+ var targetHsl = rgbToHsl(targetColor);
84
81
  var h1_1 = inputHsl[0];
85
82
  var s1 = inputHsl[1];
86
83
  var l1_1 = inputHsl[2];
87
84
  var h2_1 = targetHsl[0] + ((_a = settings.hueOffset) !== null && _a !== void 0 ? _a : 0);
88
85
  var s2 = targetHsl[1] + ((_b = settings.saturationOffset) !== null && _b !== void 0 ? _b : 0);
89
86
  var l2_1 = targetHsl[2] + ((_c = settings.lightnessOffset) !== null && _c !== void 0 ? _c : 0);
90
- var h_1 = (0, maths_1.lerp)(value, h1_1, h2_1);
91
- var s = (0, maths_1.lerp)(value, s1, s2);
92
- var l_1 = (0, maths_1.lerp)(value, l1_1, l2_1);
93
- return (0, colors_1.hslToRgb)([h_1, s, l_1]);
87
+ var h_1 = lerp(value, h1_1, h2_1);
88
+ var s = lerp(value, s1, s2);
89
+ var l_1 = lerp(value, l1_1, l2_1);
90
+ return hslToRgb([h_1, s, l_1]);
94
91
  }
95
92
  case 'hsb': {
96
- var inputHsb = (0, colors_1.rgbToHsb)(inputColor);
97
- var targetHsb = (0, colors_1.rgbToHsb)(targetColor);
93
+ var inputHsb = rgbToHsb(inputColor);
94
+ var targetHsb = rgbToHsb(targetColor);
98
95
  var h1_2 = inputHsb[0];
99
96
  var s1 = inputHsb[1];
100
97
  var b1 = inputHsb[2];
101
98
  var h2_2 = targetHsb[0] + ((_d = settings.hueOffset) !== null && _d !== void 0 ? _d : 0);
102
99
  var s2 = targetHsb[1] + ((_e = settings.saturationOffset) !== null && _e !== void 0 ? _e : 0);
103
100
  var b2 = targetHsb[2] + ((_f = settings.brightnessOffset) !== null && _f !== void 0 ? _f : 0);
104
- var h_2 = (0, maths_1.lerp)(value, h1_2, h2_2);
105
- var s = (0, maths_1.lerp)(value, s1, s2);
106
- var b = (0, maths_1.lerp)(value, b1, b2);
107
- return (0, colors_1.hsbToRgb)([h_2, s, b]);
101
+ var h_2 = lerp(value, h1_2, h2_2);
102
+ var s = lerp(value, s1, s2);
103
+ var b = lerp(value, b1, b2);
104
+ return hsbToRgb([h_2, s, b]);
108
105
  }
109
106
  case 'hcl':
110
- var inputHcl = (0, colors_1.rgbToHcl)(inputColor);
111
- var targetHcl = (0, colors_1.rgbToHcl)(targetColor);
107
+ var inputHcl = rgbToHcl(inputColor);
108
+ var targetHcl = rgbToHcl(targetColor);
112
109
  var powerValue = Math.pow(value, (_g = settings.powerStrength) !== null && _g !== void 0 ? _g : 1);
113
110
  var h1 = inputHcl[0];
114
111
  var c1 = inputHcl[1];
@@ -131,7 +128,7 @@ var ColorScale = /** @class */ (function () {
131
128
  * - Luminance: Constant
132
129
  */
133
130
  case 'qualitative': {
134
- h = (0, maths_1.lerp)(value, h1, h2);
131
+ h = lerp(value, h1, h2);
135
132
  c = c1;
136
133
  l = l1;
137
134
  }
@@ -145,9 +142,9 @@ var ColorScale = /** @class */ (function () {
145
142
  * - Luminance: Linear (+power)
146
143
  */
147
144
  case 'sequential': {
148
- h = (0, maths_1.lerp)(value, h1, h2);
149
- c = settings.triangular ? (0, maths_1.triLerp)(powerValue, c1, c2, settings.triangular) : (0, maths_1.lerp)(powerValue, c1, c2);
150
- l = (0, maths_1.lerp)(powerValue, l1, l2);
145
+ h = lerp(value, h1, h2);
146
+ c = settings.triangular ? triLerp(powerValue, c1, c2, settings.triangular) : lerp(powerValue, c1, c2);
147
+ l = lerp(powerValue, l1, l2);
151
148
  }
152
149
  /**
153
150
  * Diverging
@@ -159,19 +156,19 @@ var ColorScale = /** @class */ (function () {
159
156
  * - Luminance: Linear (+power)
160
157
  */
161
158
  case 'diverging': {
162
- h = value < 0.5 ? h1 : value > 0.5 ? h2 : (0, maths_1.lerp)(0.5, h1, h2);
163
- c = settings.triangular ? (0, maths_1.triLerp)(powerValue, c1, c2, settings.triangular) : (0, maths_1.lerp)(powerValue, c1, c2);
164
- l = (0, maths_1.lerp)(powerValue, l1, l2);
159
+ h = value < 0.5 ? h1 : value > 0.5 ? h2 : lerp(0.5, h1, h2);
160
+ c = settings.triangular ? triLerp(powerValue, c1, c2, settings.triangular) : lerp(powerValue, c1, c2);
161
+ l = lerp(powerValue, l1, l2);
165
162
  }
166
163
  default: {
167
- h = (0, maths_1.lerp)(value, h1, h2);
168
- c = (0, maths_1.lerp)(value, c1, c2);
169
- l = (0, maths_1.lerp)(value, l1, l2);
164
+ h = lerp(value, h1, h2);
165
+ c = lerp(value, c1, c2);
166
+ l = lerp(value, l1, l2);
170
167
  }
171
168
  }
172
- return (0, colors_1.hclToRgb)([h, c, l]);
169
+ return hclToRgb([h, c, l]);
173
170
  }
174
171
  };
175
172
  return ColorScale;
176
173
  }());
177
- exports.default = ColorScale;
174
+ export default ColorScale;
@@ -6,10 +6,10 @@
6
6
  */
7
7
  export default class FrameRate {
8
8
  private _fps;
9
- private interval;
10
- private time;
11
- private elapsedTime;
12
- private lastUpdate;
9
+ private _interval;
10
+ private _time;
11
+ private _elapsedTime;
12
+ private _lastUpdate;
13
13
  /**
14
14
  * @param {number} [fps=30] Frame per second limit
15
15
  */
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var functions_1 = require("../functions");
1
+ import { now } from '../functions';
4
2
  /**
5
3
  * Utility class for controlling FPS calls
6
4
  *
@@ -13,11 +11,10 @@ var FrameRate = /** @class */ (function () {
13
11
  */
14
12
  function FrameRate(fps) {
15
13
  if (fps === void 0) { fps = 30; }
16
- this.interval = 0;
17
- this.time = 0;
18
- this.elapsedTime = 0;
19
- this.lastUpdate = 0;
20
- this._fps = fps;
14
+ this._interval = 0;
15
+ this._time = 0;
16
+ this._elapsedTime = 0;
17
+ this._lastUpdate = 0;
21
18
  this.fps = fps;
22
19
  }
23
20
  /**
@@ -26,12 +23,12 @@ var FrameRate = /** @class */ (function () {
26
23
  * @returns {boolean}
27
24
  */
28
25
  FrameRate.prototype.update = function () {
29
- this.time = (0, functions_1.now)();
30
- this.elapsedTime = this.time - this.lastUpdate;
31
- if (this.elapsedTime < this.interval) {
26
+ this._time = now();
27
+ this._elapsedTime = this._time - this._lastUpdate;
28
+ if (this._elapsedTime < this._interval) {
32
29
  return false;
33
30
  }
34
- this.lastUpdate = this.time - (this.elapsedTime % this.interval);
31
+ this._lastUpdate = this._time - (this._elapsedTime % this._interval);
35
32
  return true;
36
33
  };
37
34
  Object.defineProperty(FrameRate.prototype, "fps", {
@@ -40,11 +37,11 @@ var FrameRate = /** @class */ (function () {
40
37
  },
41
38
  set: function (fps) {
42
39
  this._fps = fps;
43
- this.interval = 1000 / fps;
40
+ this._interval = 1000 / fps;
44
41
  },
45
42
  enumerable: false,
46
43
  configurable: true
47
44
  });
48
45
  return FrameRate;
49
46
  }());
50
- exports.default = FrameRate;
47
+ export default FrameRate;
package/lib/colors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ColorRepresentation } from './types';
1
+ import type { ColorRepresentation } from './types';
2
2
  /**
3
3
  * Normalize a color representation into RGB
4
4
  *
@@ -33,7 +33,7 @@ export declare function rgbToHexString([r, g, b]: [number, number, number]): str
33
33
  * Convert hexadecimal to RGB
34
34
  * Note: rgb values are contained in the interval [0, 1]
35
35
  *
36
- * @param {(number|string)} hex Hexadecimal color
36
+ * @param {number|string} hex Hexadecimal color
37
37
  * @returns {[number, number, number]} RGB color
38
38
  */
39
39
  export declare function hexToRgb(hex: number | string): [number, number, number];