UNPKG

@rustable/utils

Version:

Essential utilities for object cloning, string manipulation, and value comparison in TypeScript, inspired by Rust's standard library.

32 lines (31 loc) 899 B
interface PtrAccessors<T> { get: () => T; set: (value: T) => void; } /** * Symbol used as a unique key for the pointer function. */ declare const symbol: unique symbol; /** * Creates a ptrable reference that behaves like the original object * @param accessors Getter and setter functions * @returns A Ptr instance that behaves like the original object */ export declare function Ptr<T>({ get, set }: PtrAccessors<T>): Ptr<T>; export declare namespace Ptr { var ptr: typeof symbol; } /** * Represents a ptrable reference to a value. * The ptrable reference can be modified, but modifications won't affect the original value. * Access to the original value is provided through the `Ptr.ptr` symbol. * * @template T The type of the ptrable value */ export type Ptr<T = object> = T & { /** * The original value of the Ptr object. */ [Ptr.ptr]: T; }; export {};