Skip to content

Commit 59fa707

Browse files
authored
feat: add isNonEmptyString (#66)
1 parent 3133ab8 commit 59fa707

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@ if (isArray(value)) {
5050
- `isFunction()`
5151
- `isGuid()`
5252
- `isInfinity()`
53+
- `isNegativeNumber()`
5354
- `isNull()`
5455
- `isNil()`
56+
- `isNonEmptyString()`
57+
- `isNonZeroNumber()`
5558
- `isNumber()`
5659
- `isObject()`
5760
- `isPlainObject()`
61+
- `isPositiveNumber()`
5862
- `isRegExp()`
5963
- `isString()`
6064
- `isSymbol()`

src/index.spec.ts

+5
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ describe('ts-util-is methods', () => {
9191
expect(util.isString('')).toEqual(true);
9292
});
9393

94+
it('ensure value is a non empty string', () => {
95+
expect(util.isNonEmptyString('')).toBe(false);
96+
expect(util.isNonEmptyString('something')).toBe(true);
97+
});
98+
9499
it('ensure value is a symbol', () => {
95100
expect(util.isSymbol(Symbol())).toEqual(true);
96101
});

src/index.ts

+9
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@ export function isString(value: any): value is string {
184184
return typeof value === 'string';
185185
}
186186

187+
/**
188+
* Determines if a reference is a `String` and not the empty string.
189+
*
190+
* @param value Reference to check
191+
*/
192+
export function isNonEmptyString(value: unknown): value is string {
193+
return isString(value) && !!value;
194+
}
195+
187196
/**
188197
* Determines if a reference is a `Symbol`.
189198
*

0 commit comments

Comments
 (0)