mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 17:41:40 -05:00
Be more careful with truthy values
This commit is contained in:
parent
7e7528746b
commit
e122caa326
1 changed files with 9 additions and 5 deletions
|
@ -219,7 +219,11 @@ export function get(...target) {
|
|||
if (defult && (! Array.isArray(defult) && typeof defult === "object")) {
|
||||
return Object.assign(o({}), defult, user)
|
||||
} else {
|
||||
return user || defult
|
||||
if (user !== undefined) {
|
||||
return user
|
||||
} else {
|
||||
return defult
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,13 +250,13 @@ export async function getAsync(...target) {
|
|||
set("aucmd", "BufRead", "memrise.com", "open memrise.com")
|
||||
*/
|
||||
export function set(...args) {
|
||||
const target = args.slice(0, args.length - 1)
|
||||
const value = args[args.length - 1]
|
||||
|
||||
if (args.length < 2) {
|
||||
throw "You must provide at least two arguments!"
|
||||
}
|
||||
|
||||
const target = args.slice(0, args.length - 1)
|
||||
const value = args[args.length - 1]
|
||||
|
||||
setDeepProperty(USERCONFIG, value, target)
|
||||
save()
|
||||
}
|
||||
|
@ -260,7 +264,7 @@ export function set(...args) {
|
|||
/** Delete the key at target if it exists */
|
||||
export function unset(...target) {
|
||||
const parent = getDeepProperty(USERCONFIG, target.slice(0, -1))
|
||||
if (parent) delete parent[target[target.length - 1]]
|
||||
if (parent !== undefined) delete parent[target[target.length - 1]]
|
||||
save()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue