@woosh/meep-engine 2.84.5 → 2.84.6
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/build/meep.cjs +30 -30
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +30 -30
- package/package.json +1 -1
- package/src/core/collection/list/List.js +1 -1
- package/src/core/primitives/numbers/number_count_decimals.js +30 -0
- package/src/core/primitives/numbers/number_pretty_print.js +7 -29
- package/src/core/primitives/strings/string_format_camel_to_kebab.js +2 -0
- package/src/core/primitives/strings/string_strip_trailing.js +22 -0
- package/src/core/primitives/strings/string_strip_trailing.spec.js +27 -0
- package/src/engine/ecs/storage/BinaryBufferDeSerializer.js +8 -1
package/build/meep.cjs
CHANGED
|
@@ -61271,7 +61271,7 @@ class List {
|
|
|
61271
61271
|
this.data.push(el);
|
|
61272
61272
|
const oldLength = this.length;
|
|
61273
61273
|
|
|
61274
|
-
this.length
|
|
61274
|
+
this.length = oldLength + 1;
|
|
61275
61275
|
|
|
61276
61276
|
this.on.added.send2(el, oldLength);
|
|
61277
61277
|
return this;
|
|
@@ -96086,40 +96086,38 @@ LinearValue.prototype.fromJSON = function (json) {
|
|
|
96086
96086
|
|
|
96087
96087
|
/**
|
|
96088
96088
|
*
|
|
96089
|
-
* @param {
|
|
96090
|
-
* @param {string}
|
|
96089
|
+
* @param {string} string
|
|
96090
|
+
* @param {string} trailing_sequence
|
|
96091
96091
|
* @returns {string}
|
|
96092
96092
|
*/
|
|
96093
|
-
function
|
|
96093
|
+
function string_strip_trailing(string, trailing_sequence) {
|
|
96094
|
+
const trailing_sequence_length = trailing_sequence.length;
|
|
96094
96095
|
|
|
96095
|
-
|
|
96096
|
+
if (trailing_sequence_length <= 0) {
|
|
96097
|
+
// special case to avoid infinite looping
|
|
96098
|
+
return string;
|
|
96099
|
+
}
|
|
96100
|
+
|
|
96101
|
+
let end_index = string.length;
|
|
96102
|
+
|
|
96103
|
+
while (string.substring(end_index - trailing_sequence_length, end_index) === trailing_sequence) {
|
|
96104
|
+
end_index -= trailing_sequence_length;
|
|
96105
|
+
}
|
|
96106
|
+
|
|
96107
|
+
return string.substring(0, end_index);
|
|
96096
96108
|
}
|
|
96097
96109
|
|
|
96098
96110
|
/**
|
|
96099
96111
|
*
|
|
96100
|
-
* @param {
|
|
96101
|
-
* @
|
|
96112
|
+
* @param {number} x
|
|
96113
|
+
* @param {string} [separator=',']
|
|
96114
|
+
* @returns {string}
|
|
96102
96115
|
*/
|
|
96103
|
-
function
|
|
96104
|
-
if (value % 1 === 0) {
|
|
96105
|
-
//whole number
|
|
96106
|
-
return 0;
|
|
96107
|
-
}
|
|
96108
|
-
const s = value.toString();
|
|
96109
|
-
const index = s.indexOf('.');
|
|
96110
|
-
|
|
96111
|
-
if (index === -1) {
|
|
96112
|
-
return 0;
|
|
96113
|
-
}
|
|
96114
|
-
|
|
96115
|
-
//find last 0
|
|
96116
|
-
let endIndex = s.length - 1;
|
|
96117
|
-
for (; endIndex > index && s.charAt(endIndex) === "0"; endIndex--) {
|
|
96118
|
-
|
|
96119
|
-
}
|
|
96120
|
-
return endIndex - index;
|
|
96121
|
-
}
|
|
96116
|
+
function number_format_by_thousands(x, separator = ',') {
|
|
96122
96117
|
|
|
96118
|
+
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, separator);
|
|
96119
|
+
}
|
|
96120
|
+
|
|
96123
96121
|
/**
|
|
96124
96122
|
*
|
|
96125
96123
|
* @param {number} value
|
|
@@ -96130,10 +96128,12 @@ function number_pretty_print(value) {
|
|
|
96130
96128
|
const MAX_DECIMALS = 2;
|
|
96131
96129
|
|
|
96132
96130
|
const fraction = value % 1;
|
|
96133
|
-
|
|
96134
|
-
|
|
96135
|
-
|
|
96136
|
-
|
|
96131
|
+
|
|
96132
|
+
const would_produce_decimals = fraction * Math.pow(10, MAX_DECIMALS) > 0;
|
|
96133
|
+
|
|
96134
|
+
if (would_produce_decimals && Math.abs(value) < 100) {
|
|
96135
|
+
const truncated = value.toFixed(MAX_DECIMALS);
|
|
96136
|
+
return string_strip_trailing(truncated, "0");
|
|
96137
96137
|
} else {
|
|
96138
96138
|
//no fraction
|
|
96139
96139
|
return number_format_by_thousands(value - fraction, ",");
|