Skip to content

Commit

Permalink
refactor(yaml): simplify resolve() for pairs (denoland#5852)
Browse files Browse the repository at this point in the history
initial commit
  • Loading branch information
timreichen committed Aug 29, 2024
1 parent 8b9a139 commit 745c4a6
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions yaml/_type/pairs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"> = {
Expand Down

0 comments on commit 745c4a6

Please sign in to comment.