declare module 'safe-buffer' {
  export class Buffer {
    public length: number
    public write(string: string, offset?: number, length?: number, encoding?: string): number;
    public toString(encoding?: string, start?: number, end?: number): string;
    public toJSON(): { type: 'Buffer', data: any[] };
    public equals(otherBuffer: Buffer): boolean;
    public compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
    public copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
    public slice(start?: number, end?: number): Buffer;
    public writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
    public writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
    public writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
    public writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
    public readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
    public readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
    public readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
    public readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
    public readUInt8(offset: number, noAssert?: boolean): number;
    public readUInt16LE(offset: number, noAssert?: boolean): number;
    public readUInt16BE(offset: number, noAssert?: boolean): number;
    public readUInt32LE(offset: number, noAssert?: boolean): number;
    public readUInt32BE(offset: number, noAssert?: boolean): number;
    public readInt8(offset: number, noAssert?: boolean): number;
    public readInt16LE(offset: number, noAssert?: boolean): number;
    public readInt16BE(offset: number, noAssert?: boolean): number;
    public readInt32LE(offset: number, noAssert?: boolean): number;
    public readInt32BE(offset: number, noAssert?: boolean): number;
    public readFloatLE(offset: number, noAssert?: boolean): number;
    public readFloatBE(offset: number, noAssert?: boolean): number;
    public readDoubleLE(offset: number, noAssert?: boolean): number;
    public readDoubleBE(offset: number, noAssert?: boolean): number;
    public swap16(): Buffer;
    public swap32(): Buffer;
    public swap64(): Buffer;
    public writeUInt8(value: number, offset: number, noAssert?: boolean): number;
    public writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
    public writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
    public writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
    public writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
    public writeInt8(value: number, offset: number, noAssert?: boolean): number;
    public writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
    public writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
    public writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
    public writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
    public writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
    public writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
    public writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
    public writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
    public fill(value: any, offset?: number, end?: number): this;
    public indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
    public lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
    public includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean;

    /**
     * Allocates a new buffer containing the given {str}.
     *
     * @param str String to store in buffer.
     * @param encoding encoding to use, optional.  Default is 'utf8'
     */
     constructor (str: string, encoding?: string);
    /**
     * Allocates a new buffer of {size} octets.
     *
     * @param size count of octets to allocate.
     */
    constructor (size: number);
    /**
     * Allocates a new buffer containing the given {array} of octets.
     *
     * @param array The octets to store.
     */
    constructor (array: Uint8Array);
    /**
     * Produces a Buffer backed by the same allocated memory as
     * the given {ArrayBuffer}.
     *
     *
     * @param arrayBuffer The ArrayBuffer with which to share memory.
     */
    constructor (arrayBuffer: ArrayBuffer);
    /**
     * Allocates a new buffer containing the given {array} of octets.
     *
     * @param array The octets to store.
     */
    constructor (array: any[]);
    /**
     * Copies the passed {buffer} data onto a new {Buffer} instance.
     *
     * @param buffer The buffer to copy.
     */
    constructor (buffer: Buffer);
    public prototype: Buffer;
    /**
     * Allocates a new Buffer using an {array} of octets.
     *
     * @param array
     */
    public static from(array: any[]): Buffer;
    /**
     * When passed a reference to the .buffer property of a TypedArray instance,
     * the newly created Buffer will share the same allocated memory as the TypedArray.
     * The optional {byteOffset} and {length} arguments specify a memory range
     * within the {arrayBuffer} that will be shared by the Buffer.
     *
     * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
     * @param byteOffset
     * @param length
     */
    public static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
    /**
     * Copies the passed {buffer} data onto a new Buffer instance.
     *
     * @param buffer
     */
    public static from(buffer: Buffer): Buffer;
    /**
     * Creates a new Buffer containing the given JavaScript string {str}.
     * If provided, the {encoding} parameter identifies the character encoding.
     * If not provided, {encoding} defaults to 'utf8'.
     *
     * @param str
     */
    public static from(str: string, encoding?: string): Buffer;
    /**
     * Returns true if {obj} is a Buffer
     *
     * @param obj object to test.
     */
    public static isBuffer(obj: any): obj is Buffer;
    /**
     * Returns true if {encoding} is a valid encoding argument.
     * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
     *
     * @param encoding string to test.
     */
    public static isEncoding(encoding: string): boolean;
    /**
     * Gives the actual byte length of a string. encoding defaults to 'utf8'.
     * This is not the same as String.prototype.length since that returns the number of characters in a string.
     *
     * @param string string to test.
     * @param encoding encoding used to evaluate (defaults to 'utf8')
     */
    public static byteLength(string: string, encoding?: string): number;
    /**
     * Returns a buffer which is the result of concatenating all the buffers in the list together.
     *
     * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
     * If the list has exactly one item, then the first item of the list is returned.
     * If the list has more than one item, then a new Buffer is created.
     *
     * @param list An array of Buffer objects to concatenate
     * @param totalLength Total length of the buffers when concatenated.
     *   If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
     */
    public static concat(list: Buffer[], totalLength?: number): Buffer;
    /**
     * The same as buf1.compare(buf2).
     */
    public static compare(buf1: Buffer, buf2: Buffer): number;
    /**
     * Allocates a new buffer of {size} octets.
     *
     * @param size count of octets to allocate.
     * @param fill if specified, buffer will be initialized by calling buf.fill(fill).
     *    If parameter is omitted, buffer will be filled with zeros.
     * @param encoding encoding used for call to buf.fill while initalizing
     */
    public static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer;
    /**
     * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
     * of the newly created Buffer are unknown and may contain sensitive data.
     *
     * @param size count of octets to allocate
     */
    public static allocUnsafe(size: number): Buffer;
    /**
     * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
     * of the newly created Buffer are unknown and may contain sensitive data.
     *
     * @param size count of octets to allocate
     */
    public static allocUnsafeSlow(size: number): Buffer;
  }
}