make filterObjectsByStringEntries and checkDoesObjectMatchReference work with FileContent
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
import { DATA_VERSION, ValidObject } from "../Utility/typeSafety";
|
import { DATA_VERSION, ValidObject } from "../Utility/typeSafety";
|
||||||
import {
|
import {
|
||||||
HandlerManager,
|
HandlerManager,
|
||||||
|
StringEntryObject,
|
||||||
createTimestamp,
|
createTimestamp,
|
||||||
parseValidObject,
|
parseValidObject,
|
||||||
stringify,
|
stringify,
|
||||||
@@ -175,7 +176,7 @@ export enum FileModelSubPath {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// types
|
// types
|
||||||
export interface FileContent<T extends string> extends ValidObject {
|
export interface FileContent<T extends string> extends ValidObject, StringEntryObject {
|
||||||
fileId: string;
|
fileId: string;
|
||||||
fileContentId: string;
|
fileContentId: string;
|
||||||
creationDate: string;
|
creationDate: string;
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ export class HandlerManager<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// objects
|
// objects
|
||||||
export type StringEntryObject = { [key: string]: string };
|
export type StringEntryObject = { [key: string]: string | undefined };
|
||||||
|
|
||||||
export function filterObjectsByStringEntries<T>(
|
export function filterObjectsByStringEntries<T>(
|
||||||
reference: StringEntryObject,
|
reference: StringEntryObject,
|
||||||
converter: (T) => StringEntryObject,
|
converter: (T) => StringEntryObject,
|
||||||
@@ -56,7 +57,10 @@ export function checkDoesObjectMatchReference<T>(
|
|||||||
reference
|
reference
|
||||||
)) {
|
)) {
|
||||||
const [referenceKey, referenceValue] = referenceEntry;
|
const [referenceKey, referenceValue] = referenceEntry;
|
||||||
const stringEntryObjectValue: string = stringEntryObject[referenceKey];
|
const stringEntryObjectValue: string | undefined =
|
||||||
|
stringEntryObject[referenceKey];
|
||||||
|
|
||||||
|
if (referenceValue == undefined) return false;
|
||||||
|
|
||||||
if (referenceValue[0] == "-") {
|
if (referenceValue[0] == "-") {
|
||||||
const strippedReferenceValue: string = referenceValue.substring(1);
|
const strippedReferenceValue: string = referenceValue.substring(1);
|
||||||
@@ -102,7 +106,7 @@ export function collectObjectValuesForKey<T>(
|
|||||||
|
|
||||||
for (const object of objects) {
|
for (const object of objects) {
|
||||||
const stringEntryObject: StringEntryObject = converter(object);
|
const stringEntryObject: StringEntryObject = converter(object);
|
||||||
const stringEntryObjectValue: string = stringEntryObject[key];
|
const stringEntryObjectValue: string | undefined = stringEntryObject[key];
|
||||||
if (stringEntryObjectValue == undefined || stringEntryObjectValue == "")
|
if (stringEntryObjectValue == undefined || stringEntryObjectValue == "")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user