forked from CorentinTh/it-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add split by separator + order by numeric + no sort
Fix CorentinTh#764 CorentinTh#1279 CorentinTh#1090 Small screen UI Fix
- Loading branch information
Showing
7 changed files
with
166 additions
and
72 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 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 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,17 +1,18 @@ | ||
export type SortOrder = 'asc' | 'desc' | null; | ||
export type SortOrder = null | 'asc' | 'desc' | 'asc-num' | 'desc-num' | 'asc-bin' | 'desc-bin' | 'asc-upper' | 'desc-upper'; | ||
|
||
export interface ConvertOptions { | ||
lowerCase: boolean | ||
trimItems: boolean | ||
itemPrefix: string | ||
itemSuffix: string | ||
removeItemPrefix: string | ||
removeItemSuffix: string | ||
listPrefix: string | ||
listSuffix: string | ||
reverseList: boolean | ||
sortList: SortOrder | ||
removeDuplicates: boolean | ||
separator: string | ||
keepLineBreaks: boolean | ||
lowerCase?: boolean | ||
trimItems?: boolean | ||
itemPrefix?: string | ||
itemSuffix?: string | ||
removeItemPrefix?: string | ||
removeItemSuffix?: string | ||
listPrefix?: string | ||
listSuffix?: string | ||
reverseList?: boolean | ||
sortList?: SortOrder | ||
removeDuplicates?: boolean | ||
itemsSeparator?: string | ||
splitBySeparator?: string | ||
keepLineBreaks?: boolean | ||
} |
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,25 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { type SortOrder, byOrder } from './array'; | ||
|
||
describe('array utils', () => { | ||
describe('byOrder', () => { | ||
it('should sort correctly', () => { | ||
const sortBy = (array: string[], order: SortOrder) => { | ||
return array.sort(byOrder({ order })); | ||
}; | ||
|
||
const strings = ['a', 'A', 'b', 'B', 'á', '1', '2', '10', '一', '阿']; | ||
|
||
expect(sortBy(strings, null)).to.eql(strings); | ||
expect(sortBy(strings, undefined)).to.eql(strings); | ||
expect(sortBy(strings, 'asc')).to.eql(['1', '10', '2', 'a', 'A', 'á', 'b', 'B', '一', '阿']); | ||
expect(sortBy(strings, 'asc-num')).to.eql(['1', '2', '10', 'a', 'A', 'á', 'b', 'B', '一', '阿']); | ||
expect(sortBy(strings, 'asc-bin')).to.eql(['1', '10', '2', 'A', 'B', 'a', 'b', 'á', '一', '阿']); | ||
expect(sortBy(strings, 'asc-upper')).to.eql(['1', '10', '2', 'A', 'a', 'á', 'B', 'b', '一', '阿']); | ||
expect(sortBy(strings, 'desc')).to.eql(['阿', '一', 'B', 'b', 'á', 'A', 'a', '2', '10', '1']); | ||
expect(sortBy(strings, 'desc-num')).to.eql(['阿', '一', 'B', 'b', 'á', 'A', 'a', '10', '2', '1']); | ||
expect(sortBy(strings, 'desc-bin')).to.eql(['阿', '一', 'á', 'b', 'a', 'B', 'A', '2', '10', '1']); | ||
expect(sortBy(strings, 'desc-upper')).to.eql(['阿', '一', 'b', 'B', 'á', 'a', 'A', '2', '10', '1']); | ||
}); | ||
}); | ||
}); |
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