pubo-utils 1.0.129 → 1.0.142

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.
@@ -1,49 +1,55 @@
1
1
  "use strict";
2
2
 
3
- var __values = this && this.__values || function (o) {
4
- var s = typeof Symbol === "function" && Symbol.iterator,
5
- m = s && o[s],
6
- i = 0;
7
- if (m) return m.call(o);
8
- if (o && typeof o.length === "number") return {
9
- next: function next() {
10
- if (o && i >= o.length) o = void 0;
11
- return {
12
- value: o && o[i++],
13
- done: !o
14
- };
15
- }
16
- };
17
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
18
- };
3
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
19
6
  Object.defineProperty(exports, "__esModule", {
20
7
  value: true
21
8
  });
22
9
  exports.StringSplit = exports.SensorDataFilter = void 0;
23
10
  // 过滤跳变数据
24
- var SensorDataFilter = /** @class */function () {
25
- function SensorDataFilter(_a) {
26
- var _b = _a === void 0 ? {} : _a,
27
- _c = _b.size,
28
- size = _c === void 0 ? 5 : _c,
29
- _d = _b.step,
30
- step = _d === void 0 ? 5 : _d,
31
- _e = _b.min,
32
- min = _e === void 0 ? -Infinity : _e,
33
- _f = _b.max,
34
- max = _f === void 0 ? Infinity : _f;
35
- // 缓冲区
11
+ var SensorDataFilter = /*#__PURE__*/function () {
12
+ // 缓冲区
13
+
14
+ // 最大缓存
15
+
16
+ // 跳变步长
17
+
18
+ // 最小值
19
+
20
+ // 最大值
21
+
22
+ // 与缓冲区不一致的值连续出现的次数 (不一致指的是与缓冲区中数量最多的数值不同且差值大于步长)
23
+
24
+ // 与缓冲区不一致的值
25
+
26
+ // 上一次正确返回的值
27
+
28
+ function SensorDataFilter(_temp) {
29
+ var _ref = _temp === void 0 ? {} : _temp,
30
+ _ref$size = _ref.size,
31
+ size = _ref$size === void 0 ? 5 : _ref$size,
32
+ _ref$step = _ref.step,
33
+ step = _ref$step === void 0 ? 5 : _ref$step,
34
+ _ref$min = _ref.min,
35
+ min = _ref$min === void 0 ? -Infinity : _ref$min,
36
+ _ref$max = _ref.max,
37
+ max = _ref$max === void 0 ? Infinity : _ref$max;
36
38
  this.tmp = [];
37
- // 与缓冲区不一致的值连续出现的次数 (不一致指的是与缓冲区中数量最多的数值不同且差值大于步长)
39
+ this.size = void 0;
40
+ this.step = void 0;
41
+ this.min = void 0;
42
+ this.max = void 0;
38
43
  this.count = 0;
39
- // 与缓冲区不一致的值
40
44
  this.value = NaN;
45
+ this.old = void 0;
41
46
  this.size = size;
42
47
  this.step = step;
43
48
  this.min = min;
44
49
  this.max = max;
45
50
  }
46
- SensorDataFilter.prototype.filter = function (n) {
51
+ var _proto = SensorDataFilter.prototype;
52
+ _proto.filter = function filter(n) {
47
53
  // 溢出范围的值将被忽略
48
54
  if (n < this.min || n > this.max) {
49
55
  return this.old;
@@ -52,7 +58,7 @@ var SensorDataFilter = /** @class */function () {
52
58
  this.old = this.calc(n);
53
59
  return this.old;
54
60
  };
55
- SensorDataFilter.prototype.calc = function (n) {
61
+ _proto.calc = function calc(n) {
56
62
  // 缓冲区没有值时直接返回当前值
57
63
  if (this.tmp.length < 1) {
58
64
  return n;
@@ -60,9 +66,9 @@ var SensorDataFilter = /** @class */function () {
60
66
  if (this.tmp.length > this.size) {
61
67
  this.tmp.shift();
62
68
  }
63
- var _a = this.getMostNumberOfTmp(),
64
- res = _a.res,
65
- dic = _a.dic;
69
+ var _this$getMostNumberOf = this.getMostNumberOfTmp(),
70
+ res = _this$getMostNumberOf.res,
71
+ dic = _this$getMostNumberOf.dic;
66
72
  // 当前值与缓冲区数量最多的值不一致且差值大于步长
67
73
  if (res !== n && Math.abs(res - n) > this.step) {
68
74
  // 累计跳变数据连续出现的次数
@@ -85,39 +91,26 @@ var SensorDataFilter = /** @class */function () {
85
91
  return n;
86
92
  }
87
93
  return res;
88
- };
94
+ }
89
95
  /**
90
96
  * A function to calculate the most frequent element in the 'tmp' array and its frequency.
91
97
  *
92
98
  * @return {object} An object containing the most frequent element and its frequency.
93
- */
94
- SensorDataFilter.prototype.getMostNumberOfTmp = function () {
95
- var e_1, _a;
99
+ */;
100
+ _proto.getMostNumberOfTmp = function getMostNumberOfTmp() {
96
101
  var a = {};
97
102
  var max = 0;
98
103
  var res;
99
- try {
100
- for (var _b = __values(this.tmp), _c = _b.next(); !_c.done; _c = _b.next()) {
101
- var item = _c.value;
102
- if (!a[item]) {
103
- a[item] = 1;
104
- } else {
105
- a[item] += 1;
106
- }
107
- if (a[item] > max) {
108
- max = a[item];
109
- res = item;
110
- }
104
+ for (var _iterator = _createForOfIteratorHelperLoose(this.tmp), _step; !(_step = _iterator()).done;) {
105
+ var item = _step.value;
106
+ if (!a[item]) {
107
+ a[item] = 1;
108
+ } else {
109
+ a[item] += 1;
111
110
  }
112
- } catch (e_1_1) {
113
- e_1 = {
114
- error: e_1_1
115
- };
116
- } finally {
117
- try {
118
- if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
119
- } finally {
120
- if (e_1) throw e_1.error;
111
+ if (a[item] > max) {
112
+ max = a[item];
113
+ res = item;
121
114
  }
122
115
  }
123
116
  return {
@@ -134,12 +127,14 @@ exports.SensorDataFilter = SensorDataFilter;
134
127
  * @param {string} str - the input string to be split
135
128
  * @return {string[]} an array of substrings
136
129
  */
137
- var StringSplit = /** @class */function () {
130
+ var StringSplit = /*#__PURE__*/function () {
138
131
  function StringSplit(splitSymbol) {
132
+ this._splitSymbol = void 0;
139
133
  this._cache = '';
140
134
  this._splitSymbol = splitSymbol;
141
135
  }
142
- StringSplit.prototype.split = function (str) {
136
+ var _proto2 = StringSplit.prototype;
137
+ _proto2.split = function split(str) {
143
138
  var tmp = this._cache + str;
144
139
  var arr = tmp.split(this._splitSymbol);
145
140
  this._cache = arr.splice(arr.length - 1, 1)[0];
@@ -4,12 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Level = void 0;
7
- var Level = /** @class */function () {
7
+ var Level = /*#__PURE__*/function () {
8
8
  function Level(props) {
9
+ this.config = void 0;
10
+ this.step = void 0;
9
11
  this.config = props;
10
12
  this.step = (this.config.max - this.config.min) / (this.config.count - 2);
11
13
  }
12
- Level.prototype.get = function (value) {
14
+ var _proto = Level.prototype;
15
+ _proto.get = function get(value) {
13
16
  if (value <= this.config.min) {
14
17
  return 1;
15
18
  }
@@ -5,7 +5,7 @@
5
5
  * @param {number} time - The time interval in milliseconds for the loop.
6
6
  * @return {Function} The stop function that can be used to stop the loop.
7
7
  */
8
- export declare const loop: (cb: (stop: () => void) => Promise<void>, time: number) => () => void;
8
+ export declare const loop: (cb: () => Promise<void>, time: number) => () => void;
9
9
  type WaitForBool = () => boolean | Promise<boolean>;
10
10
  /**
11
11
  * Waits for a boolean condition to be true, with optional timeouts for the check and the overall wait.
package/lib/loop/index.js CHANGED
@@ -1,120 +1,55 @@
1
1
  "use strict";
2
2
 
3
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) {
5
- return value instanceof P ? value : new P(function (resolve) {
6
- resolve(value);
7
- });
3
+ function _empty() {}
4
+ function _call(body, then, direct) {
5
+ if (direct) {
6
+ return then ? then(body()) : body();
8
7
  }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) {
11
- try {
12
- step(generator.next(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- }
17
- function rejected(value) {
18
- try {
19
- step(generator["throw"](value));
20
- } catch (e) {
21
- reject(e);
22
- }
23
- }
24
- function step(result) {
25
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
26
- }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
- var __generator = this && this.__generator || function (thisArg, body) {
31
- var _ = {
32
- label: 0,
33
- sent: function sent() {
34
- if (t[0] & 1) throw t[1];
35
- return t[1];
36
- },
37
- trys: [],
38
- ops: []
39
- },
40
- f,
41
- y,
42
- t,
43
- g;
44
- return g = {
45
- next: verb(0),
46
- "throw": verb(1),
47
- "return": verb(2)
48
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
49
- return this;
50
- }), g;
51
- function verb(n) {
52
- return function (v) {
53
- return step([n, v]);
54
- };
8
+ try {
9
+ var result = Promise.resolve(body());
10
+ return then ? result.then(then) : result;
11
+ } catch (e) {
12
+ return Promise.reject(e);
13
+ }
14
+ }
15
+ function _callIgnored(body, direct) {
16
+ return _call(body, _empty, direct);
17
+ }
18
+ function _catch(body, recover) {
19
+ try {
20
+ var result = body();
21
+ } catch (e) {
22
+ return recover(e);
23
+ }
24
+ if (result && result.then) {
25
+ return result.then(void 0, recover);
26
+ }
27
+ return result;
28
+ }
29
+ function _await(value, then, direct) {
30
+ if (direct) {
31
+ return then ? then(value) : value;
55
32
  }
56
- function step(op) {
57
- if (f) throw new TypeError("Generator is already executing.");
58
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
59
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
60
- if (y = 0, t) op = [op[0] & 2, t.value];
61
- switch (op[0]) {
62
- case 0:
63
- case 1:
64
- t = op;
65
- break;
66
- case 4:
67
- _.label++;
68
- return {
69
- value: op[1],
70
- done: false
71
- };
72
- case 5:
73
- _.label++;
74
- y = op[1];
75
- op = [0];
76
- continue;
77
- case 7:
78
- op = _.ops.pop();
79
- _.trys.pop();
80
- continue;
81
- default:
82
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
83
- _ = 0;
84
- continue;
85
- }
86
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
87
- _.label = op[1];
88
- break;
89
- }
90
- if (op[0] === 6 && _.label < t[1]) {
91
- _.label = t[1];
92
- t = op;
93
- break;
94
- }
95
- if (t && _.label < t[2]) {
96
- _.label = t[2];
97
- _.ops.push(op);
98
- break;
99
- }
100
- if (t[2]) _.ops.pop();
101
- _.trys.pop();
102
- continue;
103
- }
104
- op = body.call(thisArg, _);
33
+ if (!value || !value.then) {
34
+ value = Promise.resolve(value);
35
+ }
36
+ return then ? value.then(then) : value;
37
+ }
38
+ function _continue(value, then) {
39
+ return value && value.then ? value.then(then) : then(value);
40
+ }
41
+ function _async(f) {
42
+ return function () {
43
+ for (var args = [], i = 0; i < arguments.length; i++) {
44
+ args[i] = arguments[i];
45
+ }
46
+ try {
47
+ return Promise.resolve(f.apply(this, args));
105
48
  } catch (e) {
106
- op = [6, e];
107
- y = 0;
108
- } finally {
109
- f = t = 0;
49
+ return Promise.reject(e);
110
50
  }
111
- if (op[0] & 5) throw op[1];
112
- return {
113
- value: op[0] ? op[1] : void 0,
114
- done: true
115
- };
116
- }
117
- };
51
+ };
52
+ }
118
53
  Object.defineProperty(exports, "__esModule", {
119
54
  value: true
120
55
  });
@@ -132,29 +67,26 @@ var loop = function loop(cb, time) {
132
67
  var stop = function stop() {
133
68
  onOff = false;
134
69
  };
135
- var _fn = function fn() {
136
- return __awaiter(void 0, void 0, void 0, function () {
137
- return __generator(this, function (_a) {
138
- switch (_a.label) {
139
- case 0:
140
- return [4 /*yield*/, cb(stop)];
141
- case 1:
142
- _a.sent();
143
- return [4 /*yield*/, (0, sleep_1.sleep)(time)];
144
- case 2:
145
- _a.sent();
146
- if (onOff) {
147
- _fn();
148
- } else {
149
- _fn = null;
150
- }
151
- return [2 /*return*/];
70
+ var fn = _async(function () {
71
+ return _continue(_catch(function () {
72
+ return _callIgnored(cb);
73
+ }, function (err) {
74
+ console.log(err);
75
+ }), function () {
76
+ return _await((0, sleep_1.sleep)(time), function () {
77
+ if (onOff) {
78
+ fn();
79
+ } else {
80
+ fn = null;
81
+ cb = null;
82
+ stop = null;
83
+ onOff = null;
84
+ time = null;
152
85
  }
153
86
  });
154
87
  });
155
- };
156
-
157
- _fn();
88
+ });
89
+ fn();
158
90
  return stop;
159
91
  };
160
92
  exports.loop = loop;
@@ -167,33 +99,29 @@ exports.loop = loop;
167
99
  * @param {number} options.timeout - the maximum time to wait for the boolean condition to be true
168
100
  * @return {Promise<any>} a promise that resolves when the boolean condition is true or rejects with 'timeout' if the timeout is reached
169
101
  */
170
- var waitFor = function waitFor(bool, _a) {
171
- var _b = _a === void 0 ? {} : _a,
172
- checkTime = _b.checkTime,
173
- timeout = _b.timeout;
102
+ var waitFor = function waitFor(bool, _temp) {
103
+ var _ref = _temp === void 0 ? {} : _temp,
104
+ checkTime = _ref.checkTime,
105
+ timeout = _ref.timeout;
174
106
  return new Promise(function (resolve, reject) {
175
107
  var stop = (0, exports.loop)(function () {
176
- return __awaiter(void 0, void 0, void 0, function () {
177
- var res;
178
- return __generator(this, function (_a) {
179
- switch (_a.label) {
180
- case 0:
181
- return [4 /*yield*/, bool()];
182
- case 1:
183
- res = _a.sent();
184
- if (res) {
185
- stop();
186
- resolve(res);
187
- }
188
- return [2 /*return*/];
189
- }
190
- });
108
+ return _call(bool, function (res) {
109
+ if (res) {
110
+ stop();
111
+ stop = null;
112
+ bool = null;
113
+ resolve(res);
114
+ resolve = null;
115
+ }
191
116
  });
192
117
  }, checkTime || 100);
193
118
  if (timeout) {
194
119
  setTimeout(function () {
195
120
  stop();
121
+ stop = null;
122
+ bool = null;
196
123
  reject('timeout');
124
+ reject = null;
197
125
  }, timeout);
198
126
  }
199
127
  });
@@ -1,62 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var __assign = this && this.__assign || function () {
4
- __assign = Object.assign || function (t) {
5
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6
- s = arguments[i];
7
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __values = this && this.__values || function (o) {
14
- var s = typeof Symbol === "function" && Symbol.iterator,
15
- m = s && o[s],
16
- i = 0;
17
- if (m) return m.call(o);
18
- if (o && typeof o.length === "number") return {
19
- next: function next() {
20
- if (o && i >= o.length) o = void 0;
21
- return {
22
- value: o && o[i++],
23
- done: !o
24
- };
25
- }
26
- };
27
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
28
- };
29
- var __read = this && this.__read || function (o, n) {
30
- var m = typeof Symbol === "function" && o[Symbol.iterator];
31
- if (!m) return o;
32
- var i = m.call(o),
33
- r,
34
- ar = [],
35
- e;
36
- try {
37
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
38
- } catch (error) {
39
- e = {
40
- error: error
41
- };
42
- } finally {
43
- try {
44
- if (r && !r.done && (m = i["return"])) m.call(i);
45
- } finally {
46
- if (e) throw e.error;
47
- }
48
- }
49
- return ar;
50
- };
51
- var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
52
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
53
- if (ar || !(i in from)) {
54
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
55
- ar[i] = from[i];
56
- }
57
- }
58
- return to.concat(ar || Array.prototype.slice.call(from));
59
- };
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
60
7
  Object.defineProperty(exports, "__esModule", {
61
8
  value: true
62
9
  });
@@ -77,9 +24,9 @@ var radians = function radians(deg) {
77
24
  };
78
25
  exports.radians = radians;
79
26
  // 获取三角形角度
80
- var getAngle = function getAngle(_a) {
81
- var w = _a.w,
82
- h = _a.h;
27
+ var getAngle = function getAngle(_ref) {
28
+ var w = _ref.w,
29
+ h = _ref.h;
83
30
  return (0, exports.degrees)(Math.atan2(h, w));
84
31
  };
85
32
  exports.getAngle = getAngle;
@@ -103,28 +50,15 @@ function filterKeyPoints(list, len) {
103
50
  exports.filterKeyPoints = filterKeyPoints;
104
51
  // 获取中心点坐标
105
52
  function getCenter(list) {
106
- var e_1, _a;
107
53
  var tmp = [0, 0];
108
- try {
109
- for (var list_1 = __values(list), list_1_1 = list_1.next(); !list_1_1.done; list_1_1 = list_1.next()) {
110
- var item = list_1_1.value;
111
- if (Array.isArray(item)) {
112
- tmp[0] += item[0];
113
- tmp[1] += item[1];
114
- } else {
115
- tmp[0] += item.x;
116
- tmp[1] += item.y;
117
- }
118
- }
119
- } catch (e_1_1) {
120
- e_1 = {
121
- error: e_1_1
122
- };
123
- } finally {
124
- try {
125
- if (list_1_1 && !list_1_1.done && (_a = list_1["return"])) _a.call(list_1);
126
- } finally {
127
- if (e_1) throw e_1.error;
54
+ for (var _iterator = _createForOfIteratorHelperLoose(list), _step; !(_step = _iterator()).done;) {
55
+ var item = _step.value;
56
+ if (Array.isArray(item)) {
57
+ tmp[0] += item[0];
58
+ tmp[1] += item[1];
59
+ } else {
60
+ tmp[0] += item.x;
61
+ tmp[1] += item.y;
128
62
  }
129
63
  }
130
64
  return {
@@ -151,38 +85,25 @@ var getPositionTheta = function getPositionTheta(a, b) {
151
85
  exports.getPositionTheta = getPositionTheta;
152
86
  // 获取距离和方向最佳的位置点
153
87
  var getBestPointIndex = function getBestPointIndex(points, pose) {
154
- var e_2, _a;
155
88
  if (points.length < 2) {
156
89
  return 0;
157
90
  }
158
91
  var temp = [];
159
92
  var minDistance = Infinity;
160
93
  var index = 0;
161
- try {
162
- for (var points_1 = __values(points), points_1_1 = points_1.next(); !points_1_1.done; points_1_1 = points_1.next()) {
163
- var item = points_1_1.value;
164
- var distance = (0, exports.getDistance)(item, pose);
165
- var theta = (0, exports.getPositionTheta)(pose, item) - pose.theta;
166
- if (minDistance > distance) {
167
- minDistance = distance;
168
- }
169
- temp.push(__assign(__assign({}, item), {
170
- index: index,
171
- distance: distance,
172
- theta: theta
173
- }));
174
- index += 1;
175
- }
176
- } catch (e_2_1) {
177
- e_2 = {
178
- error: e_2_1
179
- };
180
- } finally {
181
- try {
182
- if (points_1_1 && !points_1_1.done && (_a = points_1["return"])) _a.call(points_1);
183
- } finally {
184
- if (e_2) throw e_2.error;
94
+ for (var _iterator2 = _createForOfIteratorHelperLoose(points), _step2; !(_step2 = _iterator2()).done;) {
95
+ var item = _step2.value;
96
+ var distance = (0, exports.getDistance)(item, pose);
97
+ var theta = (0, exports.getPositionTheta)(pose, item) - pose.theta;
98
+ if (minDistance > distance) {
99
+ minDistance = distance;
185
100
  }
101
+ temp.push(_extends({}, item, {
102
+ index: index,
103
+ distance: distance,
104
+ theta: theta
105
+ }));
106
+ index += 1;
186
107
  }
187
108
  var results = temp.filter(function (item) {
188
109
  return item.distance - minDistance < 0.1;
@@ -203,7 +124,7 @@ var orderByDistance = function orderByDistance(points, pose) {
203
124
  }
204
125
  var current = pose;
205
126
  var results = [];
206
- var arr = __spreadArray([], __read(points), false);
127
+ var arr = [].concat(points);
207
128
  while (arr.length > 0) {
208
129
  var index = (0, exports.getBestPointIndex)(arr, current);
209
130
  results.push(arr[index]);