@exodus/storage-mobile
v1.0.7
Published
Implementation of storage-spec interface for react-native on mobile
Downloads
4,592
Readme
@exodus/storage-mobile
Usage
To use the module call the factory and pass in required dependencies
import { hashSync } from '@exodus/crypto/hash'
import createStorageMobile from '@exodus/storage-mobile'
import AsyncStorage from '@exodus/react-native-async-storage'
import fs from '@exodus/react-native-fs'
const hashString = (str) => hashSync('sha256', str, 'hex').slice(0, 20)
const storage = createStorageMobile({
asyncStorage: AsyncStorage,
androidFallback: {
filesystem: {
rimraf: fs.unlink.bind(fs),
mkdirp: fs.mkdir.bind(fs),
readUtf8: fs.readUtf8.bind(fs),
writeUtf8: fs.writeUtf8.bind(fs),
},
placeholder: '~', // will be written to the async storage for files larger than the threshold
rootDir: fs.DocumentDirectoryPath + '/async-storage',
hashString,
threshold: 1.9 * 1024 * 1024, // 2 megs, slightly lower to avoid the edge cases too close to the limit
},
})