/** * Closure Function to Store Data in Memory (RAM) * * @param {Object|Array = Object} [initValue] - initialized value * @return {function(ACTION, key, value)} - to store or retrieve data in memory */ export function memoryCache(initValue?: {}): (arg0: ACTION, arg1: key, arg2: value) => any; /** * Perform the fastest possible cache in RAM * * @param {string} ACTION - one of GET, SET, or DELETE * @param {string} key - stored value's key identifier * @param {*} value - value to store */ export function performCache(ACTION: string, key: string, value: any): any; export namespace performCache { const cache: {}; } /** * Perform localStorage (for the Web), node-persist (for Node.js) or AsyncStorage (for React Native) * * @setup (for backend): * if (!Current.Storage) { * Current.Storage = require('node-persist') * performStorage.init() // initiate local storage as async method to avoid blocking concurrent processes * } * @example: * performStorage(SET, 'token', 'Wait_for_it___Legendary_Genius') * * @NOTE: * AsyncStorage takes 5 milliseconds delay on average for each storage operation, and can add up. * Store in state instead, for non-persistent data, because it is much faster and synchronous. * * @param {string} ACTION - one of GET, SET, DELETE or ADD * @param {string} storageKey - stored value's key identifier * @param {*} value - value to store * @param {Array|Object} initialValue - used for ADD ACTION when saving the first time * @return {*} - Synchronous/Asynchronous promise result of Local Storage (or stored value for GET action) */ export function performStorage(ACTION: string, storageKey: string, value?: any, initialValue?: any[] | Object): any; export namespace performStorage { namespace toClient { const GET: string; const SET: string; const DELETE: string; } namespace toServer { const GET_1: string; export { GET_1 as GET }; const SET_1: string; export { SET_1 as SET }; const DELETE_1: string; export { DELETE_1 as DELETE }; } namespace toServerSync { const GET_2: string; export { GET_2 as GET }; const SET_2: string; export { SET_2 as SET }; const DELETE_2: string; export { DELETE_2 as DELETE }; } function init(...args: any[]): any; function initSync(...args: any[]): any; }