one
Version:
One is a React framework for web, iOS, and Android apps.
50 lines (47 loc) • 1.57 kB
JavaScript
import { NitroModules } from "react-native-nitro-modules";
import { rethrowNativeError } from "../nativeError.native.js";
import { invalidKey, invalidValue } from "./validate.native.js";
var hybrid;
function getItem(key) {
if (typeof key !== "string" || key === "") invalidKey("Storage.getItem");
try {
var _getItem;
return (_getItem = (hybrid !== null && hybrid !== void 0 ? hybrid : hybrid = NitroModules.createHybridObject("OneStorage")).getItem(key)) !== null && _getItem !== void 0 ? _getItem : null;
} catch (error) {
rethrowNativeError(error);
}
}
function setItem(key, value) {
if (typeof key !== "string" || key === "") invalidKey("Storage.setItem");
if (typeof value !== "string") invalidValue("Storage.setItem");
try {
;
(hybrid !== null && hybrid !== void 0 ? hybrid : hybrid = NitroModules.createHybridObject("OneStorage")).setItem(key, value);
} catch (error) {
rethrowNativeError(error);
}
}
function removeItem(key) {
if (typeof key !== "string" || key === "") invalidKey("Storage.removeItem");
try {
;
(hybrid !== null && hybrid !== void 0 ? hybrid : hybrid = NitroModules.createHybridObject("OneStorage")).removeItem(key);
} catch (error) {
rethrowNativeError(error);
}
}
function getAllKeys() {
try {
return (hybrid !== null && hybrid !== void 0 ? hybrid : hybrid = NitroModules.createHybridObject("OneStorage")).getAllKeys();
} catch (error) {
rethrowNativeError(error);
}
}
var Storage = Object.freeze({
getItem,
setItem,
removeItem,
getAllKeys
});
export { Storage };
//# sourceMappingURL=index.native.js.map