File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
packages/type/src/guard/lib Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 11// Function.
2- import { guardObject } from './guard-object.func' ;
3- import { isKey } from '../../is/lib/is-key.func' ;
2+ import { isObjectKey } from '../../is/lib/is-object-key.func' ;
43// Type.
54import { GuardObjectKey } from '../type/guard-object-key.type' ;
5+ import { Key } from '../../type/key.type' ;
6+ import { ResultCallback } from '../../type/result-callback.type' ;
67/**
78 * Guard the `value` to be an `object` of a generic `Obj` type that contains the `key` property of the `Key` type.
89 * @param value A generic `Obj` type `value` that contains the `key` to guard.
9- * @param key A `Key` type name of the property that the `value` contains.
10+ * @param key A `Key` or `Key[]` type name of the property that the `value` contains.
11+ * @param callback An optional `ResultCallback` function to handle result before returns.
1012 * @returns A `boolean` indicating whether or not the `value` is an `object` of a generic `Obj` containing the `Key`.
1113 */
12- export const guardObjectKey : GuardObjectKey = < Obj extends object , Key extends keyof Obj > ( value : Obj , key : Key ) : value is Obj =>
13- guardObject < Obj > ( value ) ? isKey ( key ) ? key in value : true : false ;
14+ export const guardObjectKey : GuardObjectKey = < Obj extends object > ( value : Obj , key : Key | Key [ ] , callback ?: ResultCallback ) : value is Obj =>
15+ isObjectKey < Obj > ( value , key , callback ) ;
You can’t perform that action at this time.
0 commit comments