@@ -62,6 +62,50 @@ type FromBinary<U> = ( this: U, value: boolean, index: number ) => boolean;
62
62
*/
63
63
type FromCallback < U > = FromNullary < U > | FromUnary < U > | FromBinary < U > ;
64
64
65
+ /**
66
+ * Callback invoked for each element in an array.
67
+ *
68
+ * @returns returned value
69
+ */
70
+ type NullaryMapFcn < U > = ( this : U ) => any ;
71
+
72
+ /**
73
+ * Callback invoked for each element in an array.
74
+ *
75
+ * @param value - current array element
76
+ * @returns returned value
77
+ */
78
+ type UnaryMapFcn < U > = ( this : U , value : boolean ) => any ;
79
+
80
+ /**
81
+ * Callback invoked for each element in an array.
82
+ *
83
+ * @param value - current array element
84
+ * @param index - current array element index
85
+ * @returns returned value
86
+ */
87
+ type BinaryMapFcn < U > = ( this : U , value : boolean , index : number ) => any ;
88
+
89
+ /**
90
+ * Callback invoked for each element in an array.
91
+ *
92
+ * @param value - current array element
93
+ * @param index - current array element index
94
+ * @param arr - array on which the method was called
95
+ * @returns returned value
96
+ */
97
+ type TernaryMapFcn < U > = ( this : U , value : boolean , index : number , arr : BooleanArray ) => any ;
98
+
99
+ /**
100
+ * Callback invoked for each element in an array.
101
+ *
102
+ * @param value - current array element
103
+ * @param index - current array element index
104
+ * @param arr - array on which the method was called
105
+ * @returns returned value
106
+ */
107
+ type MapFcn < U > = NullaryMapFcn < U > | UnaryMapFcn < U > | BinaryMapFcn < U > | TernaryMapFcn < U > ;
108
+
65
109
/**
66
110
* Class for creating a Boolean array.
67
111
*/
@@ -194,6 +238,38 @@ declare class BooleanArray implements BooleanArrayInterface {
194
238
*/
195
239
get ( i : number ) : boolean | void ;
196
240
241
+ /**
242
+ * Returns a new array with each element being the result of a provided callback function.
243
+ *
244
+ * @param fcn - callback function
245
+ * @param thisArg - callback function execution context
246
+ * @returns new boolean array
247
+ *
248
+ * @example
249
+ * function invert( v ) {
250
+ * return !v;
251
+ * }
252
+ *
253
+ * var arr = new BooleanArray( 3 );
254
+ *
255
+ * arr.set( true, 0 );
256
+ * arr.set( false, 1 );
257
+ * arr.set( true, 2 );
258
+ *
259
+ * var out = arr.map( invert );
260
+ * // returns <BooleanArray>
261
+ *
262
+ * var v = out.get( 0 );
263
+ * // returns false
264
+ *
265
+ * v = out.get( 1 );
266
+ * // returns true
267
+ *
268
+ * v = out.get( 2 );
269
+ * // returns false
270
+ */
271
+ map < U = unknown > ( fcn : MapFcn < U > , thisArg ?: ThisParameterType < MapFcn < U > > ) : BooleanArray ;
272
+
197
273
/**
198
274
* Sets an array element.
199
275
*
0 commit comments