Initial commit

This commit is contained in:
Brian McGonagill 2026-03-18 09:02:21 -05:00
commit b3a51a4115
10336 changed files with 2381973 additions and 0 deletions

View file

@ -0,0 +1,23 @@
import { Arbitrary } from '../../check/arbitrary/definition/Arbitrary.js';
import { Stream } from '../../stream/Stream.js';
import { noUndefinedAsContext, UndefinedContextPlaceholder } from './helpers/NoUndefinedAsContext.js';
export class AlwaysShrinkableArbitrary extends Arbitrary {
constructor(arb) {
super();
this.arb = arb;
}
generate(mrng, biasFactor) {
const value = this.arb.generate(mrng, biasFactor);
return noUndefinedAsContext(value);
}
canShrinkWithoutContext(value) {
return true;
}
shrink(value, context) {
if (context === undefined && !this.arb.canShrinkWithoutContext(value)) {
return Stream.nil();
}
const safeContext = context !== UndefinedContextPlaceholder ? context : undefined;
return this.arb.shrink(value, safeContext).map(noUndefinedAsContext);
}
}