UNPKG

@3r/tool

Version:

🏃‍包含一些常用方法例如对象深克隆、递归调用、一一对比/数组交集、并集、差集/二维向量点乘、叉乘/股票KDJ、MACD、RSI、BOLL/验证为空、车牌号、邮箱、身份证、统一社会信用代码、手机号、版本对比/转换日期、星座、身份证解析、字节/随机颜色、手机号、身份证号码、统一社会信用代码...持续更新整合

32 lines (28 loc) 1.07 kB
import { Generate, v2 } from "../index.js"; let description = function () { return ["#### Generate 生成模块", "包含一些生成的方法.", "", "以下是相关示例:"]; }; let run = function () { console.log("范围数字", Generate.rangeNumber(1, 7)); // [ 1, 2, 3, 4, 5, 6 ] console.log("直线路径", Generate.straightLinePath(v2(0, 0), v2(0, 2), v2(2, 2))); // [{ x: 0, y: 0 },{ x: 0, y: 1 },{ x: 0, y: 2 },{ x: 1, y: 2 },{ x: 2, y: 2 }] }; try { describe("生成模块", function () { it("范围数字", function () { expect(Generate.rangeNumber(1, 7)).toEqual([1, 2, 3, 4, 5, 6]); expect(Generate.rangeNumber(7, 1)).toEqual([7, 6, 5, 4, 3, 2]); }); it("直线路径", function () { expect(Generate.straightLinePath(v2(0, 0), v2(0, 2), v2(2, 2))).toEqual([ { x: 0, y: 0 }, { x: 0, y: 1 }, { x: 0, y: 2 }, { x: 1, y: 2 }, { x: 2, y: 2 }, ]); }); }); } catch (error) { // describe is not defined 无需理会 调用方式不一致 } export { run, description };