@adriansteffan/reactive 0.0.27 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mod.d.ts CHANGED
@@ -45,6 +45,11 @@ export declare function CheckDevice({ check, content, data, store, updateStore,
45
45
  content?: React.ReactNode;
46
46
  } & BaseComponentProps): JSX_2.Element | null;
47
47
 
48
+ /**
49
+ * Splits array into chunks
50
+ */
51
+ export declare function chunk<T>(array: T[], n: number): T[][];
52
+
48
53
  declare type ComponentResultData = BaseTrialData & {
49
54
  type: string;
50
55
  name: string;
@@ -160,6 +165,11 @@ declare type ParamType = 'string' | 'number' | 'boolean' | 'array' | 'json';
160
165
 
161
166
  declare type ParamValue<T extends ParamType> = T extends 'number' ? number : T extends 'boolean' ? boolean : T extends 'array' | 'json' ? any : string;
162
167
 
168
+ /**
169
+ * Applies a function to an array
170
+ */
171
+ export declare function pipe<T, U>(array: T[], fn: (arr: T[]) => U): U;
172
+
163
173
  export declare function PlainInput({ content, buttonText, className, next, updateStore, animate, storeupdate, placeholder, }: BaseComponentProps & {
164
174
  content: React.ReactNode;
165
175
  buttonText?: string;
@@ -195,7 +205,6 @@ declare type RefinedTrialData = ComponentResultData | CanvasResultData;
195
205
  * import { registerArrayExtensions } from '@adriansteffan/reactive/array';
196
206
  * registerArrayExtensions();
197
207
  *
198
- * // Now you can use the methods
199
208
  * const myArray = [1, 2, 3, 4, 5];
200
209
  * myArray.shuffle();
201
210
  * ```
@@ -215,16 +224,11 @@ export declare function RequestFilePermission({ next }: BaseComponentProps): JSX
215
224
 
216
225
  /**
217
226
  * Returns random elements from an array
218
- * @param array The source array
219
- * @param n Number of random elements to return (defaults to 1)
220
- * @returns Array of randomly selected elements
221
227
  */
222
228
  export declare function sample<T>(array: T[], n?: number): T[];
223
229
 
224
230
  /**
225
231
  * Shuffles array elements using Fisher-Yates algorithm
226
- * @param array The source array
227
- * @returns A new shuffled array
228
232
  */
229
233
  export declare function shuffle<T>(array: T[]): T[];
230
234
 
@@ -289,13 +293,21 @@ declare global {
289
293
  /**
290
294
  * Returns random elements from the array
291
295
  * @param n Number of random elements to return (defaults to 1)
292
- * @returns Array of randomly selected elements
293
296
  */
294
297
  sample(n?: number): Array<T>;
295
298
  /**
296
299
  * Shuffles array elements using Fisher-Yates algorithm
297
- * @returns A new shuffled array
298
300
  */
299
301
  shuffle(): Array<T>;
302
+ /**
303
+ * Applies a function to the array
304
+ * @param fn Function to apply to the array
305
+ */
306
+ pipe<U>(fn: (arr: Array<T>) => U): U;
307
+ /**
308
+ * Splits array into chunks
309
+ * @param n Number of chunks to create
310
+ */
311
+ chunk(n: number): Array<Array<T>>;
300
312
  }
301
313
  }
@@ -1,29 +1,31 @@
1
- import { C as e, t as r, m as n, o as t, p as i, q as o, M as l, P as m, k as c, l as p, Q as P, R as u, T as x, U as E, j as g, g as f, d as C, c as d, i as k, n as h, r as v, f as F, e as R, s as q, a as w, h as y } from "./mod-CbGhKi2f.js";
1
+ import { C as e, v as r, o as n, q as i, t, u as o, M as l, P as m, l as p, m as c, Q as u, R as P, T as x, U as E, k as g, c as f, g as k, e as C, d, i as h, n as v, p as F, r as R, h as q, f as w, s as y, a as B, j as D } from "./mod-CjZm1Ta9.js";
2
2
  export {
3
3
  e as CanvasBlock,
4
4
  r as CheckDevice,
5
5
  n as EnterFullscreen,
6
- t as ExitFullscreen,
7
- i as ExperimentProvider,
6
+ i as ExitFullscreen,
7
+ t as ExperimentProvider,
8
8
  o as ExperimentRunner,
9
9
  l as MicCheck,
10
10
  m as Param,
11
- c as PlainInput,
12
- p as ProlificEnding,
13
- P as Quest,
14
- u as RequestFilePermission,
11
+ p as PlainInput,
12
+ c as ProlificEnding,
13
+ u as Quest,
14
+ P as RequestFilePermission,
15
15
  x as Text,
16
16
  E as Upload,
17
17
  g as canvasCountdown,
18
- f as getParam,
18
+ f as chunk,
19
+ k as getParam,
19
20
  C as getPlatform,
20
21
  d as isDesktop,
21
- k as isFullscreen,
22
- h as now,
23
- v as registerArrayExtensions,
24
- F as registerComponentParams,
25
- R as registerExperimentParams,
26
- q as sample,
27
- w as shuffle,
28
- y as subsetExperimentByParam
22
+ h as isFullscreen,
23
+ v as now,
24
+ F as pipe,
25
+ R as registerArrayExtensions,
26
+ q as registerComponentParams,
27
+ w as registerExperimentParams,
28
+ y as sample,
29
+ B as shuffle,
30
+ D as subsetExperimentByParam
29
31
  };