Start implementation of model relations
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-11-10 21:30:59 -06:00
parent 589cb7d579
commit d92c8b5409
15 changed files with 557 additions and 4 deletions

View File

@@ -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

View File

@@ -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
}