@oliversalzburg/js-utils 0.0.23-dev.5 → 0.0.23-dev.7

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/math/core.d.ts CHANGED
@@ -9,28 +9,28 @@ export declare const TWO_PI: number;
9
9
  * @returns The degrees in radians.
10
10
  * @group Math
11
11
  */
12
- export declare const deg2rad: (degrees: number) => number;
12
+ export declare const degreesToRadians: (degrees: number) => number;
13
13
  /**
14
14
  * Convertrs the radians to degrees.
15
15
  * @param radians - The radians to convert to degrees.
16
16
  * @returns The radians as degrees.
17
17
  * @group Math
18
18
  */
19
- export declare const rad2deg: (radians: number) => number;
19
+ export declare const radiansToDegrees: (radians: number) => number;
20
20
  /**
21
21
  * Calculates the sine for a given degree value.
22
22
  * @param value - The value in degrees to calculate the sine for.
23
23
  * @returns The sine for the given value.
24
24
  * @group Math
25
25
  */
26
- export declare const sinDeg: (value: number) => number;
26
+ export declare const sinDegrees: (value: number) => number;
27
27
  /**
28
28
  * Calculates the cosine for a given degree value.
29
29
  * @param value - The value in degrees to calculate the cosine for.
30
30
  * @returns The cosine for the given value.
31
31
  * @group Math
32
32
  */
33
- export declare const cosDeg: (value: number) => number;
33
+ export declare const cosDegrees: (value: number) => number;
34
34
  /**
35
35
  * Calculates the distance between two vectors.
36
36
  * @param x1 - The X component of the first vector.
package/math/core.js CHANGED
@@ -9,7 +9,7 @@ export const TWO_PI = /* __PURE__ */ Math.PI * 2;
9
9
  * @returns The degrees in radians.
10
10
  * @group Math
11
11
  */
12
- export const deg2rad = (degrees) => {
12
+ export const degreesToRadians = (degrees) => {
13
13
  return degrees * (Math.PI / 180);
14
14
  };
15
15
  /**
@@ -18,7 +18,7 @@ export const deg2rad = (degrees) => {
18
18
  * @returns The radians as degrees.
19
19
  * @group Math
20
20
  */
21
- export const rad2deg = (radians) => {
21
+ export const radiansToDegrees = (radians) => {
22
22
  return radians * (180 / Math.PI);
23
23
  };
24
24
  /**
@@ -27,8 +27,8 @@ export const rad2deg = (radians) => {
27
27
  * @returns The sine for the given value.
28
28
  * @group Math
29
29
  */
30
- export const sinDeg = (value) => {
31
- return Math.sin(deg2rad(value));
30
+ export const sinDegrees = (value) => {
31
+ return Math.sin(degreesToRadians(value));
32
32
  };
33
33
  /**
34
34
  * Calculates the cosine for a given degree value.
@@ -36,8 +36,8 @@ export const sinDeg = (value) => {
36
36
  * @returns The cosine for the given value.
37
37
  * @group Math
38
38
  */
39
- export const cosDeg = (value) => {
40
- return Math.cos(deg2rad(value));
39
+ export const cosDegrees = (value) => {
40
+ return Math.cos(degreesToRadians(value));
41
41
  };
42
42
  /**
43
43
  * Calculates the distance between two vectors.
package/math/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../../source/math/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,OAAe,EAAE,EAAE;IACzC,OAAO,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,OAAe,EAAE,EAAE;IACzC,OAAO,OAAO,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,EAAE;IACtC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,EAAE;IACtC,OAAO,IAAI,CAAC,GAAG,CAAC,O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C,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE;IACrC,IAAI,CAAC,KAAK,KAAK,EAAE;QACf,OAAO,CAAC,CAAC;KACV,CAAC,oBAAoB;IACtB,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,8BAA8B;IACrD,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,EAAE,GAAG,CAAC,EAAE;QACb,CAAC,GAAG,EAAE,CAAC;QACP,EAAE,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;KAC1B;IACD,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE;IACzC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;AACrC,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,KAAa,EAAE,IAAY,EAAU,EAAE;IAC1E,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AAChD,CAAC,CAAC"}
package/nil.d.ts CHANGED
@@ -15,21 +15,26 @@ export type Maybe<T> = T | Nil;
15
15
  * Check if something is nil.
16
16
  * Can be used as a typeguard.
17
17
  * @param subject - The subject that could be nil.
18
+ * @typeParam TSubject - The type of the subject.
18
19
  * @returns `true` if the subject is nil, `false` otherwise.
20
+ * @group Nullability
19
21
  */
20
- export declare function isNil<T>(subject: Maybe<T>): subject is Nil;
22
+ export declare function isNil<TSubject>(subject: Maybe<TSubject>): subject is Nil;
21
23
  /**
22
24
  * Check if something is a concrete value of the given type.
23
25
  * Can be used as a typeguard.
24
- * @param nilable - The subject that could be nil.
25
- * @param InstanceType - The type to check against.
26
+ * @param subject - The subject that could be nil.
27
+ * @param Prototype - The prototype to check against.
28
+ * @typeParam TSubject - The type to check against.
26
29
  * @returns `true` if the input element matches the given type,
27
30
  * `false` otherwise.
31
+ * @group Nullability
28
32
  */
29
- export declare function is<T>(nilable: Maybe<T>, InstanceType: ConstructorOf<T>): nilable is T;
33
+ export declare function is<TSubject>(subject: Maybe<TSubject>, Prototype: ConstructorOf<TSubject>): subject is TSubject;
30
34
  /**
31
35
  * Thrown when an unexpected nil value was encountered.
32
36
  * @group Errors
37
+ * @group Nullability
33
38
  */
34
39
  export declare class UnexpectedNilError extends Error {
35
40
  /**
@@ -42,13 +47,17 @@ export declare class UnexpectedNilError extends Error {
42
47
  * Ensure that the passed subject is not nil; throw otherwise.
43
48
  * @param subject - A subject that is possible nil.
44
49
  * @param errorMessage - An optional error message to throw when the subject is nil.
50
+ * @typeParam TSubject - The type of the subject.
45
51
  * @returns The subject, if it isn't nil.
46
52
  * @throws {@linkcode UnexpectedNilError} When the subject is nil.
53
+ * @group Nullability
47
54
  */
48
- export declare function mustExist<T>(subject: Maybe<T>, errorMessage?: string): T;
55
+ export declare function mustExist<TSubject>(subject: Maybe<TSubject>, errorMessage?: string): TSubject;
49
56
  /**
50
57
  * Ensure that the passed subject is not nil; throw otherwise.
51
58
  * @param subject - A subject that is possibly nil.
59
+ * @typeParam TSubject - The type of the subject.
52
60
  * @throws {@linkcode UnexpectedNilError} When the subject is nil.
61
+ * @group Nullability
53
62
  */
54
- export declare function assertExists<T>(subject: Maybe<T>): asserts subject is T;
63
+ export declare function assertExists<TSubject>(subject: Maybe<TSubject>): asserts subject is TSubject;
package/nil.js CHANGED
@@ -2,7 +2,9 @@
2
2
  * Check if something is nil.
3
3
  * Can be used as a typeguard.
4
4
  * @param subject - The subject that could be nil.
5
+ * @typeParam TSubject - The type of the subject.
5
6
  * @returns `true` if the subject is nil, `false` otherwise.
7
+ * @group Nullability
6
8
  */
7
9
  export function isNil(subject) {
8
10
  return subject === null || subject === undefined;
@@ -10,17 +12,20 @@ export function isNil(subject) {
10
12
  /**
11
13
  * Check if something is a concrete value of the given type.
12
14
  * Can be used as a typeguard.
13
- * @param nilable - The subject that could be nil.
14
- * @param InstanceType - The type to check against.
15
+ * @param subject - The subject that could be nil.
16
+ * @param Prototype - The prototype to check against.
17
+ * @typeParam TSubject - The type to check against.
15
18
  * @returns `true` if the input element matches the given type,
16
19
  * `false` otherwise.
20
+ * @group Nullability
17
21
  */
18
- export function is(nilable, InstanceType) {
19
- return !isNil(nilable) && nilable instanceof InstanceType;
22
+ export function is(subject, Prototype) {
23
+ return !isNil(subject) && subject instanceof Prototype;
20
24
  }
21
25
  /**
22
26
  * Thrown when an unexpected nil value was encountered.
23
27
  * @group Errors
28
+ * @group Nullability
24
29
  */
25
30
  export class UnexpectedNilError extends Error {
26
31
  /**
@@ -35,8 +40,10 @@ export class UnexpectedNilError extends Error {
35
40
  * Ensure that the passed subject is not nil; throw otherwise.
36
41
  * @param subject - A subject that is possible nil.
37
42
  * @param errorMessage - An optional error message to throw when the subject is nil.
43
+ * @typeParam TSubject - The type of the subject.
38
44
  * @returns The subject, if it isn't nil.
39
45
  * @throws {@linkcode UnexpectedNilError} When the subject is nil.
46
+ * @group Nullability
40
47
  */
41
48
  export function mustExist(subject, errorMessage) {
42
49
  if (isNil(subject)) {
@@ -47,7 +54,9 @@ export function mustExist(subject, errorMessage) {
47
54
  /**
48
55
  * Ensure that the passed subject is not nil; throw otherwise.
49
56
  * @param subject - A subject that is possibly nil.
57
+ * @typeParam TSubject - The type of the subject.
50
58
  * @throws {@linkcode UnexpectedNilError} When the subject is nil.
59
+ * @group Nullability
51
60
  */
52
61
  export function assertExists(subject) {
53
62
  if (isNil(subject)) {
package/nil.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"nil.js","sourceRoot":"","sources":["../source/nil.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AACH,MAAM,UAAU,KAAK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,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAW,OAAwB,EAAE,YAAqB;IACjF,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE;QAClB,MAAM,IAAI,kBAAkB,CAAC,YAAY,CAAC,CAAC;KAC5C;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAW,OAAwB;IAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE;QAClB,MAAM,IAAI,kBAAkB,EAAE,CAAC;KAChC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@oliversalzburg/js-utils",
4
- "version": "0.0.23-dev.5",
4
+ "version": "0.0.23-dev.7",
5
5
  "license": "MIT",
6
6
  "author": "Oliver Salzburg <oliver.salzburg@gmail.com>",
7
7
  "repository": {
@@ -35,7 +35,7 @@
35
35
  "@types/eslint": "8.44.7",
36
36
  "@types/mocha": "10.0.6",
37
37
  "@types/node": "20.9.4",
38
- "@types/web": "0.0.119",
38
+ "@types/web": "0.0.120",
39
39
  "@typescript-eslint/eslint-plugin": "6.12.0",
40
40
  "@typescript-eslint/parser": "6.12.0",
41
41
  "c8": "8.0.1",