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

fix: removed dead code and adjusted fileExt #304

Merged
merged 4 commits into from
Feb 1, 2022
Merged
Changes from 1 commit
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
37 changes: 0 additions & 37 deletions src/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,6 @@ export class System {
* faker.system.mimeType() // 'video/vnd.vivo'
*/
mimeType(): string {
const typeSet = new Set<string>();
const extensionSet = new Set();
const mimeTypes = this.faker.definitions.system.mimeTypes;

Object.keys(mimeTypes).forEach((m) => {
const type = m.split('/')[0];

typeSet.add(type);

if (mimeTypes[m].extensions instanceof Array) {
mimeTypes[m].extensions.forEach((ext) => {
extensionSet.add(ext);
});
}
});

const types = setToArray(typeSet);
const extensions = setToArray(extensionSet);
const mimeTypeKeys = Object.keys(this.faker.definitions.system.mimeTypes);

return this.faker.random.arrayElement(mimeTypeKeys);
Expand Down Expand Up @@ -145,8 +127,6 @@ export class System {
});

const types = setToArray(typeSet);
const extensions = setToArray(extensionSet);
const mimeTypeKeys = Object.keys(this.faker.definitions.system.mimeTypes);
return this.faker.random.arrayElement(types);
}

Expand All @@ -160,25 +140,8 @@ export class System {
* faker.system.fileExt('application/json') // 'json'
*/
fileExt(mimeType?: string): string {
const typeSet = new Set<string>();
const extensionSet = new Set<string>();
const mimeTypes = this.faker.definitions.system.mimeTypes;

Object.keys(mimeTypes).forEach((m) => {
const type = m.split('/')[0];

typeSet.add(type);

if (mimeTypes[m].extensions instanceof Array) {
mimeTypes[m].extensions.forEach((ext) => {
extensionSet.add(ext);
ST-DDT marked this conversation as resolved.
Show resolved Hide resolved
});
}
});

const types = setToArray(typeSet);
const extensions = setToArray(extensionSet);
ST-DDT marked this conversation as resolved.
Show resolved Hide resolved
const mimeTypeKeys = Object.keys(this.faker.definitions.system.mimeTypes);

if (mimeType) {
const mimes = this.faker.definitions.system.mimeTypes;
Expand Down