Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 lines
813 B

/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
export class Version {
public static readonly EMPTY = new Version('');
constructor(
public readonly value: string
) {
}
public eq(other: Version) {
return other && other.trimmed() === this.trimmed();
}
public toString() {
return this.value;
}
private trimmed(): string {
if (this.value.startsWith('W/')) {
return this.value.substr(2);
} else {
return this.value;
}
}
}
export function versioned<T = any>(version: Version, payload: T = undefined!): Versioned<T> {
return { version, payload };
}
export type Versioned<T> = { readonly version: Version, readonly payload: T };