var DATA = (function (K, N, total) {
function random(n) {
return Math.floor(Math.random() * 7);
}
function randomKey() {
return Math.random().toString(36).slice(2);
}
function randomCollection(count = random(N)) {
for (var a = new Array(count), i = 0; i < count; i++) {
a[i] = randomValue();
}
return a;
}
function randomObject(keysCount = random(N)) {
for (var obj = {}, i = 0; i < keysCount; i++) {
obj[randomKey()] = randomValue();
}
return obj;
}
function randomValue(type = random(K)) {
switch (type % K) {
case 0: return undefined;
case 1: return null; break;
case 2: return String(Math.random());
case 3: return Math.random() > 0.5;
case 4: return Math.random() * 1E3;
case 5: return randomCollection();
default: return randomObject();
}
}
return randomCollection(total);
}(7, 5, 1E5));
function canBeAddedToWeakSet_switch_simple(value) {
switch (typeof value) {
case 'undefined':
case 'boolean':
case 'number':
case 'string':
case 'symbol':
return false;
case 'object':
return value !== null
default:
return true;
}
}
function canBeAddedToWeakSet_switch_htmlallcollection(value) {
switch (typeof value) {
case 'undefined':
return value !== undefined
case 'boolean':
case 'number':
case 'string':
case 'symbol':
return false
case 'object':
return value !== null
default:
return true
}
}
function canBeAddedToWeakSet_from_es6_weakset(value) {
return typeof value === 'object' ? value !== null : typeof value === 'function';
}
function canBeAddedToWeakSet_short_circuit_typeof(value) {
return typeof value === 'object' && value !== null || typeof value === 'function';
}
function canBeAddedToWeakSet_3eq_typeof_x2(value) {
return value !== null && (typeof value === 'object' || typeof value === 'function');
}
function canBeAddedToWeakSet_2eq_typeof_x2(value) {
return value != null && (typeof value === 'object' || typeof value === 'function');
}
function canBeAddedToWeakSet_implicit_typeof_x2(value) {
return value && (typeof value === 'object' || typeof value === 'function');
}
function canBeAddedToWeakSet_boolean_typeof_x2(value) {
return !!value && (typeof value === 'object' || typeof value === 'function');
}
const _set_ = new WeakSet();
function canBeAddedToWeakSet_try_catch(value) {
try { _set_.add(value); return true; }
catch (e) { return false; }
}
function test(canAdd) {
const count = DATA.reduce((countOfAddables, value) => (canAdd(value) ? 1 : 0) + countOfAddables, 0);
console.log('can add %d out of %d values in the array', count, DATA.length);
}