Skip to content

faykah/person-titles-en

Repository files navigation

@faykah/person-titles-en

An English dataset of person titles.

Summary

About

Faykah is a Node.js library that help create generators for various data.

This library contains a data set of English person titles (like Mr, Mrs, ...) suited for mocking and testing emails.

Features

  • Provides a list of 5 person titles
  • Provides a browser version
  • Provides its own Typescript type definition

Installation

Using NPM:

npm install --save-dev @faykah/person-titles-en

Using Yarn:

yarn add --dev @faykah/person-titles-en

Examples

1. Create an array generator

In this example, we will create a person title generator.

ES6

import { createGenerator } from "@faykah/core";
import { personTitles } from "@faykah/person-titles-en";

const generatePersonTitle = createGenerator(personTitles);

generatePersonTitle(); // "Mrs"
generatePersonTitle(); // "Dr"
generatePersonTitle(); // "Mr"

CJS

const { createGenerator } = require("@faykah/core");
const { personTitles } = require("@faykah/person-titles-en");

const generatePersonTitle = createGenerator(personTitles);

generatePersonTitle(); // "Mrs"
generatePersonTitle(); // "Dr"
generatePersonTitle(); // "Mr"

Browser

<body>
	<script type="text/javascript" src="https://unpkg.com/@faykah/[email protected]/lib/index.browser.min.js" defer></script>
	<script type="text/javascript" src="https://unpkg.com/@faykah/[email protected]/lib/index.browser.min.js" defer></script>

	<script type="text/javascript" defer>
		const { createGenerator } = Faykah;
		const { personTitles } = Faykah.personTitles;

		const generateTitle = createGenerator(personTitles);

		console.log(generateTitle());
		console.log(generateTitle());
		console.log(generateTitle());
	</script>
</body>

2. Standalone usage

In this example, we will loop through all the person titles.

ES6

import { personTitles } from "@faykah/person-titles-en";

for (const personTitle of personTitles) {
	console.log(personTitle);
}

CJS

const { personTitles } = require("@faykah/person-titles-en");

for (const personTitle of personTitles) {
	console.log(personTitle);
}

Browser

<body>
	<script type="text/javascript" src="https://unpkg.com/@faykah/[email protected]/lib/index.browser.min.js" defer></script>
	<script type="text/javascript" src="https://unpkg.com/@faykah/[email protected]/lib/index.browser.min.js" defer></script>

	<script type="text/javascript" defer>
		const { personTitles } = Faykah.personTitles;

		for (const personTitle of personTitles) {
			console.log(personTitle);
		}
	</script>
</body>