function toArray(val, stringify) {
    const result = [];
    for (const key of val.keys()) {
        result.push(stringify ? "" + key : key);
    }
    return result;
}
@param {Map|Set} val
@param {boolean=} stringify
@return {Array}