@nativewrappers/fivem 0.0.27 → 0.0.28

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.
@@ -196,7 +196,6 @@ export declare class Vector {
196
196
  constructor(size: number, x?: number, y?: number, z?: number | undefined, w?: number | undefined);
197
197
  [Symbol.iterator](): Iterator<number>;
198
198
  toString(): string;
199
- toJSON(): string;
200
199
  /**
201
200
  * @see Vector.clone
202
201
  */
@@ -17,16 +17,14 @@ export class Vector {
17
17
  return new Vector2(x, x);
18
18
  if (typeof x === 'object')
19
19
  ({ x, y, z, w } = x);
20
- const type = this instanceof Vector
21
- ? this.type
22
- : `vec${[x, y, z, w].filter(arg => arg !== undefined).length}`;
23
- switch (type) {
20
+ const size = this instanceof Vector ? this.size : [x, y, z, w].filter(arg => arg !== undefined).length;
21
+ switch (size) {
24
22
  default:
25
- case ClassTypes.Vector2:
23
+ case 2:
26
24
  return new Vector2(x, y);
27
- case ClassTypes.Vector3:
25
+ case 3:
28
26
  return new Vector3(x, y, z);
29
- case ClassTypes.Vector4:
27
+ case 4:
30
28
  return new Vector4(x, y, z, w);
31
29
  }
32
30
  }
@@ -156,11 +154,12 @@ export class Vector {
156
154
  static dotProduct(a, b) {
157
155
  let result = 0;
158
156
  for (const key of ['x', 'y', 'z', 'w']) {
159
- if (key in a && key in b)
160
- result += a[key] * b[key];
161
- else {
157
+ const x = a[key];
158
+ const y = b[key];
159
+ if (!!x && !!y)
160
+ result += x * y;
161
+ else if (x || y)
162
162
  throw new Error('Vectors must have the same dimensions');
163
- }
164
163
  }
165
164
  return result;
166
165
  }
@@ -259,11 +258,7 @@ export class Vector {
259
258
  yield this.w;
260
259
  }
261
260
  toString() {
262
- const { x, y, z, w } = this;
263
- return `${this.type}(${[x, y, z, w].filter(val => val !== undefined).join(', ')})`;
264
- }
265
- toJSON() {
266
- return this.toString();
261
+ return `vector${this.size}(${this.toArray().join(', ')})`;
267
262
  }
268
263
  /**
269
264
  * @see Vector.clone
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Remco Troost <d0p3t>",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "version": "0.0.27",
7
+ "version": "0.0.28",
8
8
  "publishConfig": {
9
9
  "directory": "lib"
10
10
  },