# mock-ch-names

> Create mock Swiss names together with an appropriate location

Latest version **0.0.3** (published 2022-07-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install mock-ch-names
pnpm add mock-ch-names
yarn add mock-ch-names
bun add mock-ch-names
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2022-07-21 |
| First published | 2022-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 854.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Marcel Waldvogel |
| Maintainers | marcelwaldvogel |

## Links

- npm: https://www.npmjs.com/package/mock-ch-names
- Repository: https://github.com/MarcelWaldvogel/mock-ch-names
- npm.io page: https://npm.io/package/mock-ch-names

## Recent versions

- 0.0.3 (latest) — 2022-07-21
- 0.0.2 — 2022-07-21
- 0.0.1 — 2022-07-21

## README

# Swiss Mock names

## Quickstart: JavaScript/TypeScript API

Install the module as follows:

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

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

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

console.log(mockNameLocation());
```

Possible output:

```typescript
{
  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:

- [`vornamen_proplz`](https://swisspost.opendatasoft.com/explore/dataset/vornamen_proplz/information/):
  CC-BY, Die Schweizerische Post (2022-07-01)
- [`nachnamen_proplz`](https://swisspost.opendatasoft.com/explore/dataset/nachnamen_proplz/information/):
  CC-BY, Die Schweizerische Post (2022-07-01)
- [`plz_verzeichnis_v2`](https://swisspost.opendatasoft.com/explore/dataset/plz_verzeichnis_v2/information/):
  CC-BY, Die Schweizerische Post (2022-07-11)

## 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:

```typescript
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.)

---
_Source: https://npm.io/package/mock-ch-names · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
