@woosh/meep-engine 2.119.107 → 2.119.109

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.119.107",
8
+ "version": "2.119.109",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -4,7 +4,8 @@
4
4
  * @example -1 -> "11111111 11111111 11111111 11111111"
5
5
  * @param {number} input_value
6
6
  * @param {string} [byte_separator] insert this string between each group of 8 bits, defaults to a space
7
+ * @param {number} [bit_count] how many bits to actually render, cropped on the LSB
7
8
  * @returns {string}
8
9
  */
9
- export function int32_to_binary_string(input_value: number, byte_separator?: string): string;
10
+ export function int32_to_binary_string(input_value: number, byte_separator?: string, bit_count?: number): string;
10
11
  //# sourceMappingURL=int32_to_binary_string.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"int32_to_binary_string.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/int32_to_binary_string.js"],"names":[],"mappings":"AAcA;;;;;;;GAOG;AACH,oDAJW,MAAM,mBACN,MAAM,GACJ,MAAM,CA+BlB"}
1
+ {"version":3,"file":"int32_to_binary_string.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/int32_to_binary_string.js"],"names":[],"mappings":"AAcA;;;;;;;;GAQG;AACH,oDALW,MAAM,mBACN,MAAM,cACN,MAAM,GACJ,MAAM,CA+BlB"}
@@ -18,11 +18,12 @@ const MIN_VALUE = -1 * (2 ** 31);
18
18
  * @example -1 -> "11111111 11111111 11111111 11111111"
19
19
  * @param {number} input_value
20
20
  * @param {string} [byte_separator] insert this string between each group of 8 bits, defaults to a space
21
+ * @param {number} [bit_count] how many bits to actually render, cropped on the LSB
21
22
  * @returns {string}
22
23
  */
23
- export function int32_to_binary_string(input_value, byte_separator = " ") {
24
-
24
+ export function int32_to_binary_string(input_value, byte_separator = " ", bit_count = 32) {
25
25
  // @see https://stackoverflow.com/questions/9939760/how-do-i-convert-an-integer-to-binary-in-javascript
26
+ assert.lessThanOrEqual(bit_count, 32);
26
27
 
27
28
  // nMask must be between -2147483648 and 2147483647
28
29
  if (input_value > MAX_VALUE) {
@@ -36,13 +37,13 @@ export function int32_to_binary_string(input_value, byte_separator = " ") {
36
37
 
37
38
  let result = '';
38
39
 
39
- for (let bit_index = 0; bit_index < 32; bit_index++) {
40
+ for (let bit_index = 0; bit_index < bit_count; bit_index++) {
40
41
 
41
42
  if (bit_index > 0 && bit_index % 8 === 0) {
42
43
  result += byte_separator;
43
44
  }
44
45
 
45
- const bit_value = (input_value << bit_index) >>> 31;
46
+ const bit_value = (input_value << (bit_index + 32 - bit_count)) >>> 31;
46
47
 
47
48
  result += String(bit_value);
48
49