Task description
- 基于
Set 对象交集、差集 API 加速“列表差异对比”函数
- 基于
Uint8Array 对象 Base64、Hex 方法简化多个数据函数
- 升级基础设施到 TypeScript 6、PNPM 11
Document
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/intersection
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/fromBase64
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/toBase64
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/toHex
Target
|
export function diffKeys<T extends IndexKey>(oldList: T[], newList: T[]) { |
|
const map = {} as Record<T, DiffStatus>; |
|
|
|
for (const item of oldList) map[item] = DiffStatus.Old; |
|
|
|
for (const item of newList) { |
|
map[item] ||= 0; |
|
map[item] += DiffStatus.New; |
|
} |
|
|
|
return { |
|
map, |
|
group: groupBy( |
|
Object.entries<DiffStatus>(map), |
|
([key, status]) => status |
|
) |
|
}; |
|
} |
|
/** |
|
* Encode string to Base64 with Unicode support |
|
* |
|
* @param input - String to encode |
|
* @returns Base64 encoded string |
|
*/ |
|
export const encodeBase64 = (input: string) => |
|
btoa(String.fromCharCode(...new TextEncoder().encode(input))); |
|
|
|
/** |
|
* Decode Base64 string with Unicode support |
|
* |
|
* @param input - Base64 encoded string to decode |
|
* @returns Decoded Unicode string |
|
*/ |
|
export const decodeBase64 = (input: string) => |
|
new TextDecoder().decode( |
|
Uint8Array.from(atob(input), char => char.charCodeAt(0)) |
|
); |
Reward currency
TQT $
Reward amount
45
Reward payer
石垚 tech-query@idea2app.cn
Task source
https://idea2app.feishu.cn/record/PHFwrmKOceCEv4cvjL7cxrpJnWg
Task description
Set对象交集、差集 API 加速“列表差异对比”函数Uint8Array对象 Base64、Hex 方法简化多个数据函数Document
Target
web-utility/source/data.ts
Lines 121 to 138 in 0530fc2
web-utility/source/data.ts
Lines 99 to 117 in 190843a
Reward currency
TQT $
Reward amount
45
Reward payer
石垚 tech-query@idea2app.cn
Task source
https://idea2app.feishu.cn/record/PHFwrmKOceCEv4cvjL7cxrpJnWg