UNPKG

328 BJavaScriptView Raw
1/**
2 * Returns true iff `x` implements {@link IDeref}.
3 *
4 * @param x -
5 */
6export const isDeref = (x) => x != null && typeof x["deref"] === "function";
7/**
8 * If `x` implements {@link IDeref}, returns its wrapped value, else
9 * returns `x` itself.
10 *
11 * @param x -
12 */
13export const deref = (x) => (isDeref(x) ? x.deref() : x);