mock-ch-names
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Swiss Mock names

Quickstart: JavaScript/TypeScript API

Install the module as follows:

npm i mock-ch-names
# or
yarn add mock-ch-names

Use as follows to get a mock person from anywhere in Switzerland:

import { mockNameLocation } from "mock-ch-names";

console.log(mockNameLocation());

Possible output:

{
  first: 'Martin',
  last: 'Meier',
  gender: 'm',
  plz: '7208',
  town: 'Malans GR',
  townNoCanton: 'Malans',
  canton: 'GR'
}

(If the town name in the postal database does not end in the canton's abbreviation, town and townNoCanton are identical.)

To only get mock people from a particular canton, pass the canton's two-letter abbreviation (e.g., SH) as an optional parameter to mockNameLocation().

Data sources

This database of mock Swiss names is based on the following data:

Data format

Raw data

For description of the raw/ data, see the Swiss Post descriptions above.

Processed data

The data in src/data/ is JSON matching the following TypeScript types:

type NameMap = Record<
  string,
  {
    f: [Array1Plus<string>, Array1Plus<string>];
    m: [Array1Plus<string>, Array1Plus<string>];
    l: string;
    c: Canton;
  }
>;
type PlzMap = Record<string, [string, string]>;

where Array1Plus<string> is an array of at least one string (maximum five, due to the format of the Swiss Post data). Any PLZ (postal code) area which does not have at least one male/female first/last name each, will be filtered out. (E.g. "8261 Hemishofen" is missing, because the raw data does not contain any female first names. The raw files include name information only, when more than five people have the same name.)

Readme

Keywords

none

Package Sidebar

Install

npm i mock-ch-names

Weekly Downloads

3

Version

0.0.3

License

MIT

Unpacked Size

875 kB

Total Files

10

Last publish

Collaborators

  • marcelwaldvogel