@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.
- package/build/cjs/index.js +15 -8
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +15 -8
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +15 -8
- package/lib/Schema.js +2 -2
- package/lib/Schema.js.map +1 -1
- package/lib/types/ArraySchema.js +10 -3
- package/lib/types/ArraySchema.js.map +1 -1
- package/lib/types/MapSchema.js +3 -3
- package/lib/types/MapSchema.js.map +1 -1
- package/package.json +1 -1
- package/src/Schema.ts +2 -2
- package/src/types/ArraySchema.ts +13 -3
- package/src/types/MapSchema.ts +3 -3
- package/lib/events/EventEmitter.d.ts +0 -13
- package/lib/events/EventEmitter.js +0 -31
- package/lib/events/EventEmitter.js.map +0 -1
- package/lib/types/index.d.ts +0 -6
- package/lib/types/index.js +0 -13
- package/lib/types/index.js.map +0 -1
package/build/cjs/index.js
CHANGED
|
@@ -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 =
|
|
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 =
|
|
420
|
-
ArraySchema.prototype.onChange = function (callback) { return addCallback(this.$callbacks || (this.$callbacks =
|
|
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 =
|
|
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 =
|
|
947
|
-
MapSchema.prototype.onChange = function (callback) { return addCallback(this.$callbacks || (this.$callbacks =
|
|
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 =
|
|
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 =
|
|
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);
|