@pixotope/utils
v0.4.0
Published
Modular utility functions for Pixotope Foundation
Readme
@pixotope/utils
Small shared utility functions used across Pixotope Foundation packages.
Install
pnpm add @pixotope/utilsUsage
Root entry point
import { shallowEqual } from "@pixotope/utils";
shallowEqual({ a: 1 }, { a: 1 }); // true
shallowEqual({ a: 1 }, { a: 2 }); // false@pixotope/utils/comparison
The same shallowEqual helper, importable directly from the comparison
sub-path:
import { shallowEqual } from "@pixotope/utils/comparison";
const map1 = new Map([["a", 1]]);
const map2 = new Map([["a", 1]]);
shallowEqual(map1, map2); // true
const set1 = new Set([1, 2]);
const set2 = new Set([1, 3]);
shallowEqual(set1, set2); // false@pixotope/utils/dh
Type-only definitions for messages exchanged with Pixotope/Disguise DataHub. These types have no runtime code — use them to type payloads received over a DataHub socket connection:
import type { TSocketDHMessage, TCallResult } from "@pixotope/utils/dh";
function handleMessage(msg: TSocketDHMessage<{ value: number }>) {
console.log(msg.topic, msg.message.value);
}
function handleCallResult(result: TCallResult<boolean>) {
console.log(result.topic.Method, result.message.Result);
}API overview
shallowEqual(objA, objB)— one-level-deep equality check. Compares primitives withObject.is, and does a one-level comparison forMaps,Sets, and plain objects. Available from both@pixotope/utilsand@pixotope/utils/comparison.TSocketDHMessage<T>— shape of a message received on a DataHub socket ({ topic, message }). Available from@pixotope/utils/dh.TCallResult<T>— shape of a DataHub method call result, including the originating call's topic metadata. Available from@pixotope/utils/dh. Note: thedhentry point currently covers only these message types; more Pixotope DataHub message types are expected to be added over time.
See the generated API reference (pnpm typedoc) for full type signatures.
