@colyseus/schema 2.0.17 → 2.0.19

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.
@@ -395,6 +395,13 @@ function getArrayProxy(value) {
395
395
  }
396
396
  return true;
397
397
  },
398
+ has: function (obj, key) {
399
+ if (typeof (key) !== "symbol" &&
400
+ !isNaN(Number(key))) {
401
+ return obj['$items'].has(Number(key));
402
+ }
403
+ return Reflect.has(obj, key);
404
+ }
398
405
  });
399
406
  return value;
400
407
  }
@@ -412,12 +419,12 @@ var ArraySchema = /** @class */ (function () {
412
419
  }
413
420
  ArraySchema.prototype.onAdd = function (callback, triggerAll) {
414
421
  if (triggerAll === void 0) { triggerAll = true; }
415
- return addCallback((this.$callbacks || (this.$callbacks = [])), exports.OPERATION.ADD, callback, (triggerAll)
422
+ return addCallback((this.$callbacks || (this.$callbacks = {})), exports.OPERATION.ADD, callback, (triggerAll)
416
423
  ? this.$items
417
424
  : undefined);
418
425
  };
419
- ArraySchema.prototype.onRemove = function (callback) { return addCallback(this.$callbacks || (this.$callbacks = []), exports.OPERATION.DELETE, callback); };
420
- ArraySchema.prototype.onChange = function (callback) { return addCallback(this.$callbacks || (this.$callbacks = []), exports.OPERATION.REPLACE, callback); };
426
+ ArraySchema.prototype.onRemove = function (callback) { return addCallback(this.$callbacks || (this.$callbacks = {}), exports.OPERATION.DELETE, callback); };
427
+ ArraySchema.prototype.onChange = function (callback) { return addCallback(this.$callbacks || (this.$callbacks = {}), exports.OPERATION.REPLACE, callback); };
421
428
  ArraySchema.is = function (type) {
422
429
  return (
423
430
  // type format: ["string"]
@@ -939,12 +946,12 @@ var MapSchema = /** @class */ (function () {
939
946
  }
940
947
  MapSchema.prototype.onAdd = function (callback, triggerAll) {
941
948
  if (triggerAll === void 0) { triggerAll = true; }
942
- return addCallback((this.$callbacks || (this.$callbacks = [])), exports.OPERATION.ADD, callback, (triggerAll)
949
+ return addCallback((this.$callbacks || (this.$callbacks = {})), exports.OPERATION.ADD, callback, (triggerAll)
943
950
  ? this.$items
944
951
  : undefined);
945
952
  };
946
- MapSchema.prototype.onRemove = function (callback) { return addCallback(this.$callbacks || (this.$callbacks = []), exports.OPERATION.DELETE, callback); };
947
- MapSchema.prototype.onChange = function (callback) { return addCallback(this.$callbacks || (this.$callbacks = []), exports.OPERATION.REPLACE, callback); };
953
+ MapSchema.prototype.onRemove = function (callback) { return addCallback(this.$callbacks || (this.$callbacks = {}), exports.OPERATION.DELETE, callback); };
954
+ MapSchema.prototype.onChange = function (callback) { return addCallback(this.$callbacks || (this.$callbacks = {}), exports.OPERATION.REPLACE, callback); };
948
955
  MapSchema.is = function (type) {
949
956
  return type['map'] !== undefined;
950
957
  };
@@ -2434,10 +2441,10 @@ var Schema = /** @class */ (function () {
2434
2441
  type['_definition'].schema !== undefined);
2435
2442
  };
2436
2443
  Schema.prototype.onChange = function (callback) {
2437
- return addCallback((this.$callbacks || (this.$callbacks = [])), exports.OPERATION.REPLACE, callback);
2444
+ return addCallback((this.$callbacks || (this.$callbacks = {})), exports.OPERATION.REPLACE, callback);
2438
2445
  };
2439
2446
  Schema.prototype.onRemove = function (callback) {
2440
- return addCallback((this.$callbacks || (this.$callbacks = [])), exports.OPERATION.DELETE, callback);
2447
+ return addCallback((this.$callbacks || (this.$callbacks = {})), exports.OPERATION.DELETE, callback);
2441
2448
  };
2442
2449
  Schema.prototype.assign = function (props) {
2443
2450
  Object.assign(this, props);