Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace setToArray() with Array.from #1050

Merged
merged 3 commits into from
Jun 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 2 additions & 22 deletions src/modules/system/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,6 @@ const commonMimeTypes = [
'text/html',
];

/**
* Converts the given set to an array.
*
* @param set The set to convert.
*/
// TODO ST-DDT 2022-03-11: Replace with Array.from(Set)
function setToArray<T>(set: Set<T>): T[] {
// shortcut if Array.from is available
if (Array.from) {
return Array.from(set);
}

const array: T[] = [];
set.forEach((item) => {
array.push(item);
});
return array;
}

/**
* Generates fake data for many computer systems properties.
*/
Expand Down Expand Up @@ -121,7 +102,7 @@ export class System {
typeSet.add(type);
});

const types = setToArray(typeSet);
const types = Array.from(typeSet);
return this.faker.helpers.arrayElement(types);
}

Expand Down Expand Up @@ -151,8 +132,7 @@ export class System {
}
});

const extensions = setToArray(extensionSet);

const extensions = Array.from(extensionSet);
return this.faker.helpers.arrayElement(extensions);
}

Expand Down