Skip to main content

UUID

UUID namespace

Index

Codec

codecDecode

  • codecDecode(this: void, input: unknown, context: Context<UUID>): Result<UUID, CodecError>
  • Returns the decoded input, Result.Ok or Result.Error()

    @example
    interface SomeObject {
    foo: string
    }
    const someCodec: Codec<SomeObject> = ...;
    const input: unknown = ...;
    const decoded = Codec.decode(someCodec, input);

codecEncode

  • codecEncode(this: void, input: UUID): unknown
  • Returns the encoded input

    @example
    interface SomeObject {
    foo: string
    }
    const someCodec: Codec<SomeObject> = ...;
    const someObject: SomeObject = { foo: "bar" }
    const encoded = Codec.decode(someCodec, someObject);

codecSchema

  • codecSchema(this: void): JSONValue
  • Returns the JSONSchema corresponding to the decoded type

    @example
    const someCodec: Codec<unknown> = ...;
    const jsonSchema = Codec.schema(someCodec);

Constructor

asInstance

  • asInstance(anyValue: unknown): Option<UUID>
  • Try to convert anyValue to enum value or else returns Option.None

    @example
    const StringType: Type<string>;
    StringType.asInstance('foo'); // Option.Some('foo')
    StringType.asInstance(12); // Option.None

empty

  • Returns an UUID with only 0

    @example
    const emptyUUID = UUID.empty();// '00000000-0000-0000-0000-000000000000'

of

  • of(value: `${string}-${string}-${string}-${string}-${string}`): UUID
  • UUID constructor

    @example
    const uuid = UUID.of('1c19548b-7cac-4222-b722-dc38f2870669');

Type

inspect

inspect: Option<(anyValue: UUID, depth: number, options: InspectOptions, inspect: InspectFunction) => string>

When defined, returns a custom string representation

@example

@param

hasInstance

  • hasInstance(anyValue: unknown): anyValue is UUID
  • Return true if the given value is an instance of the class.

    @example
    const StringType: Type<string>;
    StringType.hasInstance('foo'); // true
    StringType.hasInstance(42); // false

Other

typeName

Re-exports typeName

readonlyid

id: ApplicationId

Application id

readonlyinitialConfiguration

initialConfiguration: UUIDConfiguration

Application initial configuration

readonlystate

state: Ref<ApplicationState>

Ref to application state

__call__

  • __call__(value: `${string}-${string}-${string}-${string}-${string}`): UUID

configure

  • configure(updater: Partial<UUIDConfiguration>): void
  • Return the configuration value

    @example
    const app = Application('my-app', {
    myVar: 1
    });
    app.configure({
    myVar: 2
    });
    app.get('myVar');// 2

get

  • get<Key>(key: Key): UUIDConfiguration[Key]
  • Return the configuration value

    @example
    const app = Application('my-app', {
    myVar: 1
    });
    app.get(app, 'myVar');// 1

    Type parameters

    • Key: randomUUIDGenerator

toBigInt

  • toBigInt(source: UUID): bigint
  • Returns a bigint from UUID

    @example
    const uuid = UUID('1c19548b-7cac-4222-b722-dc38f2870669');
    const bigint = UUID.toBigInt(uuid);// BigInt('Ox1c19548b7cac4222b722dc38f2870669');

toUint32Array

  • toUint32Array(source: UUID): Uint32Array
  • Converts a UUID to an array of uint32 values.

    @example
    const uuid: UUID;
    const parts = UUID.toUint32Array(uuid);

unwrap

  • unwrap(value: UUID): `${string}-${string}-${string}-${string}-${string}`
  • Convert a tagged value to the underlying type

wrap

  • wrap(value: `${string}-${string}-${string}-${string}-${string}`): UUID
  • Convert an underlying type to a tagged type