Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ensure there's at least 1 char in non-empty string #200

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
Class,
Falsy,
NodeStream,
NonEmptyString,
ObservableLike,
Predicate,
Primitive,
Expand Down Expand Up @@ -582,12 +583,12 @@ export function isNonEmptySet<T = unknown>(value: unknown): value is Set<T> {
}

// TODO: Use `not ''` when the `not` operator is available.
export function isNonEmptyString(value: unknown): value is string {
export function isNonEmptyString(value: unknown): value is NonEmptyString {
return isString(value) && value.length > 0;
}

// TODO: Use `not ''` when the `not` operator is available.
export function isNonEmptyStringAndNotWhitespace(value: unknown): value is string {
export function isNonEmptyStringAndNotWhitespace(value: unknown): value is NonEmptyString {
return isString(value) && !isEmptyStringOrWhitespace(value);
}

Expand Down
2 changes: 2 additions & 0 deletions source/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@ export type NodeStream = {
} & NodeJS.EventEmitter;

export type Predicate = (value: unknown) => boolean;

export type NonEmptyString = string & {0: string};