Code Monkey home page Code Monkey logo

mock-ch-names's Introduction

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

mock-ch-names's People

Contributors

marcelwaldvogel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.