react-native-user-defaults icon indicating copy to clipboard operation
react-native-user-defaults copied to clipboard

Typescript

Open litinskii opened this issue 1 year ago • 0 comments
trafficstars

declare module 'react-native-user-defaults' {
  interface UserDefaults {
    /**
     * Set information for a key.
     * @param key The key to store the value under.
     * @param value The value to store. It can be a string, number, boolean, object, or array.
     * @param suiteName Optional. The suite name (group identifier) for shared user defaults.
     * @param cb Optional. A callback function that receives an error or success data.
     * @returns A promise that resolves with the success data.
     */
    set(
      key: string,
      value: string | number | boolean | object | any[],
      suiteName?: string,
      cb?: (err: Error | null, data: any) => void,
    ): Promise<any>;

    /**
     * Get information for a key.
     * @param key The key whose value you want to retrieve.
     * @param suiteName Optional. The suite name (group identifier) for shared user defaults.
     * @param cb Optional. A callback function that receives an error or the retrieved data.
     * @returns A promise that resolves with the retrieved data.
     */
    get(
      key: string,
      suiteName?: string,
      cb?: (err: Error | null, data: any) => void,
    ): Promise<any>;

    /**
     * Remove an item by key.
     * @param key The key of the item to remove.
     * @param suiteName Optional. The suite name (group identifier) for shared user defaults.
     * @param cb Optional. A callback function that receives an error or success data.
     * @returns A promise that resolves with the success data.
     */
    remove(
      key: string,
      suiteName?: string,
      cb?: (err: Error | null, data: any) => void,
    ): Promise<any>;

    /**
     * Empty all non-default items.
     * APP default settings will be reserved.
     * @param suiteName Optional. The suite name (group identifier) for shared user defaults.
     * @param cb Optional. A callback function that receives an error or success data.
     * @returns A promise that resolves with the success data.
     */
    empty(
      suiteName?: string,
      cb?: (err: Error | null, data: any) => void,
    ): Promise<any>;
  }

  const userDefaults: UserDefaults;
  export default userDefaults;
}

litinskii avatar Aug 27 '24 19:08 litinskii