'use strict'; export function create(obj, proto=Object.prototype) { const props = Object.keys(obj) .map((key) => [ key, { value: obj[key], enumerable: true } ]) .reduce((acc, [ key, value ]) => ({ ...acc, [key]: value }), {}); return Object.create(proto, props); }; export function random_choice(collection, r) { const idx = Math.floor(collection.length * r); return collection[idx]; } export function pairs(arr1, arr2) { return arr1 .map((x, i) => arr2.map(y => [x, y])) .flat(); }