Reformat code
This commit is contained in:
parent
6e27539eca
commit
420cd788c4
94 changed files with 10592 additions and 2608 deletions
14
src/app/utils/hash.ts
Normal file
14
src/app/utils/hash.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
export const hashCode = (text: string) => {
|
||||
let hash = 0;
|
||||
if (text.length == 0) {
|
||||
return hash;
|
||||
}
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
const char = text.charCodeAt(i);
|
||||
hash = (hash << 5) - hash + char;
|
||||
hash = hash & hash;
|
||||
}
|
||||
|
||||
hash /= Math.pow(2, 32) - 1;
|
||||
return hash;
|
||||
};
|
||||
7
src/app/utils/range.ts
Normal file
7
src/app/utils/range.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export const range = ({ min = 0, max = Infinity, step = 1 }: { min?: number; max?: number; step?: number }) => {
|
||||
return {
|
||||
*[Symbol.iterator]() {
|
||||
for (let i = min; i < max; yield i, i += step);
|
||||
}
|
||||
};
|
||||
};
|
||||
3
src/app/utils/top.ts
Normal file
3
src/app/utils/top.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export const top = <T>(iterable: ArrayLike<T>): T => {
|
||||
return iterable.length > 0 ? iterable[iterable.length - 1] : null;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue