@types/secure-random
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

Installation

npm install --save @types/secure-random

Summary

This package contains type definitions for secure-random (https://github.com/jprichardson/secure-random).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/secure-random.

index.d.ts

/// <reference types="node" />

type TypeName = "Array" | "Buffer" | "Uint8Array";

type ObjectType<T> = T extends "Array" ? number[]
    : T extends "Buffer" ? Buffer
    : T extends "Uint8Array" ? Uint8Array
    : never;

declare namespace secureRandom {
    /**
     * Sugar for secureRandom(byteCount, {type: 'Array'}).
     * @param byteCount is the number of bytes to return.
     */
    function randomArray(byteCount: number): number[];

    /**
     * Sugar for secureRandom(byteCount, {type: 'Uint8Array'}).
     * @param byteCount is the number of bytes to return.
     */
    function randomUint8Array(byteCount: number): Uint8Array;

    /**
     * Sugar for secureRandom(byteCount, {type: 'Buffer'}).
     * @param byteCount is the number of bytes to return.
     */
    function randomBuffer(byteCount: number): Buffer;
}

export = secureRandom;

/**
 * Sugar for secureRandom(byteCount, {type: 'Buffer'}).
 * @param byteCount is the number of bytes to return.
 * @param options options to pass.
 *                Only valid value at this time type.
 *                type can be either Array, Uint8Array, or Buffer.
 *                Buffer is only valid in Node.js or Browserify environments - it will throw an error otherwise.
 */
declare function secureRandom<T extends TypeName>(byteCount: number, options: { type: T }): ObjectType<T>;

Additional Details

  • Last updated: Tue, 07 Nov 2023 15:11:36 GMT
  • Dependencies: @types/node

Credits

These definitions were written by Teun Verhaert.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/secure-random

Weekly Downloads

11,676

Version

1.1.3

License

MIT

Unpacked Size

5.38 kB

Total Files

5

Last publish

Collaborators

  • types