-
Notifications
You must be signed in to change notification settings - Fork 3
randomSubset
Subhajit Sahu edited this page Dec 8, 2022
·
1 revision
Pick an arbitrary subset.
Similar: subsets, hasSubset, randomSubset.
function randomSubset(x, n, fr)
// x: an object
// n: number of entries [-1 ⇒ any]
// fr: random number generator ([0, 1))
const object = require('extra-object');
var x = {a: 1, b: 2, c: 3, d: 4};
object.subset(x);
// → { a: 1 }
object.subset(x, 3);
// → { a: 1, b: 2, d: 4 }
object.subset(x, 2);
// → { b: 2, d: 4 }