Skip to content

Commit

Permalink
feat(entities): export Entity typeguard
Browse files Browse the repository at this point in the history
  • Loading branch information
monitz87 committed Jul 9, 2021
1 parent ec39d9e commit a41e677
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/api/entities/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,12 @@ export abstract class Entity<UniqueIdentifiers, HumanReadable> {
*/
public abstract toJson(): HumanReadable;
}

/**
* Return if value is an Entity
*/
export function isEntity<Identifiers = unknown, HumanReadable = unknown>(
value: unknown
): value is Entity<Identifiers, HumanReadable> {
return value instanceof Entity;
}
1 change: 1 addition & 0 deletions src/api/entities/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ export * from './CheckpointSchedule/types';
export * from './CorporateAction/types';
export * from './DividendDistribution/types';
// export * from './Proposal/types';
export { isEntity } from './Entity';

0 comments on commit a41e677

Please sign in to comment.