Skip to content

Commit 27587bc

Browse files
committed
support PredicateFunction on isMissing
1 parent 6875104 commit 27587bc

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Changelog
22

33

4-
## [4.5.0](https://github.com/supercharge/arrays/compare/v4.4.0...v4.5.0) - 2024-07-xx
4+
## [4.5.0](https://github.com/supercharge/arrays/compare/v4.4.0...v4.5.0) - 2025-06-30
55

6-
### Updated
7-
- static `from`: improve typing for returned instance type. This allows subclassing the `Arr` class and receiving the correct class instance type
6+
### Added
7+
- `isMissing`: support predicate function and individual value
88

99

1010
## [4.4.0](https://github.com/supercharge/arrays/compare/v4.3.0...v4.4.0) - 2024-02-20

src/arr.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ArrIterator } from './iterator'
44

55
type Values<T> = Array<T | Iterable<T> | undefined | null>
66

7-
type Predicate<T> = ((item: T, index: number, array: Arr<T>) => unknown)
7+
type PredicateFunction<T> = ((item: T, index: number, array: Arr<T>) => unknown)
88

99
type Truthy<T> = T extends null | undefined | false | '' | 0
1010
? never
@@ -253,9 +253,9 @@ export class Arr<T> {
253253
/**
254254
* Determine whether the array contains the given `value`.
255255
*/
256-
has (valueOrPredicate: T | Predicate<T>): boolean {
256+
has (valueOrPredicate: T | PredicateFunction<T>): boolean {
257257
const results = typeof valueOrPredicate === 'function'
258-
? this.filter((item, index) => (valueOrPredicate as Predicate<T>)(item, index, this))
258+
? this.filter((item, index) => (valueOrPredicate as PredicateFunction<T>)(item, index, this))
259259
: this.filter(item => item === valueOrPredicate)
260260

261261
return results.length() > 0
@@ -280,8 +280,8 @@ export class Arr<T> {
280280
/**
281281
* Determine whether the array does not contain the given `value`.
282282
*/
283-
isMissing (value: T): boolean {
284-
return !this.has(value)
283+
isMissing (valueOrPredicate: T | PredicateFunction<T>): boolean {
284+
return !this.has(valueOrPredicate)
285285
}
286286

287287
/**

0 commit comments

Comments
 (0)