basura - v4.1.0
    Preparing search index...

    Class Basura

    Create garbage javascript types for testing.

    Index

    Constructors

    • Create some Basura.

      Parameters

      • Optionalopts: {
            arrayLength?: number;
            cborSafe?: boolean;
            depth?: number;
            edgeFreq?: number;
            fakeSymbols?: boolean;
            jsonSafe?: boolean;
            noBoxed?: boolean;
            output?: boolean;
            randBytes?: RandBytes;
            scripts?: string[];
            stringLength?: number;
            types?: Record<string, BasuraGenerator<unknown>>;
        } = {}

        Options.

        • OptionalarrayLength?: number

          Maximum size of arrays and objects.

        • OptionalcborSafe?: boolean

          Generate only CBOR-safe types?

        • Optionaldepth?: number

          Maximum depth of object to create.

        • OptionaledgeFreq?: number

          How often do edge cases happen (0-1)?

        • OptionalfakeSymbols?: boolean

          Instead of generating symbols, generate an object that will inspect as Symbol.for('string').

        • OptionaljsonSafe?: boolean

          Generate only JSON-safe types?

        • OptionalnoBoxed?: boolean

          Ignore boxed types, like String?

        • Optionaloutput?: boolean

          Add custom inspect functions that make output parseable JS?

        • OptionalrandBytes?: RandBytes

          Randomness source. Defaults to a thin wrapper around crypto.randomBytes.

        • Optionalscripts?: string[]

          List of script names to select from for generating strings. Defaults to all Unicode scripts from data.json.

        • OptionalstringLength?: number

          Maximum size of generated strings. (in codepoints), BigInts (in bytes), and buffers (in bytes).

        • Optionaltypes?: 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.

      Returns Basura

    Properties

    annotations: [string, ...MethodDecorator[]][] = ...
    ErrorConstructors: (ErrorConstructor | AggregateErrorConstructor)[]
    functionSpecies: string[]
    funNumbers: number[]
    opts: {
        arrayLength: number;
        catchUnhandled: boolean;
        cborSafe: boolean;
        depth: number;
        edgeFreq: number;
        fakeSymbols: boolean;
        jsonSafe: boolean;
        noBoxed: boolean;
        output: boolean;
        randBytes: RandBytes;
        scripts: any;
        stringLength: number;
        types: Record<string, BasuraGenerator<unknown>>;
    }
    typedArrays: (
        | ArrayBufferConstructor
        | DataViewConstructor
        | Int8ArrayConstructor
        | Uint8ArrayConstructor
        | Uint8ClampedArrayConstructor
        | Int16ArrayConstructor
        | Uint16ArrayConstructor
        | Int32ArrayConstructor
        | Uint32ArrayConstructor
        | Float32ArrayConstructor
        | Float64ArrayConstructor
        | SharedArrayBufferConstructor
        | BigInt64ArrayConstructor
        | BigUint64ArrayConstructor
    )[]
    typeNames: string[]
    types: Record<string, BasuraGenerator<unknown>>
    validWeak: string[]
    weakMembers: WeakMap<any, any[]>

    Methods

    • Generate a random type that this object currently supports. Returns null if we're already too deep.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns any

      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.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns any[]

      Generated array.

    • Generate a random BigInt of up to stringLength bytes.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns bigint

      Generated BigInt, possibly negative.

    • Generate boolean.

      Parameters

      • Optional_depth: number = 0

        How deep are we in the generated tree of objects already?

      • Optionalreason: string = 'boolean'

        Reason for generating bool.

      Returns boolean

      True or false.

    • Generate boxed Boolean.

      Parameters

      • Optional_depth: number = 0

        How deep are we in the generated tree of objects already?

      Returns boolean

      New Boolean(true) or new Boolean(false).

    • Generate a Buffer of up to stringLength size.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns Buffer<ArrayBufferLike>

      NodeJS Buffer.

    • Generate a random Date, gaussian-distributed around today with a standard deviation of 10 years.

      Parameters

      • Optional_depth: number = 0

        How deep are we in the generated tree of objects already?

      Returns Date

      Generated Date.

    • Generate a random Error. If an AggregateError is selected, fill it with random Errors.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns Error

      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 () => {}.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns Function

      Generated function.

    • Generate a generator that yields basura.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns Generator<any, any, any>

      Generated.

    • Generate signed 32-bit integer. Note: may be folded into generate_number later.

      Parameters

      • Optional_depth: number = 0

        How deep are we in the generated tree of objects already?

      Returns number

      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.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns Map<any, any>

      Generated Map.

    • Generate 64-bit floating point number, with a 10% chance of something "fun": 0, -0, NaN, Infinity, -Infinity.

      Parameters

      • Optional_depth: number = 0

        How deep are we in the generated tree of objects already?

      Returns number

      Number or edge case.

    • Generate boxed 64-bit floating point Number, with a 10% chance of something "fun": 0, -0, NaN, Infinity, -Infinity.

      Parameters

      • Optional_depth: number = 0

        How deep are we in the generated tree of objects already?

      Returns number

      Wrapped new Number(num).

    • Generate a random object with up to arrayLength properties. Will generate null (an Object!) if we are too deep already.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns any

      Object or null.

    • Generate a rejected or resolved promise.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns Promise<any>

      Resolved or rejected promise.

    • Generate a Proxy over a random object. If we are already too deep, generates a Proxy around {}.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns ProxyConstructor

      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.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns RegExp

      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.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns Set<any>

      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.

      Parameters

      • Optional_depth: number = 0

        How deep are we in the generated tree of objects already?

      • Optionalreason: string = 'string'

        Reason for generation, since this function is called by others.

      Returns string

      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.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns string

      Wrapped new String().

    • Generate a symbol from a random string. This will intern the Symbol with Symbol.for to make testing possible.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns symbol | FakeSymbol

      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.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns
          | ArrayBuffer
          | SharedArrayBuffer
          | DataView<ArrayBufferLike>
          | Int8Array<ArrayBufferLike>
          | Uint8Array<ArrayBufferLike>
          | Uint8ClampedArray<ArrayBufferLike>
          | Int16Array<ArrayBufferLike>
          | Uint16Array<ArrayBufferLike>
          | Int32Array<ArrayBufferLike>
          | Uint32Array<ArrayBufferLike>
          | Float32Array<ArrayBufferLike>
          | Float64Array<ArrayBufferLike>
          | BigInt64Array<ArrayBufferLike>
          | BigUint64Array<ArrayBufferLike>

      Generated TypedArray.

    • Generate undefined.

      Parameters

      • Optional_depth: number = 0

        How deep are we in the generated tree of objects already?

      Returns undefined

      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.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns URL

      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.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns WeakMap<any, any>

      Generated.

    • Parameters

      • depth: number = 0

      Returns WeakRef<any>

    • Generate a WeakSet containing 0 or more sub-items of any valid type.

      Parameters

      • Optionaldepth: number = 0

        How deep are we in the generated tree of objects already?

      Returns WeakSet<any>

      Generated.