@fluidframework/common-utils
Advanced tools
Comparing version 0.28.0 to 0.29.0-19979
@@ -9,5 +9,6 @@ /*! | ||
* @param condition - The condition that should be true, if the condition is false an error will be thrown. | ||
* @param message - The message to include in the error when the condition does not hold | ||
* @param message - The message to include in the error when the condition does not hold. | ||
* A number should not be specificed manually. Run policy-check to get shortcode number assigned. | ||
*/ | ||
export declare function assert(condition: boolean, message?: string): asserts condition; | ||
export declare function assert(condition: boolean, message: string | number): asserts condition; | ||
//# sourceMappingURL=assert.d.ts.map |
@@ -12,7 +12,8 @@ "use strict"; | ||
* @param condition - The condition that should be true, if the condition is false an error will be thrown. | ||
* @param message - The message to include in the error when the condition does not hold | ||
* @param message - The message to include in the error when the condition does not hold. | ||
* A number should not be specificed manually. Run policy-check to get shortcode number assigned. | ||
*/ | ||
function assert(condition, message) { | ||
if (!condition) { | ||
throw new Error(message); | ||
throw new Error(typeof message === "number" ? message.toString(16) : message); | ||
} | ||
@@ -19,0 +20,0 @@ } |
@@ -114,4 +114,4 @@ "use strict"; | ||
// Support currently for full array, no view ports! (though it can be added in future) | ||
assert_1.assert(value.byteOffset === 0); | ||
assert_1.assert(value.byteLength === value.buffer.byteLength); | ||
assert_1.assert(value.byteOffset === 0, "nonzero isobuffer byte offset"); | ||
assert_1.assert(value.byteLength === value.buffer.byteLength, "unexpected isobuffer byte length"); | ||
return IsoBuffer.fromArrayBuffer(value.buffer, encodingOrOffset, length); | ||
@@ -118,0 +118,0 @@ } |
@@ -34,3 +34,3 @@ "use strict"; | ||
if (insecureContextHashFn !== undefined) { | ||
assert_1.assert(crypto.subtle === undefined); | ||
assert_1.assert(crypto.subtle === undefined, "Both crypto.subtle and insecureContextHashFn are defined!"); | ||
return insecureContextHashFn(file); | ||
@@ -37,0 +37,0 @@ } |
@@ -8,3 +8,3 @@ /*! | ||
export declare const pkgName = "@fluidframework/common-utils"; | ||
export declare const pkgVersion = "0.28.0"; | ||
export declare const pkgVersion = "0.29.0-19979"; | ||
//# sourceMappingURL=packageVersion.d.ts.map |
@@ -11,3 +11,3 @@ "use strict"; | ||
exports.pkgName = "@fluidframework/common-utils"; | ||
exports.pkgVersion = "0.28.0"; | ||
exports.pkgVersion = "0.29.0-19979"; | ||
//# sourceMappingURL=packageVersion.js.map |
@@ -72,5 +72,5 @@ "use strict"; | ||
// below to check invariants | ||
assert_1.assert(primary >= this.lastPrimary); | ||
assert_1.assert(primary >= this.lastPrimary, "Primary to add to range < last primary!"); | ||
if (this.lastSecondary !== undefined) { | ||
assert_1.assert(secondary >= this.lastSecondary); | ||
assert_1.assert(secondary >= this.lastSecondary, "Secondary to add to range < last secondary!"); | ||
} | ||
@@ -119,3 +119,3 @@ this.lastPrimary = primary; | ||
get(primary) { | ||
assert_1.assert(primary >= this.ranges[0].primary); | ||
assert_1.assert(primary >= this.ranges[0].primary, "Target primary to retrieve < first range's primary!"); | ||
// Find the first range where the starting position is greater than the primary. Our target range is | ||
@@ -129,3 +129,3 @@ // the one before it. | ||
} | ||
assert_1.assert(primary >= this.ranges[index - 1].primary); | ||
assert_1.assert(primary >= this.ranges[index - 1].primary, "Target primary to retrieve < last range's primary!"); | ||
// If the difference is within the stored range use it - otherwise add in the length - 1 as the highest | ||
@@ -142,3 +142,3 @@ // stored secondary value to use. | ||
updateBase(primary) { | ||
assert_1.assert(primary >= this.ranges[0].primary); | ||
assert_1.assert(primary >= this.ranges[0].primary, "Target primary to update < first range's primary!"); | ||
// Walk the ranges looking for the first one that is greater than the primary. Primary is then within the | ||
@@ -153,3 +153,3 @@ // previous index by definition (since it's less than the current index's primary but greather than the | ||
} | ||
assert_1.assert(primary >= this.ranges[index - 1].primary); | ||
assert_1.assert(primary >= this.ranges[index - 1].primary, "Target primary to update < last range's primary!"); | ||
// Update the last range values | ||
@@ -164,3 +164,3 @@ const range = this.ranges[index - 1]; | ||
// Assert that the lowest value is now the input to this method | ||
assert_1.assert(primary === this.ranges[0].primary); | ||
assert_1.assert(primary === this.ranges[0].primary, "After update, target primary is not first range's primary!"); | ||
} | ||
@@ -167,0 +167,0 @@ } |
@@ -9,5 +9,6 @@ /*! | ||
* @param condition - The condition that should be true, if the condition is false an error will be thrown. | ||
* @param message - The message to include in the error when the condition does not hold | ||
* @param message - The message to include in the error when the condition does not hold. | ||
* A number should not be specificed manually. Run policy-check to get shortcode number assigned. | ||
*/ | ||
export declare function assert(condition: boolean, message?: string): asserts condition; | ||
export declare function assert(condition: boolean, message: string | number): asserts condition; | ||
//# sourceMappingURL=assert.d.ts.map |
@@ -9,9 +9,10 @@ /*! | ||
* @param condition - The condition that should be true, if the condition is false an error will be thrown. | ||
* @param message - The message to include in the error when the condition does not hold | ||
* @param message - The message to include in the error when the condition does not hold. | ||
* A number should not be specificed manually. Run policy-check to get shortcode number assigned. | ||
*/ | ||
export function assert(condition, message) { | ||
if (!condition) { | ||
throw new Error(message); | ||
throw new Error(typeof message === "number" ? message.toString(16) : message); | ||
} | ||
} | ||
//# sourceMappingURL=assert.js.map |
@@ -88,4 +88,4 @@ /*! | ||
// Support currently for full array, no view ports! (though it can be added in future) | ||
assert(value.byteOffset === 0); | ||
assert(value.byteLength === value.buffer.byteLength); | ||
assert(value.byteOffset === 0, "nonzero isobuffer byte offset"); | ||
assert(value.byteLength === value.buffer.byteLength, "unexpected isobuffer byte length"); | ||
return IsoBuffer.fromArrayBuffer(value.buffer, encodingOrOffset, length); | ||
@@ -92,0 +92,0 @@ } |
@@ -30,3 +30,3 @@ /*! | ||
if (insecureContextHashFn !== undefined) { | ||
assert(crypto.subtle === undefined); | ||
assert(crypto.subtle === undefined, "Both crypto.subtle and insecureContextHashFn are defined!"); | ||
return insecureContextHashFn(file); | ||
@@ -33,0 +33,0 @@ } |
@@ -8,3 +8,3 @@ /*! | ||
export declare const pkgName = "@fluidframework/common-utils"; | ||
export declare const pkgVersion = "0.28.0"; | ||
export declare const pkgVersion = "0.29.0-19979"; | ||
//# sourceMappingURL=packageVersion.d.ts.map |
@@ -8,3 +8,3 @@ /*! | ||
export const pkgName = "@fluidframework/common-utils"; | ||
export const pkgVersion = "0.28.0"; | ||
export const pkgVersion = "0.29.0-19979"; | ||
//# sourceMappingURL=packageVersion.js.map |
@@ -66,5 +66,5 @@ /*! | ||
// below to check invariants | ||
assert(primary >= this.lastPrimary); | ||
assert(primary >= this.lastPrimary, "Primary to add to range < last primary!"); | ||
if (this.lastSecondary !== undefined) { | ||
assert(secondary >= this.lastSecondary); | ||
assert(secondary >= this.lastSecondary, "Secondary to add to range < last secondary!"); | ||
} | ||
@@ -113,3 +113,3 @@ this.lastPrimary = primary; | ||
get(primary) { | ||
assert(primary >= this.ranges[0].primary); | ||
assert(primary >= this.ranges[0].primary, "Target primary to retrieve < first range's primary!"); | ||
// Find the first range where the starting position is greater than the primary. Our target range is | ||
@@ -123,3 +123,3 @@ // the one before it. | ||
} | ||
assert(primary >= this.ranges[index - 1].primary); | ||
assert(primary >= this.ranges[index - 1].primary, "Target primary to retrieve < last range's primary!"); | ||
// If the difference is within the stored range use it - otherwise add in the length - 1 as the highest | ||
@@ -136,3 +136,3 @@ // stored secondary value to use. | ||
updateBase(primary) { | ||
assert(primary >= this.ranges[0].primary); | ||
assert(primary >= this.ranges[0].primary, "Target primary to update < first range's primary!"); | ||
// Walk the ranges looking for the first one that is greater than the primary. Primary is then within the | ||
@@ -147,3 +147,3 @@ // previous index by definition (since it's less than the current index's primary but greather than the | ||
} | ||
assert(primary >= this.ranges[index - 1].primary); | ||
assert(primary >= this.ranges[index - 1].primary, "Target primary to update < last range's primary!"); | ||
// Update the last range values | ||
@@ -158,5 +158,5 @@ const range = this.ranges[index - 1]; | ||
// Assert that the lowest value is now the input to this method | ||
assert(primary === this.ranges[0].primary); | ||
assert(primary === this.ranges[0].primary, "After update, target primary is not first range's primary!"); | ||
} | ||
} | ||
//# sourceMappingURL=rangeTracker.js.map |
{ | ||
"name": "@fluidframework/common-utils", | ||
"version": "0.28.0", | ||
"version": "0.29.0-19979", | ||
"description": "Collection of utility functions for Fluid", | ||
@@ -5,0 +5,0 @@ "homepage": "https://fluidframework.com", |
@@ -10,8 +10,9 @@ /*! | ||
* @param condition - The condition that should be true, if the condition is false an error will be thrown. | ||
* @param message - The message to include in the error when the condition does not hold | ||
* @param message - The message to include in the error when the condition does not hold. | ||
* A number should not be specificed manually. Run policy-check to get shortcode number assigned. | ||
*/ | ||
export function assert(condition: boolean, message?: string): asserts condition { | ||
export function assert(condition: boolean, message: string | number): asserts condition { | ||
if (!condition) { | ||
throw new Error(message); | ||
throw new Error(typeof message === "number" ? message.toString(16) : message); | ||
} | ||
} |
@@ -96,4 +96,4 @@ /*! | ||
// Support currently for full array, no view ports! (though it can be added in future) | ||
assert(value.byteOffset === 0); | ||
assert(value.byteLength === value.buffer.byteLength); | ||
assert(value.byteOffset === 0, "nonzero isobuffer byte offset"); | ||
assert(value.byteLength === value.buffer.byteLength, "unexpected isobuffer byte length"); | ||
return IsoBuffer.fromArrayBuffer(value.buffer, encodingOrOffset as number | undefined, length); | ||
@@ -100,0 +100,0 @@ } else if (isArrayBuffer(value)) { |
@@ -34,3 +34,3 @@ /*! | ||
if (insecureContextHashFn !== undefined) { | ||
assert(crypto.subtle === undefined); | ||
assert(crypto.subtle === undefined, "Both crypto.subtle and insecureContextHashFn are defined!"); | ||
return insecureContextHashFn(file); | ||
@@ -37,0 +37,0 @@ } |
@@ -9,2 +9,2 @@ /*! | ||
export const pkgName = "@fluidframework/common-utils"; | ||
export const pkgVersion = "0.28.0"; | ||
export const pkgVersion = "0.29.0-19979"; |
@@ -96,5 +96,5 @@ /*! | ||
// below to check invariants | ||
assert(primary >= this.lastPrimary); | ||
assert(primary >= this.lastPrimary, "Primary to add to range < last primary!"); | ||
if (this.lastSecondary !== undefined) { | ||
assert(secondary >= this.lastSecondary); | ||
assert(secondary >= this.lastSecondary, "Secondary to add to range < last secondary!"); | ||
} | ||
@@ -144,3 +144,3 @@ this.lastPrimary = primary; | ||
public get(primary: number): number { | ||
assert(primary >= this.ranges[0].primary); | ||
assert(primary >= this.ranges[0].primary, "Target primary to retrieve < first range's primary!"); | ||
@@ -155,3 +155,3 @@ // Find the first range where the starting position is greater than the primary. Our target range is | ||
} | ||
assert(primary >= this.ranges[index - 1].primary); | ||
assert(primary >= this.ranges[index - 1].primary, "Target primary to retrieve < last range's primary!"); | ||
@@ -170,3 +170,3 @@ // If the difference is within the stored range use it - otherwise add in the length - 1 as the highest | ||
public updateBase(primary: number) { | ||
assert(primary >= this.ranges[0].primary); | ||
assert(primary >= this.ranges[0].primary, "Target primary to update < first range's primary!"); | ||
@@ -182,3 +182,3 @@ // Walk the ranges looking for the first one that is greater than the primary. Primary is then within the | ||
} | ||
assert(primary >= this.ranges[index - 1].primary); | ||
assert(primary >= this.ranges[index - 1].primary, "Target primary to update < last range's primary!"); | ||
@@ -196,4 +196,4 @@ // Update the last range values | ||
// Assert that the lowest value is now the input to this method | ||
assert(primary === this.ranges[0].primary); | ||
assert(primary === this.ranges[0].primary, "After update, target primary is not first range's primary!"); | ||
} | ||
} |
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
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
464666
6450