(object, path)
| 105 | return output |
| 106 | } |
| 107 | function unset(object, path) { |
| 108 | if (object == null) { |
| 109 | return true |
| 110 | } |
| 111 | |
| 112 | const paths = parseJsonPath(path) |
| 113 | |
| 114 | var current = object |
| 115 | for (var i = 0; i < paths.length - 1; i++) { |
| 116 | var key = paths[i] |
| 117 | if (!(key in current)) { |
| 118 | return true |
| 119 | } |
| 120 | current = current[key] |
| 121 | if (current == null) { |
| 122 | return true |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | var finalKey = paths[paths.length - 1] |
| 127 | |
| 128 | // 处理数组的情况 |
| 129 | if (Array.isArray(current)) { |
| 130 | var index = parseInt(finalKey, 10) |
| 131 | if (!isNaN(index)) { |
| 132 | current.splice(index, 1) |
| 133 | return true |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | // 处理对象的属性删除 |
| 138 | delete current[finalKey] |
| 139 | return true |
| 140 | } |
| 141 | // 通知 |
| 142 | async function notify(title, subt, desc, opts) { |
| 143 | $.msg(title, subt, desc, opts) |
no test coverage detected