-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
44 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
# EditorConfig: http://EditorConfig.org | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.{js,d.ts,ts}] | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# 2 space indentation | ||
[*.yaml, *.yml] | ||
[package.json,*.yaml] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Global | ||
node_modules/ | ||
coverage | ||
|
||
# OS Generated | ||
.DS_Store* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
interface Options { | ||
locale?: string; | ||
extra?: string[]; | ||
} | ||
export default function gender(options?: Options): string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
/* eslint camelcase: ["error", {properties: "never"}] */ | ||
export default function gender(options) { | ||
options = options || {}; | ||
let genders = { | ||
"en_US": [ | ||
"Male", | ||
"Female" | ||
const genders = { | ||
en_US: [ | ||
'Male', | ||
'Female', | ||
], | ||
"ru_RU": [ | ||
"Мужской", | ||
"Женский" | ||
ru_RU: [ | ||
'Мужской', | ||
'Женский', | ||
], | ||
}; | ||
let locale = options.locale || 'en_US'; | ||
let gendersWithExtra = genders[locale].concat(options.extra || []); | ||
let randomGender = gendersWithExtra[Math.floor(Math.random() * gendersWithExtra.length)]; | ||
const locale = options.locale || 'en_US'; | ||
const gendersWithExtra = [...genders[locale], ...options.extra || []]; | ||
const randomGender = gendersWithExtra[Math.floor(Math.random() * gendersWithExtra.length)]; | ||
return randomGender; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {expectType} from 'tsd'; | ||
import gender from './index.js'; | ||
|
||
expectType<string>(gender()); | ||
expectType<string>(gender({locale: 'en_US'})); | ||
expectType<string>(gender({locale: 'en_US', extra: ['gender']})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters