lyb-js 1.4.0 → 1.4.2
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/LibJsCalculateExpression.js +1 -1
- package/Math/LibJsDecimal.js +1 -1
- package/libJs.d.ts +14 -0
- package/libJs.js +17 -1
- package/lyb.js +3698 -8
- package/package.json +1 -1
|
@@ -99,7 +99,7 @@ export const libJsCalculateExpression = (expression, point = 2) => {
|
|
|
99
99
|
try {
|
|
100
100
|
//调用计算器并返回结果
|
|
101
101
|
const result = evaluate(expression);
|
|
102
|
-
return Number(result.toFixed(point)); //保留指定的小数位数
|
|
102
|
+
return Number(result.toFixed(point, Decimal.ROUND_DOWN)); //保留指定的小数位数
|
|
103
103
|
}
|
|
104
104
|
catch (error) {
|
|
105
105
|
throw new Error("表达式计算失败:" + error.message);
|
package/Math/LibJsDecimal.js
CHANGED
package/libJs.d.ts
CHANGED
|
@@ -251,6 +251,20 @@ export declare const Misc: {
|
|
|
251
251
|
emit: <K extends keyof T>(event: K, ...args: T[K] extends any[] ? T[K] : [T[K]]) => void;
|
|
252
252
|
off: <K extends keyof T>(event: K, listener?: T[K] extends any[] ? (...args: T[K]) => void : (arg: T[K]) => void) => void;
|
|
253
253
|
};
|
|
254
|
+
/** @description 线性插值
|
|
255
|
+
* @param start 当 value = 0 时,返回 start
|
|
256
|
+
* @param end 当 value = 1 时,返回 end
|
|
257
|
+
* @param value 插值比例,取值范围 0~1
|
|
258
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsLerp-线性插值
|
|
259
|
+
*/
|
|
260
|
+
LibJsLerp: (start: number, end: number, value: number) => number;
|
|
261
|
+
/** @description 值介于起点与终点之间时返回一个介于0与1之间的数
|
|
262
|
+
* @param start 起点
|
|
263
|
+
* @param end 终点
|
|
264
|
+
* @param value 动态值
|
|
265
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsNormalizeInRange-范围归一化
|
|
266
|
+
*/
|
|
267
|
+
LibJsNormalizeInRange: (start: number, end: number, value: number) => number;
|
|
254
268
|
};
|
|
255
269
|
/** @description 随机相关方法 */
|
|
256
270
|
export declare const Random: {
|
package/libJs.js
CHANGED
|
@@ -37,7 +37,9 @@ import { libJsNumberUnit } from "./Formatter/LibJsNumberUnit";
|
|
|
37
37
|
import { libJsNumComma } from "./Formatter/LibJsNumComma";
|
|
38
38
|
import { libJsSecondsFormatterChinese } from "./Formatter/LibJsSecondsFormatterChinese";
|
|
39
39
|
import { libJsCalculateExpression } from "./Math/LibJsCalculateExpression";
|
|
40
|
-
import { LibJsEmitter } from
|
|
40
|
+
import { LibJsEmitter } from "./Misc/LibJsEmitter";
|
|
41
|
+
import { LibJsLerp } from "./Math/LibJsLerp";
|
|
42
|
+
import { LibJsNormalizeInRange } from './Math/LibJsNormalizeInRange';
|
|
41
43
|
/** @description 基础方法 */
|
|
42
44
|
export const Base = {
|
|
43
45
|
/**
|
|
@@ -260,6 +262,20 @@ export const Misc = {
|
|
|
260
262
|
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsEmitter-事件管理器
|
|
261
263
|
*/
|
|
262
264
|
LibJsEmitter,
|
|
265
|
+
/** @description 线性插值
|
|
266
|
+
* @param start 当 value = 0 时,返回 start
|
|
267
|
+
* @param end 当 value = 1 时,返回 end
|
|
268
|
+
* @param value 插值比例,取值范围 0~1
|
|
269
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsLerp-线性插值
|
|
270
|
+
*/
|
|
271
|
+
LibJsLerp,
|
|
272
|
+
/** @description 值介于起点与终点之间时返回一个介于0与1之间的数
|
|
273
|
+
* @param start 起点
|
|
274
|
+
* @param end 终点
|
|
275
|
+
* @param value 动态值
|
|
276
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsNormalizeInRange-范围归一化
|
|
277
|
+
*/
|
|
278
|
+
LibJsNormalizeInRange,
|
|
263
279
|
};
|
|
264
280
|
/** @description 随机相关方法 */
|
|
265
281
|
export const Random = {
|