Start implementation of model relations
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -16,8 +16,11 @@ type ComparisonFunction<T> = (item: CollectionItem<T>, otherItem: CollectionItem
|
||||
import { WhereOperator, applyWhere, whereMatch } from './where'
|
||||
|
||||
const collect = <T>(items: CollectionItem<T>[]): Collection<T> => Collection.collect(items)
|
||||
const toString = (item: unknown): string => String(item)
|
||||
|
||||
export {
|
||||
collect,
|
||||
toString,
|
||||
Collection,
|
||||
|
||||
// Types
|
||||
|
||||
@@ -9,3 +9,12 @@ export type ParameterizedCallback<T> = ((arg: T) => any)
|
||||
|
||||
/** A key-value form of a given type. */
|
||||
export type KeyValue<T> = {key: string, value: T}
|
||||
|
||||
/** Simple helper method to verify that a key is a keyof some object. */
|
||||
export function isKeyof<T>(key: unknown, obj: T): key is keyof T {
|
||||
if ( typeof key !== 'string' && typeof key !== 'symbol' ) {
|
||||
return false
|
||||
}
|
||||
|
||||
return key in obj
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user