This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Duration { | |
private _value: number | |
private constructor(value: number) { | |
this._value = value | |
} | |
static miliseconds(value: number) { | |
return new Duration(value) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class ObjectStorage { | |
private buckets: ObjectStorageBucket[] = [] | |
constructor(public readonly storagePath: string) { | |
fs.ensureDirSync(storagePath) | |
} | |
createBucket(bucketName: string) { | |
this.buckets.push(new ObjectStorageBucket(this.storagePath, bucketName)) | |
} | |
getBucket(bucketName: string): ObjectStorageBucket | undefined { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Result<T> { | |
private constructor( | |
private _value?: T, | |
private _error?: Error | |
) {} | |
static success<T>(value: T) { | |
return new Result(value, undefined) | |
} | |
static failure(err: Error) { | |
return new Result(undefined, err) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let subscriber | |
export function signal(value) { | |
const subscriptions = new Set() | |
return { | |
get value() { | |
if(subscription) { | |
subscriptions.add(subscriber) | |
} | |
return value |
NewerOlder