Skip to content

Commit

Permalink
perf(core): define some enums as const enums, so they get inlined
Browse files Browse the repository at this point in the history
  • Loading branch information
B4nan committed May 13, 2023
1 parent 74b6a98 commit 3cb43ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions packages/core/src/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const enum FlushMode {
ALWAYS,
}

export enum PopulateHint {
export const enum PopulateHint {
INFER,
ALL,
}
Expand Down Expand Up @@ -52,7 +52,7 @@ export const ARRAY_OPERATORS = [
'$contained',
];

export enum QueryOrder {
export const enum QueryOrder {
ASC = 'ASC',
ASC_NULLS_LAST = 'ASC NULLS LAST',
ASC_NULLS_FIRST = 'ASC NULLS FIRST',
Expand Down Expand Up @@ -85,7 +85,7 @@ export interface FlatQueryOrderMap {
[x: string]: QueryOrderKeysFlat;
}

export enum QueryFlag {
export const enum QueryFlag {
DISTINCT = 'DISTINCT',
PAGINATE = 'PAGINATE',
DISABLE_PAGINATE = 'DISABLE_PAGINATE',
Expand All @@ -98,7 +98,7 @@ export enum QueryFlag {

export const SCALAR_TYPES = ['string', 'number', 'boolean', 'Date', 'Buffer', 'RegExp'];

export enum ReferenceType {
export const enum ReferenceType {
SCALAR = 'scalar',
ONE_TO_ONE = '1:1',
ONE_TO_MANY = '1:m',
Expand All @@ -107,7 +107,7 @@ export enum ReferenceType {
EMBEDDED = 'embedded',
}

export enum Cascade {
export const enum Cascade {
PERSIST = 'persist',
MERGE = 'merge',
REMOVE = 'remove',
Expand All @@ -119,12 +119,12 @@ export enum Cascade {
CANCEL_ORPHAN_REMOVAL = 'cancel_orphan_removal',
}

export enum LoadStrategy {
export const enum LoadStrategy {
SELECT_IN = 'select-in',
JOINED = 'joined'
}

export enum LockMode {
export const enum LockMode {
NONE = 0,
OPTIMISTIC = 1,
PESSIMISTIC_READ = 2,
Expand All @@ -135,7 +135,7 @@ export enum LockMode {
PESSIMISTIC_READ_OR_FAIL = 7,
}

export enum IsolationLevel {
export const enum IsolationLevel {
READ_UNCOMMITTED = 'read uncommitted',
READ_COMMITTED = 'read committed',
SNAPSHOT = 'snapshot',
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/unit-of-work/ChangeSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export interface ChangeSet<T> {
originalEntity?: EntityData<T>;
}

export enum ChangeSetType {
export const enum ChangeSetType {
CREATE = 'create',
UPDATE = 'update',
DELETE = 'delete',
Expand Down
2 changes: 1 addition & 1 deletion packages/knex/src/query/enums.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum QueryType {
export const enum QueryType {
TRUNCATE = 'TRUNCATE',
SELECT = 'SELECT',
COUNT = 'COUNT',
Expand Down

0 comments on commit 3cb43ba

Please sign in to comment.