UNPKG

@gravity-ui/graph

Version:

Modern graph editor component

30 lines (29 loc) 631 B
export function assign(target, source) { const props = Object.keys(source); let prop; for (let i = 0; i < props.length; i += 1) { prop = props[i]; target[prop] = source[prop]; } return target; } export function cache(fn) { let result; let touched = true; return { get: () => { if (touched) { result = fn(); touched = false; } return result; }, reset() { touched = true; }, clear() { touched = true; result = undefined; }, }; }