# API `@deepkit/core`

```shell
npm install @deepkit/core
```

## API reference of @deepkit/core

### getClassName (function)

Returns the class name either of the class definition or of the class of an instance.

Note when code is minimized/uglified this output will change. You should disable in your compile the
className modification.

```typescript
<T>(classTypeOrInstance: ClassType<T> | Object): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L62

### getClassPropertyName (function)

Same as getClassName but appends the propertyName.

```typescript
<T>(classType: ClassType<T> | Object, propertyName: string): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L71

### applyDefaults (function)

```typescript
<T>(classType: ClassType<T>, target: { [k: string]: any; }): T
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L77

### identifyType (function)

Tries to identify the object by normalised result of Object.toString(obj).

```typescript
(obj: any): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L90

### getClassTypeFromInstance (function)

Returns the ClassType for a given instance.

```typescript
<T>(target: T): ClassType<T>
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L97

### stringifyValueWithType (function)

Returns a human-readable string representation from the given value.

```typescript
(value: any, depth?: number): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L108

### changeClass (function)

Changes the class of a given instance and returns the new object.

```typescript
<T>(value: object, newClass: ClassType<T>): T
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L141

### prettyPrintObject (function)

```typescript
(object: object, depth?: number): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L145

### indexOf (function)

```typescript
<T>(array: T[], item: T): number
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L154

### sleep (function)

```typescript
(seconds: number): Promise<void>
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L162

### copy (function)

Creates a shallow copy of given array.

```typescript
<T>(v: T[]): T[]
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L169

### empty (function)

Checks whether given array or object is empty (no keys). If given object is falsy, returns false.

```typescript
<T>(value?: T[] | object | {}): boolean
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L180

### size (function)

Returns the size of given array or object.

```typescript
<T>(array: T[] | { [key: string]: T; }): number
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L194

### firstKey (function)

Returns the first key of a given object.

```typescript
(v: { [key: string]: any; } | object): string | undefined
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L209

### lastKey (function)

Returns the last key of a given object.

```typescript
(v: { [key: string]: any; } | object): string | undefined
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L216

### first (function)

Returns the first value of given array or object.

```typescript
<T>(v: { [key: string]: T; } | T[]): T | undefined
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L227

### last (function)

Returns the last value of given array or object.

```typescript
<T>(v: { [key: string]: T; } | T[]): T | undefined
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L242

### average (function)

Returns the average of a number array.

```typescript
(array: number[]): number
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L260

### prependObjectKeys (function)

```typescript
(o: { [k: string]: any; }, prependText: string): { [k: string]: any; }
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L269

### appendObject (function)

```typescript
(origin: { [k: string]: any; }, extend: { [k: string]: any; }, prependKeyName?: string): void
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L278

### asyncOperation (function)

A better alternative to "new Promise()" that supports error handling and maintains the stack trace for Error.stack.

When you use `new Promise()` you need to wrap your code inside a try-catch to call `reject` on error.
asyncOperation() does this automatically.

When you use `new Promise()` you will lose the stack trace when `reject(new Error())` is called.
asyncOperation() makes sure the error stack trace is the correct one.

```typescript
<T>(executor: (resolve: (value: T) => void, reject: (error: any) => void) => void | Promise<void>): Promise<T>
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L304

### fixAsyncOperation (function)

When an API is called that returns a promise that loses the stack trace on error, you can use fixAsyncOperation().

```typescript
cons storage = new BrokenPromiseStorage();
const files = await fixAsyncOperation(storage.files('/'));
```

```typescript
<T>(promise: Promise<T>): Promise<T>
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L327

### mergePromiseStack (function)

```typescript
<T>(promise: Promise<T>, stack?: string): Promise<T>
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L333

### createStack (function)

```typescript
(removeCallee?: boolean): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L345

### mergeStack (function)

```typescript
(error: Error, stack: string): void
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L372

### ensureError (function)

Makes sure the given value is an error. If it's not an error, it creates a new error with the given value as message.

```typescript
(error?: any, classType?: ClassType): Error
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L381

### collectForMicrotask (function)

```typescript
<T>(callback: (args: T[]) => void): (arg: T) => void
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L385

### getPathValue (function)

```typescript
(bag: { [field: string]: any; }, parameterPath: string, defaultValue?: any): any
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L431

### setPathValue (function)

```typescript
(bag: object, parameterPath: string, value: any): void
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L452

### deletePathValue (function)

```typescript
(bag: object, parameterPath: string): void
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L467

### humanBytes (function)

Returns the human-readable byte representation.

```typescript
(bytes: number, si?: boolean): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L481

### getObjectKeysSize (function)

Returns the number of properties on `obj`. This is 20x faster than Object.keys(obj).length.

```typescript
(obj: object): number
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L501

### getParentClass (function)

```typescript
(classType: ClassType): ClassType | undefined
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L507

### getInheritanceChain (function)

```typescript
(classType: ClassType): ClassType[]
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L513

### inDebugMode (function)

```typescript
(): boolean
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L528

### createDynamicClass (function)

Create a new class with the given name.
This is currently the only know way to make it workable in browsers too.

```typescript
(name: string, base?: ClassType): ClassType
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L537

### iterableSize (function)

```typescript
(value: Array<unknown> | Set<unknown> | Map<unknown, unknown>): number
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L546

### getCurrentFileName (function)

Returns __filename, works in both cjs and esm.

```typescript
(offset?: number): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L553

### getCurrentDirName (function)

Returns the directory name of the current file (__dirname), works in both cjs and esm.

```typescript
(): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L571

### osPathDirectory (function)

dirname() for file system paths of the current OS, including Windows paths like `C:\dir\file.js`.
Unlike pathDirectory(), which is for normalized `/` paths, this does not change the path otherwise.

```typescript
(path: string): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L579

### escapeRegExp (function)

Escape special characters in a regex string, so it can be used as a literal string.

```typescript
(string: string): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L591

### hasProperty (function)

```typescript
(object: any, property: any): boolean
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L595

### range (function)

Returns an iterator of numbers from start (inclusive) to stop (exclusive) by step.

```typescript
(startOrLength: number, stop?: number, step?: number): IterableIterator<number>
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L602

### rangeArray (function)

Returns an array of numbers from start (inclusive) to stop (exclusive) by step.

Works the same as python's range function.

```typescript
(startOrLength: number, stop?: number, step?: number): number[]
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L620

### zip (function)

Returns a combined array of the given arrays.

Works the same as python's zip function.

```typescript
<T extends (readonly unknown[])[]>(...args: T): { [K in keyof T]: T[K] extends (infer V)[] ? V : never; }[]
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L629

### forwardTypeArguments (function)

Forwards the runtime type arguments from function x to function y.
This is necessary when a generic function is overridden and forwarded to something else.

```typescript
let generic = <T>(type?: ReceiveType<T>) => undefined;

let forwarded<T> = () => {
    forwardTypeArguments(forwarded, generic); //all type arguments are forwarded to generic()
    generic(); //call as usual
}

forwarded<any>(); //generic receives any in runtime.
```

Note that generic.bind(this) will not work, as bind() creates a new function and forwarded type arguments can not
reach the original function anymore.

```typescript
let forwarded<T> = () => {
    const bound = generic.bind(this);
    forwardTypeArguments(forwarded, bound); //can not be forwarded anymore
    bound(); //fails
}
```

 This is a limitation of JavaScript. In this case you have to manually forward type arguments.

 ```typescript
 let forwarded<T> = (type?: ReceiveType<T>) => {
    const bound = generic.bind(this);
    bound(type);
 }
 ```

```typescript
(x: any, y: any): void
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L672

### formatError (function)

```typescript
(error: any, withStack?: boolean): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L677

### assertInstanceOf (function)

Asserts that the given object is an instance of the given class.

```typescript
<T>(object: any, constructor: { new (...args: any[]): T; }): asserts object is T
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L699

### assertDefined (function)

Asserts that the given value is defined (not null and not undefined).

```typescript
<T>(value: T): asserts value is NonNullable<T>
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L708

### ClassType (type)

```typescript
interface ClassType<T = any> {
    new(...args: any[]): T;
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L40

### AbstractClassType (type)

```typescript
type AbstractClassType<T = any> = abstract new (...args: any[]) => T;
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L44

### ExtractClassType (type)

```typescript
type ExtractClassType<T> = T extends AbstractClassType<infer K> ? K : never;
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/core.ts#L46

### log (function)

Logs every call to this method on stdout.

```typescript
(): (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/decorators.ts#L19

### stack (function)

Makes sure that calls to this async method are stacked up and are called one after another and not parallel.

```typescript
(): (target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise<any>>) => void
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/decorators.ts#L37

### singleStack (function)

Makes sure that this async method is only running once at a time. When this method is running and it is tried
to call it another times, that call is "dropped" and it returns simply the result of the previous running call (waiting for it to complete first).

```typescript
(): (target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise<any>>) => void
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/decorators.ts#L71

### getEnumLabel (function)

Returns the enum label for a given enum value.

```typescript
(enumType: { [field: string]: any; }, id: any): any
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/enum.ts#L18

### getEnumLabels (function)

Returns all possible enum labels.

```typescript
(enumDefinition: any): string[]
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/enum.ts#L29

### getEnumValues (function)

Returns all possible enum keys.

```typescript
(enumDefinition: any): any[]
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/enum.ts#L44

### getEnumKeyLabelMap (function)

```typescript
(enumDefinition: any): Map<any, string>
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/enum.ts#L58

### isValidEnumValue (function)

Checks whether given enum value is valid.

```typescript
(enumDefinition: any, value: any, allowLabelsAsValue?: boolean): boolean
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/enum.ts#L71

### getValidEnumValue (function)

```typescript
(enumDefinition: any, value: any, allowLabelsAsValue?: boolean): any
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/enum.ts#L83

### Timer (class)

```typescript
export class Timer {
    setTimeout(cb: () => void, timeout: number): any;
    /**
     * Clears all timers at once.
     */
    clear();
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/timer.ts#L11

### ProcessLock (class)

This lock mechanism works only for one process (worker).

live-mutex: has horrible API and doesn't allow to check if an key is currently locked.
proper-filelock: No way to do a correct mutex locking with event-driven blocking acquire() method.
redislock: Very bad performance on high-load (when multiple locks on the same key `wait`, since it loops)
mongodb lock: even worse performance than redis. Jesus.

```typescript
export class ProcessLock {
    constructor(public readonly id: string);
    async acquire(ttl: number = , timeout: number = );
    isLocked();
    tryLock(ttl: number = );
    unlock();
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/process-locker.ts#L23

### ProcessLocker (class)

```typescript
export class ProcessLocker {
    /**
     *
     * @param id
     * @param ttl optional defines when the times automatically unlocks.
     * @param timeout if after `timeout` seconds the lock isn't acquired, it throws an error.
     */
    async acquireLock(id: string, ttl: number = , timeout: number = ): Promise<ProcessLock>;
    async tryLock(id: string, ttl: number = ): Promise<ProcessLock | undefined>;
    isLocked(id: string): boolean;
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/process-locker.ts#L123

### Mutex (class)

```typescript
export class Mutex {
    unlock(): void;
    async lock(): Promise<void>;
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/process-locker.ts#L152

### parseHost (function)

```typescript
(hostWithIpOrUnixPath: string): ParsedHost
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/network.ts#L54

### ParsedHost (class)

```typescript
export class ParsedHost {
    host: string;
    port: number;
    unixSocket: string;
    get isUnixSocket(): boolean;
    get isHostname(): boolean;
    get hostWithIp(): string;
    toString(): string;
    getWebSocketUrl(secure: boolean = false);
    getHttpUrl(secure: boolean = false);
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/network.ts#L13

### toFastProperties (function)

```typescript
(obj: any): void
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/perf.ts#L29

### CompilerContext (class)

```typescript
export class CompilerContext {
    readonly context;
    maxReservedVariable: number;
    /**
     * Code that is executed in the context, but before the actual function is generated.
     * This helps for example to initialize dynamically some context variables.
     */
    preCode: string;
    initialiseVariables: string[];
    config: {
        indent: boolean;
    };
    constructor(config: Partial<CompilerContext[]> = {});
    reserveName(name: string): string;
    set(values: {
        [name: string]: any;
    });
    /**
     * Returns always the same variable name for the same value.
     * The variable name should not be set afterwards.
     */
    reserveConst(value: any, name: string = ): string;
    reserveVariable(name: string = , value?: any): string;
    raw(functionCode: string): Function;
    build(functionCode: string, ...args: string[]): any;
    buildAsync(functionCode: string, ...args: string[]): Function;
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/compiler.ts#L21

### indent (function)

```typescript
(indentation: number, prefix?: string): (str?: string) => string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/string.ts#L13

### capitalize (function)

```typescript
(string: string): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/string.ts#L19

### AsyncEventSubscription (type)

```typescript
type AsyncEventSubscription = { unsubscribe: () => void };
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/emitter.ts#L18

### EventSubscription (type)

```typescript
type EventSubscription = { unsubscribe: () => void };
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/emitter.ts#L19

### EmitterEvent (class)

```typescript
export class EmitterEvent {
    readonly id;
    stopped;
    propagationStopped;
    /**
     * Stop propagating the event to subsequent event listeners.
     */
    stopPropagation();
    /**
     * Signal the emitter that you want to abort.
     * Subsequent event listeners will still be called.
     */
    stop();
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/emitter.ts#L23

### EventEmitter (class)

```typescript
export class EventEmitter<T extends EmitterEvent> {
    constructor(protected parent?: EventEmitter<any>);
    subscribe(callback: Subscriber<T>): EventSubscription;
    emit(event: T): void;
    hasSubscriptions(): boolean;
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/emitter.ts#L44

### AsyncEventEmitter (class)

```typescript
export class AsyncEventEmitter<T extends EmitterEvent> {
    constructor(protected parent?: AsyncEventEmitter<any>);
    subscribe(callback: AsyncSubscriber<T>): AsyncEventSubscription;
    async emit(event: T): Promise<void>;
    hasSubscriptions(): boolean;
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/emitter.ts#L75

### throttleTime (function)

Wraps a function and calls it only `cps` times per frame.

This is handy to throttle all kind of rapid calls, like mouse move events or other kind of events.

```typescript
(call: Function, cps?: number): (...args: any[]) => void
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/reactive.ts#L39

### bufferedGate (function)

This functions returns a stack that is filled as long as the gate is not activated.
Once activated all recorded calls go to given callback and subsequent calls go directly to given callback.

```typescript
<T>(callback: (arg: T) => any): { activate: () => void; call: (i: T) => void; }
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/reactive.ts#L72

### nextTick (function)

```typescript
(cb: () => void) => any
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/reactive.ts#L14

### clearTick (function)

```typescript
(id: any) => any
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/reactive.ts#L17

### extractParameters (function)

```typescript
(fn: string | Function | ClassType): string[]
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/reflection.ts#L16

### extractMethodBody (function)

```typescript
(classCode: string, name: string): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/reflection.ts#L34

### removeStrings (function)

```typescript
(code: string): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/reflection.ts#L61

### urlJoin (function)

```typescript
(...path: string[]): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/url.ts#L5

### arrayHasItem (function)

```typescript
<T>(array: T[], item: T): boolean
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/array.ts#L13

### arrayClear (function)

Clears the array so its empty. Returns the amount of removed items.

```typescript
<T>(array: T[]): number
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/array.ts#L20

### arrayRemoveItem (function)

Removes on particular item by reference of an array.

```typescript
<T>(array: T[], item: T): boolean
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/array.ts#L29

### arrayMoveItem (function)

Moves a particular item in an array up or down (move>0=down, move<0=up).
Changes the array itself.

```typescript
const array = ['a', 'b', 'c'];

arrayMoveItem(array, 'a', +1); //['b', 'a', 'c']
arrayMoveItem(array, 'a', -1); //['a', 'b', 'c']

arrayMoveItem(array, 'b', -1); //['b', 'a', 'c']
arrayMoveItem(array, 'b', +1); //['a', 'c', 'b']

arrayMoveItem(array, 'c', -1); //['b', 'c', 'b']
arrayMoveItem(array, 'c', +1); //['a', 'b', 'c']

```

```typescript
<A extends T[], T>(array: A, item: T, move: number): A
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/array.ts#L57

### TypeAnnotation (type)

Type to use for custom type annotations.

Adds runtime meta information to a type without influencing the type itself.
This is like an intrinsic type, but only for runtime.

```typescript
import { TypeAnnotation } from '@deepkit/core';
import { typeAnnotation } from '@deepkit/type';

type PrimaryKey = TypeAnnotation<'primaryKey'>;
type UserId = string & PrimaryKey;

const type = typeOf<UserId>();
const metaData = typeAnnotation.getType(type, 'primaryKey');
```

Runtime type is `{ __meta?: never & [T, Options] };`

```typescript
type TypeAnnotation<T extends string, Options = never> = unknown;
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/types.ts#L22

### InjectMeta (type)

```typescript
type InjectMeta<T = never> = TypeAnnotation<'inject', T>;
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/types.ts#L24

### Inject (type)

```typescript
type Inject<Type, Token = never> = Type & InjectMeta<Token>;
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/types.ts#L25

### bufferConcat (function)

Concat multiple buffers into one.

```typescript
(chunks: Uint8Array[], length?: number): Uint8Array
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/buffer.ts#L16

### bufferToString (function)

Convert a buffer to a string.

```typescript
(buffer: string | Uint8Array): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/buffer.ts#L39

### nativeBase64ToUint8Array (function)

```typescript
(base64: string): Uint8Array
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/buffer.ts#L44

### createBuffer (function)

Create a buffer of the given size (uninitialized, so it may contain random data).

Note that the result is either Uin8Array or Buffer, depending on the environment.
Buffer from NodeJS works slightly different than Uint8Array.

```typescript
(size: number) => Uint8Array<ArrayBufferLike>
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/buffer.ts#L11

### uint8ArrayToUtf8 (function)

```typescript
(buffer: Uint8Array<ArrayBufferLike>) => any
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/buffer.ts#L34

### base64ToUint8Array (function)

Converts a base64 string to a Uint8Array.

```typescript
(v: string) => Uint8Array<ArrayBufferLike>
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/buffer.ts#L58

### isPlainObject (function)

Returns true if the given obj is a plain object, and no class instance.

isPlainObject(\{\}) === true
isPlainObject(new ClassXY) === false

```typescript
(obj: any): obj is object
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L20

### isClassInstance (function)

Returns true when target is a class instance.

```typescript
(target: any): boolean
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L27

### isFunction (function)

Returns true if given obj is a function.

```typescript
(obj: any): obj is Function
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L38

### isAsyncFunction (function)

Returns true if given obj is a async function.

```typescript
(obj: any): obj is (...args: any[]) => Promise<any>
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L67

### isPromise (function)

Returns true if given obj is a promise like object.

Note: There's no way to check if it's actually a Promise using instanceof since
there are a lot of different implementations around.

```typescript
<T>(obj: any | Promise<T>): obj is Promise<T>
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L77

### isClass (function)

Returns true if given obj is a ES6 class (ES5 fake classes are not supported).

```typescript
(obj: any): obj is AbstractClassType
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L85

### isGlobalClass (function)

```typescript
(obj: any): obj is AbstractClassType
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L92

### isObject (function)

Returns true for real objects: object literals ({}) or class instances (new MyClass).

```typescript
(obj: any): obj is { [key: string]: any; }
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L107

### isObjectLiteral (function)

Returns true if given obj is a plain object, and no Date, Array, Map, Set, etc.

This is different to isObject and used in the type system to differentiate
between JS objects in general and what we define as ReflectionKind.objectLiteral.
Since we have Date, Set, Map, etc. in the type system, we need to differentiate
between them and all other object literals.

```typescript
(obj: any): obj is { [key: string]: any; }
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L122

### isNull (function)

```typescript
(obj: any): obj is null
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L128

### isUndefined (function)

```typescript
(obj: any): obj is undefined
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L132

### isSet (function)

Checks if obj is not null and not undefined.

```typescript
(obj: any): boolean
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L139

### isNumber (function)

Check if it is a real number (not NaN/Infinite).

```typescript
(obj: any): obj is number
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L146

### isNumeric (function)

Returns true if given value is strictly a numeric string value (or a number).

```typescript
isNumeric(12); //true
isNumeric('12'); //true
isNumeric('12.3'); //true
isNumeric('12.3 '); //false
isNumeric('12px'); //false
```

```typescript
(s: string | number): boolean
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L161

### isString (function)

```typescript
(obj: any): obj is string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L180

### isConstructable (function)

```typescript
(fn: any): boolean
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L184

### isPrototypeOfBase (function)

```typescript
(prototype: AbstractClassType | undefined, base: ClassType): boolean
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L193

### isIterable (function)

```typescript
(value: any): boolean
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L204

### AsyncFunction (variable)

```typescript
new (...args: string[]) => Function
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L61

### isArray (function)

```typescript
(obj: any) => obj is any[]
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L126

### isInteger (function)

```typescript
(obj: any) => obj is number
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/type-guards.ts#L176

### pathNormalize (function)

Normalizes the given path.
Removes duplicate slashes, removes trailing slashes, adds a leading slash.

```typescript
(path: string): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/path.ts#L8

### pathNormalizeDirectory (function)

Same as `pathNormalize`, but ensures the path is a directory (always ends with a slash).

```typescript
(path: string): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/path.ts#L17

### pathDirectory (function)

Returns the directory (dirname) of the given path.

```typescript
(path: string): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/path.ts#L26

### pathBasename (function)

Returns the basename of the given path.

```typescript
(path: string): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/path.ts#L36

### pathExtension (function)

Returns the extension of the given path.

```typescript
(path: string): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/path.ts#L45

### pathJoin (function)

```typescript
(...paths: string[]): string
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/core/src/path.ts#L51
