Skip to content

Commit

Permalink
Gender 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Jan 11, 2022
1 parent 298f02b commit bdb5f28
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 22 deletions.
13 changes: 6 additions & 7 deletions .editorconfig
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Global
node_modules/
coverage

# OS Generated
.DS_Store*
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<a name="2.1.0"></a>
# [2.1.0](https://github.com/faker-javascript/gender) (2022-01-11)
* Added xo, tsd, c8.
* Improved tests.

<a name="2.0.1"></a>
# [2.0.1](https://github.com/faker-javascript/gender) (2022-01-10)
* GitHub docs updates.
Expand Down
5 changes: 5 additions & 0 deletions index.d.ts
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;
23 changes: 12 additions & 11 deletions index.js
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;
};
}
6 changes: 6 additions & 0 deletions index.test-d.ts
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']}));
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fakerjs/gender",
"version": "2.0.1",
"version": "2.1.0",
"description": "Gender package provides functionality to generate a fake gender value.",
"license": "MIT",
"repository": "faker-javascript/gender",
Expand All @@ -15,13 +15,17 @@
"node": ">=12"
},
"scripts": {
"test": "ava"
"test": "c8 ava; xo --space 4; tsd;"
},
"devDependencies": {
"ava": "^3.15.0"
"ava": "^4.0.0",
"c8": "^7.11.0",
"tsd": "^0.19.1",
"xo": "^0.47.0"
},
"files": [
"index.js"
"index.js",
"index.d.ts"
],
"keywords": [
"fakerjs",
Expand Down

0 comments on commit bdb5f28

Please sign in to comment.