Alright, I've added the feature using the first option as this is most convenient for the standard use case.
I've also thought a bit about the option of purging only a subset of the samples and I added a function Sampler.purgeSelection() which you can give an array of sounds and it will purge only those (while unpurging all other sounds).
// I'm pretty sure nobody knows that funky function...
var list = Sampler.createSelectionWithFilter(function()
{
// it will be called with every sound as `this` object and you just
// need to return true if you want it to be included in the list...
return this.get(Sampler.HiKey) > 72;
});
Console.print(list.length);
// now you can purge every sample that is mapped above note number 72
Sampler.purgeSampleSelection(list);
I'm curious how it will hold up in a real world use case, but the only problem I can see so far is that changing the purge state of the sampler will overwrite the "custom" purge selection so you need to make sure you call this method and restore the sampler in the correct order as the information which selection must be purged is handled on the scripting layer alone.
It might be one of the things that I'll regret adding like the Ghost panels, so take this feature request with a disclaimer that I might remove it if it becomes too annoying :)