Skip to content

Commit

Permalink
chore: replace setToArray() with Array.from (#1050)
Browse files Browse the repository at this point in the history
  • Loading branch information
kris71990 authored Jun 10, 2022
1 parent 26f89ea commit e466347
Showing 1 changed file with 2 additions and 22 deletions.
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

0 comments on commit e466347

Please sign in to comment.