Util
Enumerations
Type Aliases
Functions
TypeAssert()
TypeAssertNever()
_timerStressTest()
copyMap()
copySet()
createCylinderMeshDataFromArc()
createOpenPromise()
createTrackedOpenPromise()
createUnsafePromise()
delayCall()
exchangeIdEqual()
filterInPlace()
generateConeCylinderMeshData()
generateSphereMeshData()
isCircleElement()
isFace()
isLineElement()
isOtherEdgeElement()
isPlaneElement()
setSubtraction()
setToArray()
sleep()
toSet()
waitForAll()
Functions
TypeAssert
-
Util.
TypeAssert
(_x) Arguments: - _x (
T()
) – None
This purpose of this function is guarantee a value is of a given type.
This is essentially a compile time
console.assert(x instanceof T)
.This function is useful when terminating a type-narrowing if-else chain in that this function makes the code more robust to future type changes.
—
Warning:
T=never
doesn’t appear to work properly, hence the existence ofTypeAssertNever
.—
Example:
declare const x: Foo | Bar; if (x instanceof Foo) { console.log("foo"); } else { // This becomes a compiler error if, for example, `x`'s type gets changed to add `Baz`: // x: Foo | Bar | Baz TypeAssert<Bar>(x); console.log("bar"); }
Return type: void - _x (
TypeAssertNever
-
Util.
TypeAssertNever
(_x) Arguments: - _x (
never()
) – None
See
TypeAssert
for details.This is useful for making the compiler enforce fully-covered switch statements.
This function unconditionally throws
InternalLogicError
.—
Example:
switch (x) { case Enum.A: break; case Enum.B: break; default: TypeAssertNever(x); // compiler complains if missing other enum cases }
Return type: never - _x (
copyMap
-
Util.
copyMap
(input) Arguments: - input (
Map
) – The Map to be copied
Performs a shallow copy of a Map.
Return type: Map <K, V> - input (
copySet
-
Util.
copySet
(input) Arguments: - input (
Set
) – The Map to be copied
Performs a shallow copy of a Set.
Return type: Set <T> - input (
createCylinderMeshDataFromArc
-
Util.
createCylinderMeshDataFromArc
(arc, axisDirection, numSegments, scale) Arguments: - arc (
[number]()
) – an array of numbers describing points on an arc that will be used to deform the cylinder - axisDirection (
Point3()
) – cylinder axis. - numSegments (
number()
) – the number of segments to use when constructing the cylinder. A higher number will give a smoother appearance but consume more memory. - scale (
number()
) – a scaling factor to apply to the geometry.
Creates a cylinder that is deformed by an arc. An example of the resulting geometry can be observed in the Handles implementation.
Return type: MeshData - arc (
createOpenPromise
-
Util.
createOpenPromise
() Creates a new
OpenPromise
that does not have its state resolved or rejected.Return type: OpenPromise <T>
createTrackedOpenPromise
-
Util.
createTrackedOpenPromise
() Creates a new
TrackedOpenPromise
that does not have its state resolved or rejected.Return type: TrackedOpenPromise <T>
createUnsafePromise
-
Util.
createUnsafePromise
(promisedValue, readyPromise) Arguments: - promisedValue (
T()
) – The value this promise resolves to. (Seethis.unsafeValue
.) - readyPromise (
Promise
) – The promise used forthis.readyPromise
. (See alsothis.isReady
.)
Creates a new
UnsafePromise
.Returns: A new UnsafePromise
.Return type: UnsafePromise <T> - promisedValue (
delayCall
-
Util.
delayCall
(cb, args) Arguments: - cb (
function()
) – the callback to call the promise to call on the next frame. - args (
[unknown]()
) – the arguments of the callback.
This function is an helper function that delay the call to a callback to the computation of the next ‘frame’ of the browser’s js engine. The point is to let the js engine deal with pending promises before running the given code.
Returns: a timeout id in order to cancel it if necessary. Return type: ReturnType <unknown> -
Util.
cb
(cbArgs) Arguments: - cbArgs (
[unknown]()
) – None
Return type: unknown
- cbArgs (
- cb (
exchangeIdEqual
-
Util.
exchangeIdEqual
(exchangeIdA, exchangeIdB) Arguments: - exchangeIdA (
string()
) – the first exchange id to compare. - exchangeIdB (
string()
) – the second exchange id to compare.
Check if two exchange ids are equal.
Returns: true or false if exchange ids are equal. Return type: boolean - exchangeIdA (
filterInPlace
-
Util.
filterInPlace
(xs, pred) Arguments: - xs (
[T]()
) – Array to filter. - pred (
function()
) – If this function returns true when testing an item, the item will be kept in the array, otherwise the item will be removed.
This function takes an array of type <T>, and a predicate function to test each element of the array. This function does not create a new array.
Return type: void -
Util.
pred
(x) Arguments: - x (
T()
) – None
Return type: boolean
- x (
- xs (
generateConeCylinderMeshData
-
Util.
generateConeCylinderMeshData
(cylinderRadius, numSegments, stemHeight, coneBaseRadius, capHeight, taperHeight) Arguments: - cylinderRadius (
number()
) – the radius of the cylinder portion of the geometry. - numSegments (
number()
) – the number of segments used to create the cylinder and cone portions. Increasing this number will result in a smoother appearance but consume more memory. - stemHeight (
number()
) – the height of the cone portion. - coneBaseRadius (
number()
) – the radius of the cone portion - capHeight (
number()
) – the height of the cylinder cap - taperHeight (
number()
) – the height of the taper.
Creates a cylinder with an attached cone. An example of the resulting geometry can be observed in the default Axis Triad or Handles implementation.
Return type: MeshData - cylinderRadius (
generateSphereMeshData
-
Util.
generateSphereMeshData
() Creates a basic sphere with normals.
Return type: MeshData
isCircleElement
-
Util.
isCircleElement
(prop) Arguments: - prop (
object()
) – the Subentity to check.
Check whether or not a Subentity is a CircleElement.
Returns: true if the prop passed is a CircleElement, false otherwise. Return type: boolean - prop (
isFace
-
Util.
isFace
(prop) Arguments: - prop (
object()
) – the Subentity to check.
Check whether or not a Subentity is a Face.
Returns: true if the prop passed is a Face, false otherwise. Return type: boolean - prop (
isLineElement
-
Util.
isLineElement
(prop) Arguments: - prop (
object()
) – the Subentity to check.
Check whether or not a Subentity is a LineElement.
Returns: true if the prop passed is a LineElement, false otherwise. Return type: boolean - prop (
isOtherEdgeElement
-
Util.
isOtherEdgeElement
(prop) Arguments: - prop (
object()
) – the Subentity to check.
Check whether or not a Subentity is a OtherEdgeElement.
Returns: true if the prop passed is a OtherEdgeElement, false otherwise. Return type: boolean - prop (
isPlaneElement
-
Util.
isPlaneElement
(prop) Arguments: - prop (
object()
) – the Subentity to check.
Check whether or not a Subentity is a PlaneElement.
Returns: true if the prop passed is a PlaneElement, false otherwise. Return type: boolean - prop (
setSubtraction
-
Util.
setSubtraction
(setA, setB) Arguments: - setA (
Set
) – The starting set to start subtracting from. - setB (
Set
) – The set used to reject values fromsetA
.
Returns a new set consisting of all elements in
setA
not found insetB
.Returns: The resulting set. Return type: Set <T> - setA (
setToArray
-
Util.
setToArray
(set) Arguments: - set (
Set
) – The set to convert.
Turns a Set<T> into an Array<T>.
Returns: The resulting array. Return type: [T] - set (
sleep
-
Util.
sleep
(duration) Arguments: - duration (
number()
) – number of milliseconds until the returned promise can resolve
Returns a promise that resolves after the provided number of milliseconds
Return type: Promise <void> - duration (
toSet
-
Util.
toSet
(xs) Arguments: - xs (
[T]()
) – Array to create a Set from
Creates a Set from the provided array.
Return type: Set <T> - xs (
waitForAll
-
Util.
waitForAll
(promises) Arguments: - promises (
[Promise <void>]()
) – array of promises.
This function behaves like writing [[Promise.all(promises).then(no_op)]] but does not incur the overhead of creating a [[.then]] promise. Using this function can provide a performance boost when doing large amounts of batch processing with groups of promises.
Return type: Promise <void> - promises (