chore: format

This commit is contained in:
Nathan Walker
2020-07-05 14:57:06 -07:00
parent 8f2900ad0b
commit da3c0b973d
379 changed files with 71587 additions and 54582 deletions

View File

@@ -5,71 +5,75 @@ import * as utils from "../utils/utils";
const userDefaults = NSUserDefaults.standardUserDefaults;
export function hasKey(key: string): boolean {
Common.checkKey(key);
Common.checkKey(key);
return userDefaults.objectForKey(key) !== null;
return userDefaults.objectForKey(key) !== null;
}
// utils.ios.getters
export function getBoolean(key: string, defaultValue?: boolean): boolean {
Common.checkKey(key);
if (hasKey(key)) {
return userDefaults.boolForKey(key);
}
Common.checkKey(key);
if (hasKey(key)) {
return userDefaults.boolForKey(key);
}
return defaultValue;
return defaultValue;
}
export function getString(key: string, defaultValue?: string): string {
Common.checkKey(key);
if (hasKey(key)) {
return userDefaults.stringForKey(key);
}
Common.checkKey(key);
if (hasKey(key)) {
return userDefaults.stringForKey(key);
}
return defaultValue;
return defaultValue;
}
export function getNumber(key: string, defaultValue?: number): number {
Common.checkKey(key);
if (hasKey(key)) {
return userDefaults.doubleForKey(key);
}
Common.checkKey(key);
if (hasKey(key)) {
return userDefaults.doubleForKey(key);
}
return defaultValue;
return defaultValue;
}
// setters
export function setBoolean(key: string, value: boolean): void {
Common.checkKey(key);
Common.ensureValidValue(value, "boolean");
userDefaults.setBoolForKey(value, key);
Common.checkKey(key);
Common.ensureValidValue(value, "boolean");
userDefaults.setBoolForKey(value, key);
}
export function setString(key: string, value: string): void {
Common.checkKey(key);
Common.ensureValidValue(value, "string");
userDefaults.setObjectForKey(value, key);
Common.checkKey(key);
Common.ensureValidValue(value, "string");
userDefaults.setObjectForKey(value, key);
}
export function setNumber(key: string, value: number): void {
Common.checkKey(key);
Common.ensureValidValue(value, "number");
userDefaults.setDoubleForKey(value, key);
Common.checkKey(key);
Common.ensureValidValue(value, "number");
userDefaults.setDoubleForKey(value, key);
}
export function remove(key: string): void {
Common.checkKey(key);
userDefaults.removeObjectForKey(key);
Common.checkKey(key);
userDefaults.removeObjectForKey(key);
}
export function clear(): void {
userDefaults.removePersistentDomainForName(NSBundle.mainBundle.bundleIdentifier);
userDefaults.removePersistentDomainForName(
NSBundle.mainBundle.bundleIdentifier
);
}
export function flush(): boolean {
return userDefaults.synchronize();
return userDefaults.synchronize();
}
export function getAllKeys(): Array<string> {
return utils.ios.collections.nsArrayToJSArray(userDefaults.dictionaryRepresentation().allKeys);
return utils.ios.collections.nsArrayToJSArray(
userDefaults.dictionaryRepresentation().allKeys
);
}