-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: rename functions and export types from d.ts
- Loading branch information
1 parent
e5c785d
commit b74732b
Showing
16 changed files
with
82 additions
and
160 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { get } from 'lodash'; | ||
|
||
export const groupByKey = <T>(datas: T[], key: keyof T, formatter?: (v: string) => string): Record<string, T[]> => { | ||
const ret: Record<string, T[]> = {}; | ||
|
||
if (datas && Array.isArray(datas)) { | ||
for (const data of datas) { | ||
let value = get(data, key); | ||
value = formatter ? formatter(value) : value; | ||
if (ret[value]) { | ||
ret[value]!.push(data); | ||
} else { | ||
ret[value] = [data]; | ||
} | ||
} | ||
} | ||
|
||
return ret; | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,2 @@ | ||
import { groupByDate } from './group-by-date'; | ||
import { rank } from './rank'; | ||
|
||
export const _collection = { | ||
rank, | ||
groupByDate, | ||
}; | ||
export * from './group-by-key'; | ||
export * from './rank-by-path'; |
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,3 @@ | ||
import { cnWeekDay } from './cn-week-day'; | ||
import { isOverlap, isOverlaps } from './overlap'; | ||
export * from './cn-week-day'; | ||
export * from './fns-tz'; | ||
|
||
export const _datetime = { | ||
isOverlap, | ||
isOverlaps, | ||
cnWeekDay, | ||
}; | ||
export * from './interval-overlap'; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Exception } from '../exception'; | ||
|
||
export const areIntervalsOverlap = (intervalLeft: Interval, intervalRight: Interval) => { | ||
if (intervalLeft.start > intervalLeft.end || intervalRight.start > intervalRight.end) { | ||
throw new Exception.Server.InternalErrorException('时间段无效'); | ||
} | ||
|
||
if (intervalLeft.end < intervalRight.start || intervalRight.end < intervalLeft.start) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}; | ||
|
||
export const areIntervalsOverlaps = (time: Interval, compares: Interval[]): boolean => { | ||
for (const compare of compares) { | ||
if (areIntervalsOverlap(time, compare)) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,2 @@ | ||
import { oid } from './oid'; | ||
import { ossImageCrop } from './oss-image-crop'; | ||
|
||
export const _generator = { | ||
oid, | ||
ossImageCrop, | ||
}; | ||
export * from './oid'; | ||
export * from './oss-image-crop'; |
This file contains 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