refactor(yaml): simplify resolve() for pairs (#5852)

initial commit
This commit is contained in:
Tim Reichen 2024-08-29 02:38:29 +02:00 committed by GitHub
parent 8b9a139472
commit 745c4a61ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,20 +8,7 @@ import { isPlainObject } from "../_utils.ts";
function resolveYamlPairs(data: unknown[][]): boolean {
if (data === null) return true;
const result = Array.from({ length: data.length });
for (const [index, pair] of data.entries()) {
if (!isPlainObject(pair)) return false;
const keys = Object.keys(pair);
if (keys.length !== 1) return false;
result[index] = [keys[0], pair[keys[0] as keyof typeof pair]];
}
return true;
return data.every((it) => isPlainObject(it) && Object.keys(it).length === 1);
}
export const pairs: Type<"sequence"> = {