amos-tool
Version:
amos ui tool
76 lines (74 loc) • 2.64 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")), List = {
ArrayList: function() {
var t = new Array, e = 0;
this.size = function() {
return e;
}, this.values = function() {
return t;
}, this.isEmpty = function() {
return e <= 0;
}, this.iterator = function(r) {
for (var n = 0; n < e; n++) {
if (0 == r.call(null, t[n], n)) return;
}
}, this.get = function(r) {
if (r >= e) throw "IndexOutOfBoundsException";
return t[r];
}, this.add = function(r) {
t[e] = r, e++;
}, this.addAll = function(t) {
for (var e = t.size(), r = 0; r < e; r++) this.add(t.get(r));
}, this.set = function(r, n) {
if (r >= e || r < 0) throw "IndexOutOfBoundsException";
t[r] = n;
}, this.remove = function(t) {
var e = this.indexOf(t);
e > -1 && this.removeAt(e);
}, this.removeAt = function(r) {
if (r >= e || r < 0) throw "argument out of range. index=" + r;
for (var n = e - 1, i = r; i < n; i++) t[i] = t[i + 1];
delete t[n], e--;
}, this.indexOf = function(r) {
if (null == r) return -1;
if (List.isObject(r)) {
for (var n = 0; n < e; n++) if (List.simpleEqual(r, t[n])) return n;
} else for (var i = 0; i < e; i++) if (r == t[i]) return i;
return -1;
}, this.clear = function() {
t = new Array, e = 0;
}, this.insert = function(r, n) {
if (r >= e || r < 0) this.add(n); else {
for (var i = e - 1; i > r; i--) t[i + 1] = t[i];
t[r] = n;
}
e++;
}, this.updateValue = function(r, n) {
e <= 0 ? (t[e] = n, e++) : t.forEach(function(i, u) {
if (i[r] !== n[r]) ; else {
if (u >= e || u < 0) throw "IndexOutOfBoundsException";
t[u] = n;
}
});
};
},
parse2string: function(t) {
return JSON.stringify(t);
},
parse2object: function(str) {
return eval("(" + str + ")");
},
simpleEqual: function(t, e) {
if (t === e) return !0;
if ("object" !== (0, _typeof2.default)(t) || null === t || "object" !== (0, _typeof2.default)(e) || null === e) return !1;
var r = Object.keys(t), n = Object.keys(e);
if (r.length !== n.length) return !1;
for (var i = hasOwnProperty.bind(e), u = 0; u < r.length; u++) if (!i(r[u]) || t[r[u]] !== e[r[u]]) return !1;
return !0;
},
isObject: function(t) {
var e = (0, _typeof2.default)(t);
return "function" === e || "object" === e && !!t;
}
};
module.exports = List;