From 04a7b99ce5dabda35f90a10ab36da5df24817ddf Mon Sep 17 00:00:00 2001 From: coding Date: Sun, 13 May 2018 16:14:35 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/modules/utils.js | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/main/resources/modules/utils.js diff --git a/src/main/resources/modules/utils.js b/src/main/resources/modules/utils.js new file mode 100644 index 0000000..d8f2429 --- /dev/null +++ b/src/main/resources/modules/utils.js @@ -0,0 +1,35 @@ +'use strict'; +/** + * 常用工具类 + * Created by 蒋天蓓 on 2018/5/12 0009. + */ +/*global Java, base, module, exports, require, __FILE__*/ +var Arrays = Java.type('java.util.Arrays'); + +function toStr(obj) { + if (obj.class) { + return Arrays.toString() + } +} + +function compare(prop) { + return function (obj1, obj2) { + var val1 = obj1[prop]; + var val2 = obj2[prop]; + if (!isNaN(Number(val1)) && !isNaN(Number(val2))) { + val1 = Number(val1); + val2 = Number(val2); + } + if (val1 < val2) { + return -1; + } else if (val1 > val2) { + return 1; + } else { + return 0; + } + } +} + +exports = module.exports = { + compare: compare +} \ No newline at end of file