|
| 1 | +/* eslint-disable max-lines */ |
| 2 | + |
1 | 3 | /* |
2 | 4 | * @license Apache-2.0 |
3 | 5 | * |
@@ -105,6 +107,50 @@ type TernaryPredicate<U> = ( this: U, value: Complex64, index: number, arr: Comp |
105 | 107 | */ |
106 | 108 | type Predicate<U> = NullaryPredicate<U> | UnaryPredicate<U> | BinaryPredicate<U> | TernaryPredicate<U>; |
107 | 109 |
|
| 110 | +/** |
| 111 | +* Callback invoked for each element in an array. |
| 112 | +* |
| 113 | +* @returns undefined |
| 114 | +*/ |
| 115 | +type NullaryCallback<U> = ( this: U ) => void; |
| 116 | + |
| 117 | +/** |
| 118 | +* Callback invoked for each element in an array. |
| 119 | +* |
| 120 | +* @param value - current array element |
| 121 | +* @returns undefined |
| 122 | +*/ |
| 123 | +type UnaryCallback<U> = ( this: U, value: Complex64 ) => void; |
| 124 | + |
| 125 | +/** |
| 126 | +* Callback invoked for each element in an array. |
| 127 | +* |
| 128 | +* @param value - current array element |
| 129 | +* @param index - current array element index |
| 130 | +* @returns undefined |
| 131 | +*/ |
| 132 | +type BinaryCallback<U> = ( this: U, value: Complex64, index: number ) => void; |
| 133 | + |
| 134 | +/** |
| 135 | +* Callback invoked for each element in an array. |
| 136 | +* |
| 137 | +* @param value - current array element |
| 138 | +* @param index - current array element index |
| 139 | +* @param arr - array on which the method was called |
| 140 | +* @returns undefined |
| 141 | +*/ |
| 142 | +type TernaryCallback<U> = ( this: U, value: Complex64, index: number, arr: Complex64Array ) => void; |
| 143 | + |
| 144 | +/** |
| 145 | +* Callback invoked for each element in an array. |
| 146 | +* |
| 147 | +* @param value - current array element |
| 148 | +* @param index - current array element index |
| 149 | +* @param arr - array on which the method was called |
| 150 | +* @returns undefined |
| 151 | +*/ |
| 152 | +type Callback<U> = NullaryCallback<U> | UnaryCallback<U> | BinaryCallback<U> | TernaryCallback<U>; |
| 153 | + |
108 | 154 | /** |
109 | 155 | * Class for creating a 64-bit complex number array. |
110 | 156 | */ |
@@ -501,6 +547,33 @@ declare class Complex64Array implements Complex64ArrayInterface { |
501 | 547 | */ |
502 | 548 | findLastIndex<U = unknown>( predicate: Predicate, thisArg?: ThisParameterType<Predicate<U>> ): number; |
503 | 549 |
|
| 550 | + /** |
| 551 | + * Invokes a function once for each array element. |
| 552 | + * |
| 553 | + * @param fcn - function to invoke |
| 554 | + * @param thisArg - execution context |
| 555 | + * @returns undefined |
| 556 | + * |
| 557 | + * @example |
| 558 | + * var Complex64 = require( '@stdlib/complex/float32' ); |
| 559 | + * |
| 560 | + * function log( v, i ) { |
| 561 | + * console.log( '%s: %s', i, v.toString() ); |
| 562 | + * } |
| 563 | + * |
| 564 | + * var arr = new Complex64Array( 3 ); |
| 565 | + * |
| 566 | + * arr.set( [ 1.0, 1.0 ], 0 ); |
| 567 | + * arr.set( [ 2.0, 2.0 ], 1 ); |
| 568 | + * arr.set( [ 3.0, 3.0 ], 2 ); |
| 569 | + * |
| 570 | + * arr.forEach( log ); |
| 571 | + * // => 0: 1 + 1i |
| 572 | + * // => 1: 2 + 2i |
| 573 | + * // => 2: 3 + 3i |
| 574 | + */ |
| 575 | + forEach<U = unknown>( fcn: Callback, thisArg?: ThisParameterType<Callback<U>> ): void; |
| 576 | + |
504 | 577 | /** |
505 | 578 | * Returns an array element. |
506 | 579 | * |
|
0 commit comments