/*
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// TypeScript Version: 4.1
///
import { typedndarray, complexndarray } from '@stdlib/types/ndarray';
/**
* Callback invoked for each ndarray element.
*
* @returns fill value
*/
type Nullary = ( this: ThisArg ) => U;
/**
* Callback invoked for each ndarray element.
*
* @param value - current array element
* @returns fill value
*/
type Unary = ( this: ThisArg, value: T ) => U;
/**
* Callback invoked for each ndarray element.
*
* @param value - current array element
* @param indices - current array element indices
* @returns fill value
*/
type Binary = ( this: ThisArg, value: T, indices: Array ) => U;
/**
* Callback invoked for each ndarray element.
*
* @param value - current array element
* @param indices - current array element indices
* @param arr - input array
* @returns fill value
*/
type Ternary = ( this: ThisArg, value: T, indices: Array, arr: V ) => U;
/**
* Callback invoked for each ndarray element.
*
* @param value - current array element
* @param indices - current array element indices
* @param arr - input array
* @returns fill value
*/
type Callback = Nullary | Unary | Binary | Ternary;
/**
* Fills an input ndarray according to a callback function.
*
* @param x - input ndarray
* @param fcn - callback function
* @param thisArg - callback function execution context
* @returns input ndarray
*
* @example
* var Complex128Array = require( '@stdlib/array/complex128' );
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
*
* function fcn() {
* return new Complex128( 10.0, 0.0 );
* }
*
* // Create a data buffer:
* var xbuf = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );
*
* // Define the shape of the input array:
* var shape = [ 3, 1, 2 ];
*
* // Define the array strides:
* var sx = [ 2, 2, 1 ];
*
* // Define the index offset:
* var ox = 0;
*
* // Create the input ndarray-like object:
* var x = {
* 'dtype': 'float64',
* 'data': xbuf,
* 'shape': shape,
* 'strides': sx,
* 'offset': ox,
* 'order': 'row-major'
* };
*
* var out = fillBy( x, fcn );
*
* console.log( x.data );
* // => [ 10.0, 0.0, 10.0, 0.0, 10.0, 0.0, 10.0, 0.0, 10.0, 0.0, 10.0, 0.0 ]
*
* var bool = ( out === x );
* // returns true
*/
declare function fillBy( x: V, fcn: Callback, thisArg?: ThisParameterType> ): V;
/**
* Fills an input ndarray according to a callback function.
*
* @param x - input ndarray
* @param fcn - callback function
* @param thisArg - callback function execution context
* @returns input ndarray
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* function fcn() {
* return 10.0;
* }
*
* // Create a data buffer:
* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
*
* // Define the shape of the input array:
* var shape = [ 3, 1, 2 ];
*
* // Define the array strides:
* var sx = [ 2, 2, 1 ];
*
* // Define the index offset:
* var ox = 0;
*
* // Create the input ndarray-like object:
* var x = {
* 'dtype': 'float64',
* 'data': xbuf,
* 'shape': shape,
* 'strides': sx,
* 'offset': ox,
* 'order': 'row-major'
* };
*
* var out = fillBy( x, fcn );
*
* console.log( x.data );
* // => [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ]
*
* var bool = ( out === x );
* // returns true
*/
declare function fillBy = typedndarray, ThisArg = unknown>( x: V, fcn: Callback, thisArg?: ThisParameterType> ): V;
// EXPORTS //
export = fillBy;