lint and merge
This commit is contained in:
parent
49f2234e81
commit
e12b99c38b
34 changed files with 10323 additions and 10330 deletions
|
@ -1,20 +1,20 @@
|
|||
abstract class SnowFlake {
|
||||
public readonly id: string;
|
||||
constructor(id: string) {
|
||||
this.id = id;
|
||||
abstract class SnowFlake{
|
||||
public readonly id: string;
|
||||
constructor(id: string){
|
||||
this.id = id;
|
||||
}
|
||||
getUnixTime(): number{
|
||||
return SnowFlake.stringToUnixTime(this.id);
|
||||
}
|
||||
static stringToUnixTime(str: string){
|
||||
try{
|
||||
return Number((BigInt(str) >> 22n) + 1420070400000n);
|
||||
}catch{
|
||||
console.error(
|
||||
`The ID is corrupted, it's ${str} when it should be some number.`
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
getUnixTime(): number {
|
||||
return SnowFlake.stringToUnixTime(this.id);
|
||||
}
|
||||
static stringToUnixTime(str: string) {
|
||||
try {
|
||||
return Number((BigInt(str) >> 22n) + 1420070400000n);
|
||||
} catch {
|
||||
console.error(
|
||||
`The ID is corrupted, it's ${str} when it should be some number.`
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
export { SnowFlake };
|
||||
export{ SnowFlake };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue