mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
feat(ios): nbstore swift native binding (#9211)
This commit is contained in:
@@ -9,9 +9,9 @@ rand = { workspace = true }
|
||||
sha3 = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
rayon = { workspace = true }
|
||||
criterion2 = { workspace = true }
|
||||
criterion2 = { workspace = true }
|
||||
rayon = { workspace = true }
|
||||
|
||||
[[bench]]
|
||||
name = "hashcash"
|
||||
harness = false
|
||||
name = "hashcash"
|
||||
|
||||
@@ -13,6 +13,10 @@ export function universalId({ peer, type, id }: StorageOptions) {
|
||||
return `@peer(${peer});@type(${type});@id(${id});`;
|
||||
}
|
||||
|
||||
export function isValidSpaceType(type: string): type is SpaceType {
|
||||
return type === 'workspace' || type === 'userspace';
|
||||
}
|
||||
|
||||
export function isValidUniversalId(opts: Record<string, string>): boolean {
|
||||
const requiredKeys: Array<keyof StorageOptions> = [
|
||||
'peer',
|
||||
@@ -26,11 +30,11 @@ export function isValidUniversalId(opts: Record<string, string>): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
return opts.type === 'userspace' || opts.type === 'workspace';
|
||||
return isValidSpaceType(opts.type);
|
||||
}
|
||||
|
||||
export function parseUniversalId(id: string) {
|
||||
const result: Record<string, string> = {};
|
||||
const result: Partial<StorageOptions> = {};
|
||||
let key = '';
|
||||
let value = '';
|
||||
let isInValue = false;
|
||||
@@ -44,6 +48,7 @@ export function parseUniversalId(id: string) {
|
||||
// when we are in value string, we only care about ch and next char to be [')', ';'] to end the id part
|
||||
if (isInValue) {
|
||||
if (ch === ')' && nextCh === ';') {
|
||||
// @ts-expect-error we know the key is valid
|
||||
result[key] = value;
|
||||
key = '';
|
||||
value = '';
|
||||
@@ -77,7 +82,7 @@ export function parseUniversalId(id: string) {
|
||||
);
|
||||
}
|
||||
|
||||
return result as any;
|
||||
return result as StorageOptions;
|
||||
}
|
||||
|
||||
export interface Storage {
|
||||
|
||||
Reference in New Issue
Block a user