UNPKG

fluorine-orchestra

Version:
11 lines (8 loc) 401 B
import invariant from 'invariant'; import { Map, Iterable } from 'immutable'; export default function toMap(value) { invariant(Iterable.isKeyed(value), 'toMap: `value` is expected to be a keyed iterable.'); var item = Map.isMap(value) ? value : new Map(value); invariant(item.has('id') && typeof item.get('id') === 'string', 'toMap: `value` is expected to contain an `id`.'); return item; }