sbd-npm 1.2.43 → 1.2.44

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/util.js +34 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.2.43",
3
+ "version": "1.2.44",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/util.js CHANGED
@@ -253,12 +253,20 @@ const Util = {
253
253
  let symbol = Util.is_alpha(item["code"]) ? item["code"].toUpperCase() : item["code"];
254
254
  let name = symbol;
255
255
  if (item["cname"]) {
256
- name = item["cname"];
256
+ if (Util.is_us(item["code"])) {
257
+ name = item["cname"].replace("公司", "");
258
+ } else {
259
+ name = item["cname"];
260
+ }
257
261
  } else if (item["name"]) {
258
262
  name = item["name"];
259
- if (Util.is_us(item["code"]) && name.indexOf(' ') !== -1) {
260
- let name_arr = name.split(' ');
261
- name = name_arr[0] ? name_arr[0] : name;
263
+ if (Util.is_us(item["code"])) {
264
+ if (name.indexOf(' ') !== -1) {
265
+ let name_arr = name.split(' ');
266
+ name = name_arr[0] ? name_arr[0] : name;
267
+ } else {
268
+ name = name.replace("公司", "");
269
+ }
262
270
  }
263
271
  name = name.substr(0, 10);
264
272
  }
@@ -2722,7 +2730,10 @@ const Util = {
2722
2730
  } else if (digit >= 10000 || digit <= -10000) {
2723
2731
  return "<span title='" + digit + "'>" + Util.to_float(digit / 10000, fraction) + "万</span>";
2724
2732
  }
2725
- return Util.to_float(digit, fraction);
2733
+ if (Util.is_float(digit)) {
2734
+ return Util.to_float(digit, fraction);
2735
+ }
2736
+ return digit;
2726
2737
  },
2727
2738
 
2728
2739
  /**
@@ -2750,6 +2761,24 @@ const Util = {
2750
2761
  return 0;
2751
2762
  },
2752
2763
 
2764
+ /**
2765
+ * 是否浮点数
2766
+ * @param n
2767
+ * @returns {boolean}
2768
+ */
2769
+ is_float: function (n) {
2770
+ return Number(n) === n && n % 1 !== 0;
2771
+ },
2772
+
2773
+ /**
2774
+ * 是否整数
2775
+ * @param n
2776
+ * @returns {boolean}
2777
+ */
2778
+ is_int: function (n) {
2779
+ return Number(n) === n && n % 1 === 0;
2780
+ },
2781
+
2753
2782
  /**
2754
2783
  * 触发事件的对象的引用
2755
2784
  * https://developer.mozilla.org/zh-CN/docs/Web/API/Event/target