@@ -349,6 +349,40 @@ export function exists<T>(a: any, b?: any): any {
349
349
return partial ? exec : exec ( a )
350
350
}
351
351
352
+ /**
353
+ * Tests if every element of the array satisfies the given predicate.
354
+ * @param source The input collection.
355
+ * @param predicate A function to test against each item of the input collection.
356
+ * @example
357
+ * Arrays.every([1, 2], x => x === 1) // false
358
+ * // or using pipe
359
+ * pipe([1, 2], Arrays.every(x => x >= 1)) // true
360
+ */
361
+ export function every < T > (
362
+ source : ReadonlyArray < T > ,
363
+ predicate : ( item : T , index : number ) => boolean
364
+ ) : boolean
365
+ /**
366
+ * Tests if every element of the array satisfies the given predicate.
367
+ * @param predicate A function to test against each item of the input collection.
368
+ * @param source The input collection.
369
+ * @example
370
+ * Arrays.every([1, 2], x => x === 1) // false
371
+ * // or using pipe
372
+ * pipe([1, 2], Arrays.every(x => x >= 1)) // true
373
+ */
374
+ export function every < T > (
375
+ predicate : ( item : T , index : number ) => boolean
376
+ ) : ( source : ReadonlyArray < T > ) => boolean
377
+ export function every < T > ( a : any , b ?: any ) : any {
378
+ const partial = typeof a === 'function'
379
+ const predicate : ( item : T , index : number ) => boolean = partial ? a : b
380
+ function exec ( source : ReadonlyArray < T > ) : boolean {
381
+ return source . every ( predicate )
382
+ }
383
+ return partial ? exec : exec ( a )
384
+ }
385
+
352
386
/**
353
387
* Returns the first element for which the given function returns true or throws if not found.
354
388
* If you don't want exceptions, use `find` instead.
0 commit comments