(fn, cfg, state = true)
| 150 | }); |
| 151 | |
| 152 | function watchStorage(fn, cfg, state = true) { |
| 153 | if (state && !valuesToWatch) { |
| 154 | valuesToWatch = {}; |
| 155 | } |
| 156 | cfg::forEachEntry(([area, ids]) => { |
| 157 | const { prefix } = storage[area]; |
| 158 | for (const id of ensureArray(ids)) { |
| 159 | const key = prefix + id; |
| 160 | const list = valuesToWatch[key] || state && (valuesToWatch[key] = []); |
| 161 | const i = list ? list.indexOf(fn) : -1; |
| 162 | if (i >= 0 && !state) { |
| 163 | list.splice(i, 1); |
| 164 | if (!list.length) delete valuesToWatch[key]; |
| 165 | } else if (i < 0 && state) { |
| 166 | list.push(fn); |
| 167 | } |
| 168 | } |
| 169 | }); |
| 170 | if (isEmpty(valuesToWatch)) { |
| 171 | valuesToWatch = null; |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | async function updateScriptSizeContributor(key, val) { |
| 176 | const area = sizesPrefixRe.exec(key); |
no test coverage detected