node-ctypes - v2.10.0
    Preparing search index...

    Interface ArrayTypeDef<E>

    An array type definition created by the array function.

    Python equivalent: c_int * 5. Call it (with or without new) with the initial elements, as Python's (c_int * 5)(1, 2, 3).

    const IntArray5 = array(c_int32, 5);
    const arr = IntArray5(1, 2, 3, 4, 5); // or IntArray5.create([1, 2, 3, 4, 5])
    console.log(arr[0]); // 1
    interface ArrayTypeDef<E = any> {
        new ArrayTypeDef(...values: ArrayElementArg<E>[]): ArrayInstance<E>;
        elementType:
            | AnyType
            | StructureClass
            | ArrayTypeDef<any>
            | PointerTypeDef<any>
            | FuncPtrFactory<FFIType, readonly FFIType[]>;
        length: number;
        getSize(): number;
        getLength(): number;
        getAlignment(): number;
        create(values?: string | readonly ArrayElementArg<E>[]): ArrayInstance<E>;
        wrap(buffer: Buffer): ArrayInstance<E>;
        from_buffer(
            source:
                | Uint8Array<ArrayBufferLike>
                | Buffer<ArrayBufferLike>
                | { _buffer: Buffer },
            offset?: number,
        ): ArrayInstance<E>;
        from_buffer_copy(
            source:
                | Uint8Array<ArrayBufferLike>
                | Buffer<ArrayBufferLike>
                | { _buffer: Buffer },
            offset?: number,
        ): ArrayInstance<E>;
        from_address(address: number | bigint): ArrayInstance<E>;
        (...values: ArrayElementArg<E>[]): ArrayInstance<E>;
    }

    Type Parameters

    • E = any
    Index
    elementType:
        | AnyType
        | StructureClass
        | ArrayTypeDef<any>
        | PointerTypeDef<any>
        | FuncPtrFactory<FFIType, readonly FFIType[]>

    Element type.

    length: number

    Number of elements.

    • Total size in bytes (elementSize * length).

      Returns number

    • Number of elements.

      Returns number

    • Element alignment.

      Returns number

    • Array sharing the memory of source from offset (Python: (c_int * 3).from_buffer(source, offset)).

      Parameters

      • source: Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike> | { _buffer: Buffer }
      • Optionaloffset: number

      Returns ArrayInstance<E>

    • Array with a copy of the bytes of source from offset (Python: from_buffer_copy).

      Parameters

      • source: Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike> | { _buffer: Buffer }
      • Optionaloffset: number

      Returns ArrayInstance<E>

    • Array on the memory at address (Python: (c_int * 3).from_address(address)). Its _buffer is a Buffer over that memory, as Python's memoryview((c_char * n).from_address(address)); where EXTERNAL_BUFFERS is false it is a copy kept in sync by the array's element accesses.

      Parameters

      • address: number | bigint

      Returns ArrayInstance<E>