DuyTa's picture
Upload folder using huggingface_hub
bc20498 verified
import { withGet } from './withGet.js';
export const overridable = (_store, onChange) => {
const store = withGet(_store);
const update = (updater, sideEffect) => {
store.update((curr) => {
const next = updater(curr);
let res = next;
if (onChange) {
res = onChange({ curr, next });
}
sideEffect?.(res);
return res;
});
};
const set = (curr) => {
update(() => curr);
};
return {
...store,
update,
set,
};
};