File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// Function.
22import { isString } from '../../is/lib/is-string.func' ;
33// Type.
4+ import { AnyString } from '../../type/any-string.type' ;
45import { GuardString } from '../type/guard-string.type' ;
56import { ResultCallback } from '../../type/result-callback.type' ;
67/**
7- * Guard the `value` to be a ` string` .
8- * @param value A `string ` type `value` to guard.
9- * @param callback Optional `ResultCallback` function to handle result before returns.
10- * @returns A `boolean` indicating whether or not the `value` is a `string`.
8+ * Guard the `value` to be any type of a string.
9+ * @param value An `AnyString ` type `value` to guard.
10+ * @param callback An Optional `ResultCallback` function to handle result before returns.
11+ * @returns A `boolean` indicating whether or not the `value` is a `string` type or `String` object .
1112 */
12- export const guardString : GuardString = ( value : string , callback ?: ResultCallback ) : value is string =>
13+ export const guardString : GuardString = < S extends AnyString > ( value : S , callback ?: ResultCallback ) : value is S =>
1314 isString ( value , callback ) ;
Original file line number Diff line number Diff line change 1+ import { AnyString } from '../../type/any-string.type' ;
12import { ResultCallback } from '../../type/result-callback.type' ;
2- export type GuardString = ( value : string , callback ?: ResultCallback ) => value is string ;
3+ export type GuardString = < S extends AnyString > ( value : S , callback ?: ResultCallback ) => value is S ;
You can’t perform that action at this time.
0 commit comments