valtio
Version:
🧙 Valtio makes proxy-state simple for React and Vanilla
34 lines (33 loc) • 1 kB
TypeScript
type InternalProxySet<T> = Set<T> & {
data: T[];
toJSON: object;
index: number;
epoch: number;
intersection: (other: Set<T>) => Set<T>;
union: (other: Set<T>) => Set<T>;
difference: (other: Set<T>) => Set<T>;
symmetricDifference: (other: Set<T>) => Set<T>;
isSubsetOf: (other: Set<T>) => boolean;
isSupersetOf: (other: Set<T>) => boolean;
isDisjointFrom: (other: Set<T>) => boolean;
};
export declare const isProxySet: (obj: object) => boolean;
/**
* proxySet
*
* This is to create a proxy which mimic the native Set behavior.
* The API is the same as Set API
*
* @example
* import { proxySet } from 'valtio/utils'
* const state = proxySet([1,2,3])
* // can be used inside a proxy as well
* const state = proxy({
* count: 1,
* set: proxySet()
* })
*/
export declare function proxySet<T>(initialValues?: Iterable<T> | null): InternalProxySet<T> & {
$$valtioSnapshot: Omit<InternalProxySet<T>, "set" | "delete" | "clear">;
};
export {};