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: fix JSDoc comments in system.ts #298

Merged
merged 1 commit into from
Jan 25, 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
63 changes: 39 additions & 24 deletions src/system.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// generates fake data for many computer systems properties

import type { Faker } from '.';

const commonFileTypes = ['video', 'audio', 'image', 'text', 'application'];
Expand Down Expand Up @@ -29,6 +27,9 @@ function setToArray<T>(set: Set<T>): T[] {
return array;
}

/**
* Generates fake data for many computer systems properties.
*/
export class System {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
Expand All @@ -41,9 +42,10 @@ export class System {
}

/**
* generates a file name
* Returns a random file name with extension.
*
* @method faker.system.fileName
* @example
* faker.system.fileName() // 'self_enabling_accountability_toys.kpt'
*/
fileName() {
let str = this.faker.random.words();
Expand All @@ -53,10 +55,13 @@ export class System {
}

/**
* commonFileName
* Returns a random file name with a given extension or a commonly used extension.
*
* @method faker.system.commonFileName
* @param ext
* @param ext Extension

* @example
* faker.system.commonFileName() // 'dollar.jpg'
* faker.system.commonFileName('txt') // 'global_borders_wyoming.txt'
*/
commonFileName(ext): string {
let str = this.faker.random.words();
Expand All @@ -66,9 +71,10 @@ export class System {
}

/**
* mimeType
* Returns a mime-type.
*
* @method faker.system.mimeType
* @example
* faker.system.mimeType() // 'video/vnd.vivo'
*/
mimeType() {
const typeSet = new Set<string>();
Expand All @@ -95,18 +101,20 @@ export class System {
}

/**
* Returns a commonly used file type
* Returns a commonly used file type.
*
* @method faker.system.commonFileType
* @example
* faker.system.commonFileType() // 'audio'
*/
commonFileType() {
return this.faker.random.arrayElement(commonFileTypes);
}

/**
* Returns a commonly used file extension
* Returns a commonly used file extension.
*
* @method faker.system.commonFileExt
* @example
* faker.system.commonFileExt() // 'gif'
*/
commonFileExt() {
return this.faker.system.fileExt(
Expand All @@ -115,9 +123,10 @@ export class System {
}

/**
* Returns any file type available as mime-type
* Returns a file type.
*
* @method faker.system.fileType
* @example
* faker.system.fileType() // 'message'
*/
fileType() {
const typeSet = new Set<string>();
Expand All @@ -143,10 +152,13 @@ export class System {
}

/**
* fileExt
* Returns a file extension.
*
* @param mimeType Valid [mime-type](https://github.com/jshttp/mime-db/blob/master/db.json)
*
* @method faker.system.fileExt
* @param mimeType
* @example
* faker.system.fileExt() // 'emf'
* faker.system.fileExt('application/json') // 'json'
*/
fileExt(mimeType?: string): string {
const typeSet = new Set<string>();
Expand Down Expand Up @@ -178,19 +190,21 @@ export class System {
}

/**
* Returns directory path
* Returns a directory path.
*
* @method faker.system.directoryPath
* @example
* faker.system.directoryPath() // '/etc/mail'
*/
directoryPath(): string {
const paths = this.faker.definitions.system.directoryPaths;
return this.faker.random.arrayElement(paths);
}

/**
* returns file path
* Returns a file path.
*
* @method faker.system.filePath
* @example
* faker.system.filePath() // '/usr/local/src/money.rmp.dotx'
*/
filePath() {
return this.faker.fake(
Expand All @@ -199,9 +213,10 @@ export class System {
}

/**
* semver
* Returns a [semantic version](https://semver.org).
*
* @method faker.system.semver
* @example
* faker.system.semver() // '1.1.2'
*/
semver(): string {
return [
Expand Down