@fluidframework/protocol-base
Advanced tools
Comparing version
@@ -15,2 +15,12 @@ "use strict"; | ||
/** | ||
* Throws if condition is false. | ||
* @privateRemarks | ||
* TODO: Migrate this to a common assert pattern or library for server code. | ||
*/ | ||
function assert(condition, message) { | ||
if (!condition) { | ||
throw new Error(message); | ||
} | ||
} | ||
/** | ||
* Structure for tracking proposals that have been sequenced but not approved yet. | ||
@@ -52,4 +62,4 @@ */ | ||
addMember(clientId, details) { | ||
(0, common_utils_1.assert)(!!clientId, 0x46f /* clientId has to be non-empty string */); | ||
(0, common_utils_1.assert)(!this.members.has(clientId), 0x1ce /* clientId not found */); | ||
assert(!!clientId, "clientId has to be non-empty string"); | ||
assert(!this.members.has(clientId), "clientId not found"); | ||
this.members.set(clientId, details); | ||
@@ -64,4 +74,4 @@ this.emit("addMember", clientId, details); | ||
removeMember(clientId) { | ||
(0, common_utils_1.assert)(!!clientId, 0x470 /* clientId has to be non-empty string */); | ||
(0, common_utils_1.assert)(this.members.has(clientId), 0x1cf /* clientId not found */); | ||
assert(!!clientId, "clientId has to be non-empty string"); | ||
assert(this.members.has(clientId), "clientId not found"); | ||
this.members.delete(clientId); | ||
@@ -222,3 +232,3 @@ this.emit("removeMember", clientId); | ||
addProposal(key, value, sequenceNumber, local, clientSequenceNumber) { | ||
(0, common_utils_1.assert)(!this.proposals.has(sequenceNumber), 0x1d0 /* sequenceNumber not found */); | ||
assert(!this.proposals.has(sequenceNumber), "sequenceNumber not found"); | ||
const proposal = new PendingProposal(sequenceNumber, key, value, local); | ||
@@ -225,0 +235,0 @@ this.proposals.set(sequenceNumber, proposal); |
@@ -7,4 +7,14 @@ /*! | ||
const { EventEmitter } = events_pkg; | ||
import { assert, TypedEventEmitter } from "@fluidframework/common-utils"; | ||
import { TypedEventEmitter } from "@fluidframework/common-utils"; | ||
/** | ||
* Throws if condition is false. | ||
* @privateRemarks | ||
* TODO: Migrate this to a common assert pattern or library for server code. | ||
*/ | ||
function assert(condition, message) { | ||
if (!condition) { | ||
throw new Error(message); | ||
} | ||
} | ||
/** | ||
* Structure for tracking proposals that have been sequenced but not approved yet. | ||
@@ -46,4 +56,4 @@ */ | ||
addMember(clientId, details) { | ||
assert(!!clientId, 0x46f /* clientId has to be non-empty string */); | ||
assert(!this.members.has(clientId), 0x1ce /* clientId not found */); | ||
assert(!!clientId, "clientId has to be non-empty string"); | ||
assert(!this.members.has(clientId), "clientId not found"); | ||
this.members.set(clientId, details); | ||
@@ -58,4 +68,4 @@ this.emit("addMember", clientId, details); | ||
removeMember(clientId) { | ||
assert(!!clientId, 0x470 /* clientId has to be non-empty string */); | ||
assert(this.members.has(clientId), 0x1cf /* clientId not found */); | ||
assert(!!clientId, "clientId has to be non-empty string"); | ||
assert(this.members.has(clientId), "clientId not found"); | ||
this.members.delete(clientId); | ||
@@ -215,3 +225,3 @@ this.emit("removeMember", clientId); | ||
addProposal(key, value, sequenceNumber, local, clientSequenceNumber) { | ||
assert(!this.proposals.has(sequenceNumber), 0x1d0 /* sequenceNumber not found */); | ||
assert(!this.proposals.has(sequenceNumber), "sequenceNumber not found"); | ||
const proposal = new PendingProposal(sequenceNumber, key, value, local); | ||
@@ -218,0 +228,0 @@ this.proposals.set(sequenceNumber, proposal); |
{ | ||
"name": "@fluidframework/protocol-base", | ||
"version": "6.0.0-314981", | ||
"version": "6.0.0-317195", | ||
"description": "Fluid protocol base", | ||
@@ -63,3 +63,3 @@ "homepage": "https://fluidframework.com", | ||
"@fluidframework/common-utils": "^3.1.0", | ||
"@fluidframework/gitresources": "6.0.0-314981", | ||
"@fluidframework/gitresources": "6.0.0-317195", | ||
"@fluidframework/protocol-definitions": "^3.2.0", | ||
@@ -66,0 +66,0 @@ "events_pkg": "npm:events@^3.1.0" |
@@ -9,3 +9,3 @@ /*! | ||
import { assert, TypedEventEmitter } from "@fluidframework/common-utils"; | ||
import { TypedEventEmitter } from "@fluidframework/common-utils"; | ||
import { | ||
@@ -22,2 +22,13 @@ ICommittedProposal, | ||
/** | ||
* Throws if condition is false. | ||
* @privateRemarks | ||
* TODO: Migrate this to a common assert pattern or library for server code. | ||
*/ | ||
function assert(condition: boolean, message: string): asserts condition { | ||
if (!condition) { | ||
throw new Error(message); | ||
} | ||
} | ||
/** | ||
* Structure for tracking proposals that have been sequenced but not approved yet. | ||
@@ -101,4 +112,4 @@ */ | ||
public addMember(clientId: string, details: ISequencedClient) { | ||
assert(!!clientId, 0x46f /* clientId has to be non-empty string */); | ||
assert(!this.members.has(clientId), 0x1ce /* clientId not found */); | ||
assert(!!clientId, "clientId has to be non-empty string"); | ||
assert(!this.members.has(clientId), "clientId not found"); | ||
this.members.set(clientId, details); | ||
@@ -115,4 +126,4 @@ this.emit("addMember", clientId, details); | ||
public removeMember(clientId: string) { | ||
assert(!!clientId, 0x470 /* clientId has to be non-empty string */); | ||
assert(this.members.has(clientId), 0x1cf /* clientId not found */); | ||
assert(!!clientId, "clientId has to be non-empty string"); | ||
assert(this.members.has(clientId), "clientId not found"); | ||
this.members.delete(clientId); | ||
@@ -326,3 +337,3 @@ this.emit("removeMember", clientId); | ||
) { | ||
assert(!this.proposals.has(sequenceNumber), 0x1d0 /* sequenceNumber not found */); | ||
assert(!this.proposals.has(sequenceNumber), "sequenceNumber not found"); | ||
@@ -329,0 +340,0 @@ const proposal = new PendingProposal(sequenceNumber, key, value, local); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
213778
0.5%2627
1.16%+ Added
- Removed