Repository: dubzzz/fast-check
Pull request #1726 (2021-04-12 14:11:18)

⬆️ Bump esbuild from 0.11.8 to 0.11.9 in /test/esm/esbuild-with-require
Bumps [esbuild](https://github.com/evanw/esbuild) from 0.11.8 to 0.11.9.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/evanw/esbuild/releases">esbuild's releases</a>.</em></p>
<blockquote>
<h2>v0.11.9</h2>
<ul>
<li>
<p>Fix escaping of non-BMP characters in property names (<a href="https://github-redirect.dependabot.com/evanw/esbuild/issues/977">#977</a>)</p>
<p>Property names in object literals do not have to be quoted if the property is a valid JavaScript identifier. This is defined as starting with a character in the <code>ID_Start</code> Unicode category and ending with zero or more characters in the <code>ID_Continue</code> Unicode category. However, esbuild had a bug where non-BMP characters (i.e. characters encoded using two UTF-16 code units instead of one) were always checked against <code>ID_Continue</code> instead of <code>ID_Start</code> because they included a code unit that wasn't at the start. This could result in invalid JavaScript being generated when using <code>--charset=utf8</code> because <code>ID_Continue</code> is a superset of <code>ID_Start</code> and contains some characters that are not valid at the start of an identifier. This bug has been fixed.</p>
</li>
<li>
<p>Be maximally liberal in the interpretation of the <code>browser</code> field (<a href="https://github-redirect.dependabot.com/evanw/esbuild/issues/740">#740</a>)</p>
<p>The <code>browser</code> field in <code>package.json</code> is an informal convention followed by browser-specific bundlers that allows package authors to substitute certain node-specific import paths with alternative browser-specific import paths. It doesn't have a rigorous specification and the <a href="https://github.com/defunctzombie/package-browser-field-spec">canonical description</a> of the feature doesn't include any tests. As a result, each bundler implements this feature differently. I have tried to create a <a href="https://github.com/evanw/package-json-browser-tests">survey of how different bundlers interpret the <code>browser</code> field</a> and the results are very inconsistent.</p>
<p>This release attempts to change esbuild to support the union of the behavior of all other bundlers. That way if people have the <code>browser</code> field working with some other bundler and they switch to esbuild, the <code>browser</code> field shouldn't ever suddenly stop working. This seemed like the most principled approach to take in this situation.</p>
<p>The drawback of this approach is that it means the <code>browser</code> field may start working when switching to esbuild when it was previously not working. This could cause bugs, but I consider this to be a problem with the package (i.e. not using a more well-supported form of the <code>browser</code> field), not a problem with esbuild itself.</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/evanw/esbuild/blob/master/CHANGELOG.md">esbuild's changelog</a>.</em></p>
<blockquote>
<h2>0.11.9</h2>
<ul>
<li>
<p>Fix escaping of non-BMP characters in property names (<a href="https://github-redirect.dependabot.com/evanw/esbuild/issues/977">#977</a>)</p>
<p>Property names in object literals do not have to be quoted if the property is a valid JavaScript identifier. This is defined as starting with a character in the <code>ID_Start</code> Unicode category and ending with zero or more characters in the <code>ID_Continue</code> Unicode category. However, esbuild had a bug where non-BMP characters (i.e. characters encoded using two UTF-16 code units instead of one) were always checked against <code>ID_Continue</code> instead of <code>ID_Start</code> because they included a code unit that wasn't at the start. This could result in invalid JavaScript being generated when using <code>--charset=utf8</code> because <code>ID_Continue</code> is a superset of <code>ID_Start</code> and contains some characters that are not valid at the start of an identifier. This bug has been fixed.</p>
</li>
<li>
<p>Be maximally liberal in the interpretation of the <code>browser</code> field (<a href="https://github-redirect.dependabot.com/evanw/esbuild/issues/740">#740</a>)</p>
<p>The <code>browser</code> field in <code>package.json</code> is an informal convention followed by browser-specific bundlers that allows package authors to substitute certain node-specific import paths with alternative browser-specific import paths. It doesn't have a rigorous specification and the <a href="https://github.com/defunctzombie/package-browser-field-spec">canonical description</a> of the feature doesn't include any tests. As a result, each bundler implements this feature differently. I have tried to create a <a href="https://github.com/evanw/package-json-browser-tests">survey of how different bundlers interpret the <code>browser</code> field</a> and the results are very inconsistent.</p>
<p>This release attempts to change esbuild to support the union of the behavior of all other bundlers. That way if people have the <code>browser</code> field working with some other bundler and they switch to esbuild, the <code>browser</code> field shouldn't ever suddenly stop working. This seemed like the most principled approach to take in this situation.</p>
<p>The drawback of this approach is that it means the <code>browser</code> field may start working when switching to esbuild when it was previously not working. This could cause bugs, but I consider this to be a problem with the package (i.e. not using a more well-supported form of the <code>browser</code> field), not a problem with esbuild itself.</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/evanw/esbuild/commit/d616dac2ca7cb0f9bd918b96fa44ece3578ee9b3"><code>d616dac</code></a> publish 0.11.9 to npm</li>
<li><a href="https://github.com/evanw/esbuild/commit/a1983043a963c28a02799d7232bd4e752a13bd85"><code>a198304</code></a> Be maximally liberal in the interpretation of the <code>browser</code> field (<a href="https://github-redirect.dependabot.com/evanw/esbuild/issues/1140">#1140</a>)</li>
<li><a href="https://github.com/evanw/esbuild/commit/eac9513c8588a80de45de84aa8a3d9fbe01d2679"><code>eac9513</code></a> fix non-bmp characters in identifier validation (<a href="https://github-redirect.dependabot.com/evanw/esbuild/issues/1139">#1139</a>)</li>
<li><a href="https://github.com/evanw/esbuild/commit/093b23afe2ea9d0376d9d524df5dbc692d261f5d"><code>093b23a</code></a> fix go lints</li>
<li>See full diff in <a href="https://github.com/evanw/esbuild/compare/v0.11.8...v0.11.9">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=esbuild&package-manager=npm_and_yarn&previous-version=0.11.8&new-version=0.11.9)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually


</details>

codesandbox[bot]: This pull request is automatically built and testable in [CodeSandbox](https://codesandbox.io).

  To see build info of the built libraries, click [here](https://ci.codesandbox.io/status/dubzzz/fast-check/pr/1726/builds/118807) or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 5c9728b830023eac072cf0c8b647f4947a310a88:

|Sandbox| Source |
|--|--|
|[Vanilla](https://codesandbox.io/s/vanilla-fi8um)| Configuration |

codecov[bot]: # [Codecov](https://codecov.io/gh/dubzzz/fast-check/pull/1726?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) Report
> Merging [#1726](https://codecov.io/gh/dubzzz/fast-check/pull/1726?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) (5c9728b) into [main](https://codecov.io/gh/dubzzz/fast-check/commit/bbff08c7a922756e96d671c182e9e9a66ed45f18?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) (bbff08c) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/dubzzz/fast-check/pull/1726/graphs/tree.svg?width=650&height=150&src=pr&token=fRi2fJN730&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN)](https://codecov.io/gh/dubzzz/fast-check/pull/1726?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN)

```diff
@@           Coverage Diff           @@
##             main    #1726   +/-   ##
=======================================
  Coverage   96.51%   96.51%           
=======================================
  Files         108      108           
  Lines        3585     3585           
  Branches      710      710           
=======================================
  Hits         3460     3460           
  Misses        121      121           
  Partials        4        4           
```

| Flag | Coverage Δ | |
|---|---|---|
| unit-tests | `96.51% <ø> (ø)` | |
| unit-tests-10.x-Linux | `96.51% <ø> (?)` | |
| unit-tests-12.x-Linux | `?` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#carryforward-flags-in-the-pull-request-comment) to find out more.


------

[Continue to review full report at Codecov](https://codecov.io/gh/dubzzz/fast-check/pull/1726?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/dubzzz/fast-check/pull/1726?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN). Last update [bbff08c...5c9728b](https://codecov.io/gh/dubzzz/fast-check/pull/1726?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN).


Patch:
diff --git a/src/check/arbitrary/FrequencyArbitrary.ts b/src/arbitrary/_internals/FrequencyArbitrary.ts
similarity index 58%
rename from src/check/arbitrary/FrequencyArbitrary.ts
rename to src/arbitrary/_internals/FrequencyArbitrary.ts
index 7710dafe..6d925604 100644
--- a/src/check/arbitrary/FrequencyArbitrary.ts
+++ b/src/arbitrary/_internals/FrequencyArbitrary.ts
@@ -1,57 +1,22 @@
 import { Random } from '../../random/generator/Random';
 import { Stream } from '../../stream/Stream';
-import { Arbitrary } from './definition/Arbitrary';
-import { convertFromNext, convertToNext } from './definition/Converters';
-import { NextArbitrary } from './definition/NextArbitrary';
-import { NextValue } from './definition/NextValue';
+import { Arbitrary } from '../../check/arbitrary/definition/Arbitrary';
+import { convertFromNext, convertToNext } from '../../check/arbitrary/definition/Converters';
+import { NextArbitrary } from '../../check/arbitrary/definition/NextArbitrary';
+import { NextValue } from '../../check/arbitrary/definition/NextValue';
 import { DepthContext, getDepthContextFor } from './helpers/DepthContext';
 
-/**
- * Conjonction of a weight and an arbitrary used by {@link frequency}
- * in order to generate values
- *
- * @remarks Since 1.18.0
- * @public
- */
-export interface WeightedArbitrary<T> {
-  /**
-   * Weight to be applied when selecting which arbitrary should be used
-   * @remarks Since 0.0.7
-   */
-  weight: number;
-  /**
-   * Instance of Arbitrary
-   * @remarks Since 0.0.7
-   */
-  arbitrary: Arbitrary<T>;
-}
-
-/** @internal */
-interface WeightedNextArbitrary<T> {
-  weight: number;
-  arbitrary: NextArbitrary<T>;
-}
-
-/** @internal */
-type FrequencyArbitraryContext<T> = {
-  selectedIndex: number;
-  originalBias: number | undefined;
-  originalContext: unknown;
-  clonedMrngForFallbackFirst: Random | null;
-  cachedGeneratedForFirst?: NextValue<T>;
-};
-
 /** @internal */
 export class FrequencyArbitrary<T> extends NextArbitrary<T> {
-  readonly summedWarbs: WeightedNextArbitrary<T>[];
+  readonly summedWarbs: _WeightedNextArbitrary<T>[];
   readonly totalWeight: number;
 
-  static from<T>(warbs: WeightedArbitrary<T>[], constraints: FrequencyContraints, label: string): Arbitrary<T> {
+  static from<T>(warbs: _WeightedArbitrary<T>[], constraints: _FrequencyContraints, label: string): Arbitrary<T> {
     if (warbs.length === 0) {
       throw new Error(`${label} expects at least one weigthed arbitrary`);
     }
     let totalWeight = 0;
-    const warbsNext: WeightedNextArbitrary<T>[] = [];
+    const warbsNext: _WeightedNextArbitrary<T>[] = [];
     for (let idx = 0; idx !== warbs.length; ++idx) {
       const currentArbitrary = warbs[idx].arbitrary;
       if (currentArbitrary === undefined) {
@@ -76,8 +41,8 @@ export class FrequencyArbitrary<T> extends NextArbitrary<T> {
   }
 
   private constructor(
-    readonly warbs: WeightedNextArbitrary<T>[],
-    readonly constraints: FrequencyContraints,
+    readonly warbs: _WeightedNextArbitrary<T>[],
+    readonly constraints: _FrequencyContraints,
     readonly context: DepthContext
   ) {
     super();
@@ -110,7 +75,7 @@ export class FrequencyArbitrary<T> extends NextArbitrary<T> {
 
   shrink(value: T, context?: unknown): Stream<NextValue<T>> {
     if (context !== undefined) {
-      const safeContext = context as FrequencyArbitraryContext<T>;
+      const safeContext = context as _FrequencyArbitraryContext<T>;
       const selectedIndex = safeContext.selectedIndex;
       const originalBias = safeContext.originalBias;
       const originalArbitrary = this.summedWarbs[selectedIndex].arbitrary;
@@ -165,7 +130,7 @@ export class FrequencyArbitrary<T> extends NextArbitrary<T> {
     clonedMrngForFallbackFirst: Random | null,
     biasFactor: number | undefined
   ): NextValue<T> {
-    const context: FrequencyArbitraryContext<T> = {
+    const context: _FrequencyArbitraryContext<T> = {
       selectedIndex: idx,
       originalBias: biasFactor,
       originalContext: value.context,
@@ -210,113 +175,31 @@ export class FrequencyArbitrary<T> extends NextArbitrary<T> {
   }
 }
 
-/**
- * Infer the type of the Arbitrary produced by {@link frequency}
- * given the type of the source arbitraries
- *
- * @remarks Since 2.2.0
- * @public
- */
-export type FrequencyValue<Ts extends WeightedArbitrary<unknown>[]> = {
-  [K in keyof Ts]: Ts[K] extends WeightedArbitrary<infer U> ? U : never;
-}[number];
+/** @internal */
+interface _WeightedArbitrary<T> {
+  weight: number;
+  arbitrary: Arbitrary<T>;
+}
+
+/** @internal */
+interface _WeightedNextArbitrary<T> {
+  weight: number;
+  arbitrary: NextArbitrary<T>;
+}
 
-/**
- * Constraints to be applied on {@link frequency}
- * @remarks Since 2.14.0
- * @public
- */
-export type FrequencyContraints = {
-  /**
-   * When set to true, the shrinker of frequency will try to check if the first arbitrary
-   * could have been used to discover an issue. It allows to shrink trees.
-   *
-   * Warning: First arbitrary must be the one resulting in the smallest structures
-   * for usages in deep tree-like structures.
-   *
-   * Warning: First arbitrary will not be used if its weight is set to zero.
-   *
-   * @remarks Since 2.14.0
-   */
+/** @internal */
+type _FrequencyContraints = {
   withCrossShrink?: boolean;
-  /**
-   * While going deeper and deeper within a recursive structure (see {@link letrec}),
-   * this factor will be used to increase the probability to generate instances
-   * of the first passed arbitrary.
-   *
-   * Example of values: 0.1 (small impact as depth increases), 0.5, 1 (huge impact as depth increases).
-   *
-   * Warning: First arbitrary will not be used if its weight is set to zero.
-   *
-   * @remarks Since 2.14.0
-   */
   depthFactor?: number;
-  /**
-   * Maximal authorized depth.
-   * Once this depth has been reached only the first arbitrary will be used.
-   *
-   * Warning: Contrary to others, first arbitrary will be used even if its weight is set to zero.
-   *
-   * @remarks Since 2.14.0
-   */
   maxDepth?: number;
-  /**
-   * Depth identifier can be used to share the current depth between several instances.
-   *
-   * By default, if not specified, each instance of frequency will have its own depth.
-   * In other words: you can have depth=1 in one while you have depth=100 in another one.
-   *
-   * @remarks Since 2.14.0
-   */
   depthIdentifier?: string;
 };
 
-/**
- * @internal
- */
-function isFrequencyContraints(
-  param: FrequencyContraints | WeightedArbitrary<unknown> | undefined
-): param is FrequencyContraints {
-  return param != null && typeof param === 'object' && !('arbitrary' in param);
-}
-
-/**
- * For one of the values generated by `...warbs` - the probability of selecting the ith warb is of `warb[i].weight / sum(warb[j].weight)`
- *
- * **WARNING**: It expects at least one (Arbitrary, weight)
- *
- * @param warbs - (Arbitrary, weight)s that might be called to produce a value
- *
- * @remarks Since 0.0.7
- * @public
- */
-function frequency<Ts extends WeightedArbitrary<unknown>[]>(...warbs: Ts): Arbitrary<FrequencyValue<Ts>>;
-/**
- * For one of the values generated by `...warbs` - the probability of selecting the ith warb is of `warb[i].weight / sum(warb[j].weight)`
- *
- * **WARNING**: It expects at least one (Arbitrary, weight)
- *
- * @param constraints - Constraints to be applied when generating the values
- * @param warbs - (Arbitrary, weight)s that might be called to produce a value
- *
- * @remarks Since 0.0.7
- * @public
- */
-function frequency<Ts extends WeightedArbitrary<unknown>[]>(
-  constraints: FrequencyContraints,
-  ...warbs: Ts
-): Arbitrary<FrequencyValue<Ts>>;
-function frequency<Ts extends WeightedArbitrary<unknown>[]>(
-  ...args: [...Ts] | [FrequencyContraints, ...Ts]
-): Arbitrary<FrequencyValue<Ts>> {
-  // TODO With TypeScript 4.0 it will be possible to properly define typings for `frequency(...arbs, constraints)`
-  const label = 'fc.frequency';
-  const constraints = args[0];
-  if (isFrequencyContraints(constraints)) {
-    return FrequencyArbitrary.from(args.slice(1) as WeightedArbitrary<FrequencyValue<Ts>>[], constraints, label);
-  }
-
-  return FrequencyArbitrary.from(args as WeightedArbitrary<FrequencyValue<Ts>>[], {}, label);
-}
-
-export { frequency };
+/** @internal */
+type _FrequencyArbitraryContext<T> = {
+  selectedIndex: number;
+  originalBias: number | undefined;
+  originalContext: unknown;
+  clonedMrngForFallbackFirst: Random | null;
+  cachedGeneratedForFirst?: NextValue<T>;
+};
diff --git a/src/check/arbitrary/helpers/DepthContext.ts b/src/arbitrary/_internals/helpers/DepthContext.ts
similarity index 100%
rename from src/check/arbitrary/helpers/DepthContext.ts
rename to src/arbitrary/_internals/helpers/DepthContext.ts
diff --git a/src/arbitrary/frequency.ts b/src/arbitrary/frequency.ts
new file mode 100644
index 00000000..8feb0a86
--- /dev/null
+++ b/src/arbitrary/frequency.ts
@@ -0,0 +1,130 @@
+import { Arbitrary } from '../check/arbitrary/definition/Arbitrary';
+import { FrequencyArbitrary } from './_internals/FrequencyArbitrary';
+
+/**
+ * Conjonction of a weight and an arbitrary used by {@link frequency}
+ * in order to generate values
+ *
+ * @remarks Since 1.18.0
+ * @public
+ */
+export interface WeightedArbitrary<T> {
+  /**
+   * Weight to be applied when selecting which arbitrary should be used
+   * @remarks Since 0.0.7
+   */
+  weight: number;
+  /**
+   * Instance of Arbitrary
+   * @remarks Since 0.0.7
+   */
+  arbitrary: Arbitrary<T>;
+}
+
+/**
+ * Infer the type of the Arbitrary produced by {@link frequency}
+ * given the type of the source arbitraries
+ *
+ * @remarks Since 2.2.0
+ * @public
+ */
+export type FrequencyValue<Ts extends WeightedArbitrary<unknown>[]> = {
+  [K in keyof Ts]: Ts[K] extends WeightedArbitrary<infer U> ? U : never;
+}[number];
+
+/**
+ * Constraints to be applied on {@link frequency}
+ * @remarks Since 2.14.0
+ * @public
+ */
+export type FrequencyContraints = {
+  /**
+   * When set to true, the shrinker of frequency will try to check if the first arbitrary
+   * could have been used to discover an issue. It allows to shrink trees.
+   *
+   * Warning: First arbitrary must be the one resulting in the smallest structures
+   * for usages in deep tree-like structures.
+   *
+   * Warning: First arbitrary will not be used if its weight is set to zero.
+   *
+   * @remarks Since 2.14.0
+   */
+  withCrossShrink?: boolean;
+  /**
+   * While going deeper and deeper within a recursive structure (see {@link letrec}),
+   * this factor will be used to increase the probability to generate instances
+   * of the first passed arbitrary.
+   *
+   * Example of values: 0.1 (small impact as depth increases), 0.5, 1 (huge impact as depth increases).
+   *
+   * Warning: First arbitrary will not be used if its weight is set to zero.
+   *
+   * @remarks Since 2.14.0
+   */
+  depthFactor?: number;
+  /**
+   * Maximal authorized depth.
+   * Once this depth has been reached only the first arbitrary will be used.
+   *
+   * Warning: Contrary to others, first arbitrary will be used even if its weight is set to zero.
+   *
+   * @remarks Since 2.14.0
+   */
+  maxDepth?: number;
+  /**
+   * Depth identifier can be used to share the current depth between several instances.
+   *
+   * By default, if not specified, each instance of frequency will have its own depth.
+   * In other words: you can have depth=1 in one while you have depth=100 in another one.
+   *
+   * @remarks Since 2.14.0
+   */
+  depthIdentifier?: string;
+};
+
+/** @internal */
+function isFrequencyContraints(
+  param: FrequencyContraints | WeightedArbitrary<unknown> | undefined
+): param is FrequencyContraints {
+  return param != null && typeof param === 'object' && !('arbitrary' in param);
+}
+
+/**
+ * For one of the values generated by `...warbs` - the probability of selecting the ith warb is of `warb[i].weight / sum(warb[j].weight)`
+ *
+ * **WARNING**: It expects at least one (Arbitrary, weight)
+ *
+ * @param warbs - (Arbitrary, weight)s that might be called to produce a value
+ *
+ * @remarks Since 0.0.7
+ * @public
+ */
+function frequency<Ts extends WeightedArbitrary<unknown>[]>(...warbs: Ts): Arbitrary<FrequencyValue<Ts>>;
+/**
+ * For one of the values generated by `...warbs` - the probability of selecting the ith warb is of `warb[i].weight / sum(warb[j].weight)`
+ *
+ * **WARNING**: It expects at least one (Arbitrary, weight)
+ *
+ * @param constraints - Constraints to be applied when generating the values
+ * @param warbs - (Arbitrary, weight)s that might be called to produce a value
+ *
+ * @remarks Since 0.0.7
+ * @public
+ */
+function frequency<Ts extends WeightedArbitrary<unknown>[]>(
+  constraints: FrequencyContraints,
+  ...warbs: Ts
+): Arbitrary<FrequencyValue<Ts>>;
+function frequency<Ts extends WeightedArbitrary<unknown>[]>(
+  ...args: [...Ts] | [FrequencyContraints, ...Ts]
+): Arbitrary<FrequencyValue<Ts>> {
+  // TODO With TypeScript 4.0 it will be possible to properly define typings for `frequency(...arbs, constraints)`
+  const label = 'fc.frequency';
+  const constraints = args[0];
+  if (isFrequencyContraints(constraints)) {
+    return FrequencyArbitrary.from(args.slice(1) as WeightedArbitrary<FrequencyValue<Ts>>[], constraints, label);
+  }
+
+  return FrequencyArbitrary.from(args as WeightedArbitrary<FrequencyValue<Ts>>[], {}, label);
+}
+export { frequency };
diff --git a/src/check/arbitrary/OneOfArbitrary.ts b/src/arbitrary/oneof.ts
similarity index 96%
rename from src/check/arbitrary/OneOfArbitrary.ts
rename to src/arbitrary/oneof.ts
index be892e75..5a411d2c 100644
--- a/src/check/arbitrary/OneOfArbitrary.ts
+++ b/src/arbitrary/oneof.ts
@@ -1,5 +1,5 @@
-import { Arbitrary } from './definition/Arbitrary';
-import { FrequencyArbitrary } from './FrequencyArbitrary';
+import { Arbitrary } from '../check/arbitrary/definition/Arbitrary';
+import { FrequencyArbitrary } from './_internals/FrequencyArbitrary';
 
 /**
  * Infer the type of the Arbitrary produced by {@link oneof}
@@ -98,5 +98,4 @@ function oneof<Ts extends Arbitrary<unknown>[]>(
   const weightedArbs = (args as Arbitrary<OneOfValue<Ts>>[]).map((arbitrary) => ({ arbitrary, weight: 1 }));
   return FrequencyArbitrary.from(weightedArbs, {}, 'fc.oneof');
 }
-
 export { oneof };
diff --git a/src/check/arbitrary/OptionArbitrary.ts b/src/arbitrary/option.ts
similarity index 92%
rename from src/check/arbitrary/OptionArbitrary.ts
rename to src/arbitrary/option.ts
index c7371253..20bf08c9 100644
--- a/src/check/arbitrary/OptionArbitrary.ts
+++ b/src/arbitrary/option.ts
@@ -1,7 +1,7 @@
-import { FrequencyContraints } from '../../fast-check-default';
-import { constant } from './ConstantArbitrary';
-import { Arbitrary } from './definition/Arbitrary';
-import { FrequencyArbitrary } from './FrequencyArbitrary';
+import { FrequencyContraints } from '../fast-check-default';
+import { constant } from '../check/arbitrary/ConstantArbitrary';
+import { Arbitrary } from '../check/arbitrary/definition/Arbitrary';
+import { FrequencyArbitrary } from './_internals/FrequencyArbitrary';
 
 /**
  * Constraints to be applied on {@link option}
@@ -101,5 +101,4 @@ function option<T, TNil>(arb: Arbitrary<T>, rawConstraints?: number | OptionCons
   };
   return FrequencyArbitrary.from(weightedArbs, frequencyConstraints, 'fc.option');
 }
-
 export { option };
diff --git a/src/check/arbitrary/HostArbitrary.ts b/src/check/arbitrary/HostArbitrary.ts
index 1223abb7..a8f097b0 100644
--- a/src/check/arbitrary/HostArbitrary.ts
+++ b/src/check/arbitrary/HostArbitrary.ts
@@ -4,7 +4,7 @@ import {
   buildLowerAlphaArb,
   buildLowerAlphaNumericArb,
 } from './helpers/SpecificCharacterRange';
-import { option } from './OptionArbitrary';
+import { option } from '../../arbitrary/option';
 import { stringOf } from './StringArbitrary';
 import { tuple } from './TupleArbitrary';
 import { Arbitrary } from './definition/Arbitrary';
diff --git a/src/check/arbitrary/IpArbitrary.ts b/src/check/arbitrary/IpArbitrary.ts
index 594772fa..6303d4a6 100644
--- a/src/check/arbitrary/IpArbitrary.ts
+++ b/src/check/arbitrary/IpArbitrary.ts
@@ -2,7 +2,7 @@ import { array } from '../../arbitrary/array';
 import { constantFrom } from './ConstantArbitrary';
 import { Arbitrary } from './definition/Arbitrary';
 import { nat } from '../../arbitrary/nat';
-import { oneof } from './OneOfArbitrary';
+import { oneof } from '../../arbitrary/oneof';
 import { hexaString } from './StringArbitrary';
 import { tuple } from './TupleArbitrary';
 
diff --git a/src/check/arbitrary/LoremArbitrary.ts b/src/check/arbitrary/LoremArbitrary.ts
index 57e05e71..bc6488cb 100644
--- a/src/check/arbitrary/LoremArbitrary.ts
+++ b/src/check/arbitrary/LoremArbitrary.ts
@@ -1,7 +1,7 @@
 import { array } from '../../arbitrary/array';
 import { constant } from './ConstantArbitrary';
 import { Arbitrary } from './definition/Arbitrary';
-import { frequency } from './FrequencyArbitrary';
+import { frequency } from '../../arbitrary/frequency';
 
 /**
  * Constraints to be applied on {@link lorem}
diff --git a/src/check/arbitrary/ObjectArbitrary.ts b/src/check/arbitrary/ObjectArbitrary.ts
index ee1dd279..e377b260 100644
--- a/src/check/arbitrary/ObjectArbitrary.ts
+++ b/src/check/arbitrary/ObjectArbitrary.ts
@@ -6,10 +6,10 @@ import { boolean } from './BooleanArbitrary';
 import { constant } from './ConstantArbitrary';
 import { dictionary, toObject } from './DictionaryArbitrary';
 import { double } from './FloatingPointArbitrary';
-import { frequency } from './FrequencyArbitrary';
+import { frequency } from '../../arbitrary/frequency';
 import { maxSafeInteger } from '../../arbitrary/maxSafeInteger';
 import { memo, Memo } from './MemoArbitrary';
-import { oneof } from './OneOfArbitrary';
+import { oneof } from '../../arbitrary/oneof';
 import { set } from '../../arbitrary/set';
 import { string, unicodeString } from './StringArbitrary';
 import { tuple } from './TupleArbitrary';
diff --git a/src/check/arbitrary/RecordArbitrary.ts b/src/check/arbitrary/RecordArbitrary.ts
index 1174db5b..8733d48a 100644
--- a/src/check/arbitrary/RecordArbitrary.ts
+++ b/src/check/arbitrary/RecordArbitrary.ts
@@ -1,6 +1,6 @@
 import { Arbitrary } from './definition/Arbitrary';
 
-import { option } from './OptionArbitrary';
+import { option } from '../../arbitrary/option';
 import { genericTuple } from './TupleArbitrary';
 
 /**
diff --git a/src/check/arbitrary/WebArbitrary.ts b/src/check/arbitrary/WebArbitrary.ts
index cf2ffa4f..0f104bd8 100644
--- a/src/check/arbitrary/WebArbitrary.ts
+++ b/src/check/arbitrary/WebArbitrary.ts
@@ -5,8 +5,8 @@ import { buildAlphaNumericPercentArb } from './helpers/SpecificCharacterRange';
 import { domain, hostUserInfo } from './HostArbitrary';
 import { nat } from '../../arbitrary/nat';
 import { ipV4, ipV4Extended, ipV6 } from './IpArbitrary';
-import { oneof } from './OneOfArbitrary';
-import { option } from './OptionArbitrary';
+import { oneof } from '../../arbitrary/oneof';
+import { option } from '../../arbitrary/option';
 import { stringOf } from './StringArbitrary';
 import { tuple } from './TupleArbitrary';
 import { Arbitrary } from './definition/Arbitrary';
diff --git a/src/check/arbitrary/helpers/SpecificCharacterRange.ts b/src/check/arbitrary/helpers/SpecificCharacterRange.ts
index 0c84f555..64924632 100644
--- a/src/check/arbitrary/helpers/SpecificCharacterRange.ts
+++ b/src/check/arbitrary/helpers/SpecificCharacterRange.ts
@@ -1,6 +1,6 @@
 import { fullUnicode } from '../CharacterArbitrary';
 import { Arbitrary } from '../definition/Arbitrary';
-import { frequency } from '../FrequencyArbitrary';
+import { frequency } from '../../../arbitrary/frequency';
 import { mapToConstant } from '../MapToConstantArbitrary';
 
 /** @internal */
diff --git a/src/check/model/commands/CommandsArbitrary.ts b/src/check/model/commands/CommandsArbitrary.ts
index b7405002..debf7ab1 100644
--- a/src/check/model/commands/CommandsArbitrary.ts
+++ b/src/check/model/commands/CommandsArbitrary.ts
@@ -4,7 +4,7 @@ import { Arbitrary } from '../../arbitrary/definition/Arbitrary';
 import { ArbitraryWithContextualShrink } from '../../arbitrary/definition/ArbitraryWithContextualShrink';
 import { Shrinkable } from '../../arbitrary/definition/Shrinkable';
 import { nat } from '../../../arbitrary/nat';
-import { oneof } from '../../arbitrary/OneOfArbitrary';
+import { oneof } from '../../../arbitrary/oneof';
 import { AsyncCommand } from '../command/AsyncCommand';
 import { Command } from '../command/Command';
 import { ICommand } from '../command/ICommand';
diff --git a/src/fast-check-default.ts b/src/fast-check-default.ts
index 1234934c..b8e58fe9 100644
--- a/src/fast-check-default.ts
+++ b/src/fast-check-default.ts
@@ -37,12 +37,7 @@ import { Shrinkable } from './check/arbitrary/definition/Shrinkable';
 import { dictionary } from './check/arbitrary/DictionaryArbitrary';
 import { emailAddress } from './check/arbitrary/EmailArbitrary';
 import { double, float, DoubleConstraints, FloatConstraints } from './check/arbitrary/FloatingPointArbitrary';
-import {
-  frequency,
-  WeightedArbitrary,
-  FrequencyValue,
-  FrequencyContraints,
-} from './check/arbitrary/FrequencyArbitrary';
+import { frequency, WeightedArbitrary, FrequencyValue, FrequencyContraints } from './arbitrary/frequency';
 import { compareBooleanFunc, compareFunc, func } from './check/arbitrary/FunctionArbitrary';
 import { domain } from './check/arbitrary/HostArbitrary';
 import { integer, IntegerConstraints } from './arbitrary/integer';
@@ -65,8 +60,8 @@ import {
   unicodeJson,
   unicodeJsonObject,
 } from './check/arbitrary/ObjectArbitrary';
-import { oneof, OneOfValue, OneOfConstraints } from './check/arbitrary/OneOfArbitrary';
-import { option, OptionConstraints } from './check/arbitrary/OptionArbitrary';
+import { oneof, OneOfValue, OneOfConstraints } from './arbitrary/oneof';
+import { option, OptionConstraints } from './arbitrary/option';
 import { record, RecordConstraints, RecordValue } from './check/arbitrary/RecordArbitrary';
 import { set, SetConstraints } from './arbitrary/set';
 import { infiniteStream } from './check/arbitrary/StreamArbitrary';


Test patch:
diff --git a/test/esm/esbuild-with-require/package.json b/test/esm/esbuild-with-require/package.json
index 2f481578..1fe07271 100644
--- a/test/esm/esbuild-with-require/package.json
+++ b/test/esm/esbuild-with-require/package.json
@@ -10,7 +10,7 @@
     "fast-check": "*"
   },
   "devDependencies": {
-    "esbuild": "^0.11.8"
+    "esbuild": "^0.11.9"
   },
   "license": "MIT",
   "private": true
diff --git a/test/esm/esbuild-with-require/yarn.lock b/test/esm/esbuild-with-require/yarn.lock
index 1d321836..2dc091be 100644
--- a/test/esm/esbuild-with-require/yarn.lock
+++ b/test/esm/esbuild-with-require/yarn.lock
@@ -2,10 +2,10 @@
 # yarn lockfile v1
 
 
-esbuild@^0.11.8:
-  version "0.11.8"
-  resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.11.8.tgz#dcab565c3a61f2395aba37a78e93d5ab882bd865"
-  integrity sha512-dUZj5etA0e+SChqRMswgUj8TAj5ay7z06/BD32t0pRWgMDh8S/NTW7e7O1jLVIDeAECsRXkIzG2o+jpBwchq7w==
+esbuild@^0.11.9:
+  version "0.11.9"
+  resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.11.9.tgz#408bf4fb5ae9abc2f27d56b62e19aab697687975"
+  integrity sha512-qP7w/oWjJBIh9x+H37DbpkMtmSnLm63VDyA06+vkJJEHlVR7QSDiPAaka7mtMQZHoBn87irUx5rDxbXMKaf8xw==
 
 fast-check@*:
   version "2.13.0"
diff --git a/test/unit/check/arbitrary/FrequencyArbitrary.itest.spec.ts b/test/unit/arbitrary/FrequencyArbitrary.itest.spec.ts
similarity index 91%
rename from test/unit/check/arbitrary/FrequencyArbitrary.itest.spec.ts
rename to test/unit/arbitrary/FrequencyArbitrary.itest.spec.ts
index b38b4a6d..d1cb00ea 100644
--- a/test/unit/check/arbitrary/FrequencyArbitrary.itest.spec.ts
+++ b/test/unit/arbitrary/FrequencyArbitrary.itest.spec.ts
@@ -1,14 +1,14 @@
-import * as fc from '../../../../lib/fast-check';
+import * as fc from '../../../lib/fast-check';
 
-import { frequency } from '../../../../src/check/arbitrary/FrequencyArbitrary';
-import { integer } from '../../../../src/arbitrary/integer';
-import { constant } from '../../../../src/check/arbitrary/ConstantArbitrary';
+import { frequency } from '../../../src/arbitrary/frequency';
+import { integer } from '../../../src/arbitrary/integer';
+import { constant } from '../../../src/check/arbitrary/ConstantArbitrary';
 
-import * as genericHelper from './generic/GenericArbitraryHelper';
+import * as genericHelper from '../check/arbitrary/generic/GenericArbitraryHelper';
 
 import { mocked } from 'ts-jest/utils';
-import * as DepthContextMock from '../../../../src/check/arbitrary/helpers/DepthContext';
-jest.mock('../../../../src/check/arbitrary/helpers/DepthContext');
+import * as DepthContextMock from '../../../src/arbitrary/_internals/helpers/DepthContext';
+jest.mock('../../../src/arbitrary/_internals/helpers/DepthContext');
 
 const depthContextData: Record<string, DepthContextMock.DepthContext> = {};
 
diff --git a/test/unit/check/arbitrary/FrequencyArbitrary.utest.spec.ts b/test/unit/arbitrary/FrequencyArbitrary.utest.spec.ts
similarity index 96%
rename from test/unit/check/arbitrary/FrequencyArbitrary.utest.spec.ts
rename to test/unit/arbitrary/FrequencyArbitrary.utest.spec.ts
index ea681456..ea30f71b 100644
--- a/test/unit/check/arbitrary/FrequencyArbitrary.utest.spec.ts
+++ b/test/unit/arbitrary/FrequencyArbitrary.utest.spec.ts
@@ -1,11 +1,11 @@
-import * as fc from '../../../../lib/fast-check';
+import * as fc from '../../../lib/fast-check';
 
-import { Arbitrary } from '../../../../src/check/arbitrary/definition/Arbitrary';
-import { Shrinkable } from '../../../../src/check/arbitrary/definition/Shrinkable';
-import { frequency } from '../../../../src/check/arbitrary/FrequencyArbitrary';
-import { Random } from '../../../../src/random/generator/Random';
+import { Arbitrary } from '../../../src/check/arbitrary/definition/Arbitrary';
+import { Shrinkable } from '../../../src/check/arbitrary/definition/Shrinkable';
+import { frequency } from '../../../src/arbitrary/frequency';
+import { Random } from '../../../src/random/generator/Random';
 
-import * as stubArb from '../../stubs/arbitraries';
+import * as stubArb from '../stubs/arbitraries';
 
 const frequencyValidInputsArb = fc
   .tuple(
diff --git a/test/unit/check/arbitrary/OneOfArbitrary.itest.spec.ts b/test/unit/arbitrary/OneOfArbitrary.itest.spec.ts
similarity index 75%
rename from test/unit/check/arbitrary/OneOfArbitrary.itest.spec.ts
rename to test/unit/arbitrary/OneOfArbitrary.itest.spec.ts
index 9a133f82..4729f509 100644
--- a/test/unit/check/arbitrary/OneOfArbitrary.itest.spec.ts
+++ b/test/unit/arbitrary/OneOfArbitrary.itest.spec.ts
@@ -1,16 +1,16 @@
-import * as fc from '../../../../lib/fast-check';
+import * as fc from '../../../lib/fast-check';
 
-import { Arbitrary } from '../../../../src/check/arbitrary/definition/Arbitrary';
-import { Shrinkable } from '../../../../src/check/arbitrary/definition/Shrinkable';
-import { constant } from '../../../../src/check/arbitrary/ConstantArbitrary';
-import { integer } from '../../../../src/arbitrary/integer';
-import { oneof } from '../../../../src/check/arbitrary/OneOfArbitrary';
-import { Random } from '../../../../src/random/generator/Random';
-import { stream } from '../../../../src/stream/Stream';
+import { Arbitrary } from '../../../src/check/arbitrary/definition/Arbitrary';
+import { Shrinkable } from '../../../src/check/arbitrary/definition/Shrinkable';
+import { constant } from '../../../src/check/arbitrary/ConstantArbitrary';
+import { integer } from '../../../src/arbitrary/integer';
+import { oneof } from '../../../src/arbitrary/oneof';
+import { Random } from '../../../src/random/generator/Random';
+import { stream } from '../../../src/stream/Stream';
 
-import * as genericHelper from './generic/GenericArbitraryHelper';
+import * as genericHelper from '../check//arbitrary/generic/GenericArbitraryHelper';
 
-import * as stubRng from '../../stubs/generators';
+import * as stubRng from '../stubs/generators';
 
 class CustomArbitrary extends Arbitrary<number> {
   constructor(readonly value: number) {
diff --git a/test/unit/check/arbitrary/OneOfArbitrary.utest.spec.ts b/test/unit/arbitrary/OneOfArbitrary.utest.spec.ts
similarity index 84%
rename from test/unit/check/arbitrary/OneOfArbitrary.utest.spec.ts
rename to test/unit/arbitrary/OneOfArbitrary.utest.spec.ts
index beb2bebc..27eee63b 100644
--- a/test/unit/check/arbitrary/OneOfArbitrary.utest.spec.ts
+++ b/test/unit/arbitrary/OneOfArbitrary.utest.spec.ts
@@ -1,10 +1,10 @@
 import { mocked } from 'ts-jest/utils';
 
-import { constant } from '../../../../src/check/arbitrary/ConstantArbitrary';
-import { oneof, OneOfConstraints } from '../../../../src/check/arbitrary/OneOfArbitrary';
+import { constant } from '../../../src/check/arbitrary/ConstantArbitrary';
+import { oneof, OneOfConstraints } from '../../../src/arbitrary/oneof';
 
-import * as FrequencyArbitraryMock from '../../../../src/check/arbitrary/FrequencyArbitrary';
-jest.mock('../../../../src/check/arbitrary/FrequencyArbitrary');
+import * as FrequencyArbitraryMock from '../../../src/arbitrary/_internals/FrequencyArbitrary';
+jest.mock('../../../src/arbitrary/_internals/FrequencyArbitrary');
 
 describe('OneOfArbitrary', () => {
   describe('oneof', () => {
diff --git a/test/unit/check/arbitrary/OptionArbitrary.spec.ts b/test/unit/arbitrary/OptionArbitrary.spec.ts
similarity index 84%
rename from test/unit/check/arbitrary/OptionArbitrary.spec.ts
rename to test/unit/arbitrary/OptionArbitrary.spec.ts
index 6a6e9e0e..e49d501a 100644
--- a/test/unit/check/arbitrary/OptionArbitrary.spec.ts
+++ b/test/unit/arbitrary/OptionArbitrary.spec.ts
@@ -1,11 +1,11 @@
 import * as prand from 'pure-rand';
-import * as fc from '../../../../lib/fast-check';
+import * as fc from '../../../lib/fast-check';
 
-import { option } from '../../../../src/check/arbitrary/OptionArbitrary';
-import { Random } from '../../../../src/random/generator/Random';
+import { option } from '../../../src/arbitrary/option';
+import { Random } from '../../../src/random/generator/Random';
 
-import * as stubArb from '../../stubs/arbitraries';
-import * as stubRng from '../../stubs/generators';
+import * as stubArb from '../stubs/arbitraries';
+import * as stubRng from '../stubs/generators';
 
 describe('OptionArbitrary', () => {
   describe('option', () => {
diff --git a/test/unit/check/arbitrary/ObjectArbitrary.spec.ts b/test/unit/check/arbitrary/ObjectArbitrary.spec.ts
index 63818d96..5645425f 100644
--- a/test/unit/check/arbitrary/ObjectArbitrary.spec.ts
+++ b/test/unit/check/arbitrary/ObjectArbitrary.spec.ts
@@ -2,7 +2,7 @@ import * as prand from 'pure-rand';
 import * as fc from '../../../../lib/fast-check';
 
 import { constant } from '../../../../src/check/arbitrary/ConstantArbitrary';
-import { oneof } from '../../../../src/check/arbitrary/OneOfArbitrary';
+import { oneof } from '../../../../src/arbitrary/oneof';
 import {
   anything,
   object,