Create some Basura.
Optional
opts: {Options.
Optional
arrayLength?: numberMaximum size of arrays and objects.
Optional
cborSafe?: booleanGenerate only CBOR-safe types?
Optional
depth?: numberMaximum depth of object to create.
Optional
edgeFreq?: numberHow often do edge cases happen (0-1)?
Optional
fakeSymbols?: booleanInstead of generating symbols, generate an object that will inspect as Symbol.for('string').
Optional
jsonSafe?: booleanGenerate only JSON-safe types?
Optional
noBoxed?: booleanIgnore boxed types, like String?
Optional
output?: booleanAdd custom inspect functions that make output parseable JS?
Optional
randBytes?: RandBytesRandomness
source. Defaults to a thin wrapper around
crypto.randomBytes
.
Optional
scripts?: string[]List of script names to select from for generating strings. Defaults to all Unicode scripts from data.json.
Optional
stringLength?: numberMaximum size of generated strings. (in codepoints), BigInts (in bytes), and buffers (in bytes).
Optional
types?: Record<string, BasuraGenerator<unknown>>Additional types. The key is the type name, the value is a function used to generate, or null to prevent that type from being generated.
Static
annotationsGenerate a random type that this object currently supports. Returns null if we're already too deep.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Might generate... Anything!
Generate an Array of up to arrayLength size, with each element of the
array being generated from the list of types this object currently
supports. Generates an empty array ([]
) if we're too deep already.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Generated array.
Generate a random BigInt of up to stringLength bytes.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Generated BigInt, possibly negative.
Generate boolean.
Optional
_depth: number = 0How deep are we in the generated tree of objects already?
Optional
reason: string = 'boolean'Reason for generating bool.
True or false.
Generate boxed Boolean.
Optional
_depth: number = 0How deep are we in the generated tree of objects already?
New Boolean(true) or new Boolean(false).
Generate a Buffer
of up
to stringLength size.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
NodeJS Buffer.
Generate a random Date, gaussian-distributed around today with a standard deviation of 10 years.
Optional
_depth: number = 0How deep are we in the generated tree of objects already?
Generated Date.
Generate a random Error. If an AggregateError is selected, fill it with random Errors.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Generated Error.
Generate a function of a random "species". The current species list is
stored in this.functionSpecies. See
tutorial
for more information. If we are already too deep, generates () => {}
.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Generated function.
Generate a generator that yields basura.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Generated.
Generate signed 32-bit integer. Note: may be folded into generate_number later.
Optional
_depth: number = 0How deep are we in the generated tree of objects already?
32-bit integer.
Generate a random Map with up to arrayLength elements. If we are too deep already, will generate an empty Map. Each key and value will be of a random type currently supported by this object.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Generated Map.
Generate 64-bit floating point number, with a 10% chance of something "fun": 0, -0, NaN, Infinity, -Infinity.
Optional
_depth: number = 0How deep are we in the generated tree of objects already?
Number or edge case.
Generate boxed 64-bit floating point Number, with a 10% chance of something "fun": 0, -0, NaN, Infinity, -Infinity.
Optional
_depth: number = 0How deep are we in the generated tree of objects already?
Wrapped new Number(num).
Generate a random object with up to arrayLength properties. Will generate null (an Object!) if we are too deep already.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Object or null.
Generate a rejected or resolved promise.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Resolved or rejected promise.
Generate a Proxy over a random object. If we are already too deep,
generates a Proxy around {}
.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Plain object in output mode, otherwise Proxy.
Generate a regular expression of up to stringLength size, all from the same random Unicode script. The first codepoint will not be a combining character.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Generated regexp.
Generate a Set of random things, with length up to arrayLength, and each element being any one of the types this object currently supports. If we are already too deep, generates an empty set.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Generated Set.
Generate a string of up to stringLength size, all from the same random Unicode script. The first codepoint will not be a combining character.
Optional
_depth: number = 0How deep are we in the generated tree of objects already?
Optional
reason: string = 'string'Reason for generation, since this function is called by others.
Generated string.
Generate a boxed String of up to stringLength size, all from the same random Unicode script. The first codepoint will not be a combining character.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Wrapped new String().
Generate a symbol from a random string. This will intern the Symbol with Symbol.for to make testing possible.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Generated Symbol.
Generate one of the TypedArrays, ArrayBuffer, SharedArrayBuffer, or DataView of arrayLength elements. If we're too deep already, generate an array with length 0.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Generated TypedArray.
Generate undefined.
Optional
_depth: number = 0How deep are we in the generated tree of objects already?
Always returns undefined.
Generate a URL object where each component can be up to stringLength size, and each component is all from the same random Unicode script. The top-level domain (TLD) name will be valid, and the preceding domain label will be from the same script as the TLD.
However, that means you'll see a lot of Punycode, thanks to the way that the URL class works.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Generated punycode URL.
Generate a WeakMap containing 0 or more key/value pairs where the keys are valid weak items, and the values can be any valid type.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Generated.
Generate a WeakSet containing 0 or more sub-items of any valid type.
Optional
depth: number = 0How deep are we in the generated tree of objects already?
Generated.
Create garbage javascript types for testing.