added all files to project

This commit is contained in:
2022-03-10 10:36:59 +01:00
parent 09dd957b33
commit 46a936d7de
25351 changed files with 3883356 additions and 0 deletions
@@ -0,0 +1,30 @@
'use strict'
const berlin2 = /^berlin,\s+/i
const strasse = /(stra(ss|ß)e)[^\w]/i
const bahnhof = /,\s+bahnhof(?=[^\w])/i
const hauptbahnhof = /,\s+hauptbahnhof(?=[^\w])/i
const bhf = /[^,]\s+bhf(?=[^\w])/i
const bln = /[^\w]\(bln\)/i
const berlin = /[^\w]\(berlin\)/i
const xBhf = /\s([us])-bh?f\.?(?=[^\w])/i
const shorten = (n) => {
n = n.replace(berlin2, '')
n = ` ${n} ` // regexes work now
.replace(bhf, (m) => m[0])
.replace(bahnhof, ', Bhf')
.replace(hauptbahnhof, ', Hbf')
.replace(bln, '')
.replace(berlin, '')
.replace(xBhf, ' $1')
// …strasse -> …str.
let m = strasse.exec(n)
if (m) n =
n.substr(0, m.index) + m[1].substr(0, 3) + '.'
+ n.substr(m.index + m[1].length)
return n.trim()
}
module.exports = shorten
@@ -0,0 +1,5 @@
Copyright (c) 2017, Jannis R
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,64 @@
{
"_from": "vbb-short-station-name@^1.0.1",
"_id": "vbb-short-station-name@1.0.1",
"_inBundle": false,
"_integrity": "sha512-3pAW9RtwqTeQvTABYRJVkBNmbxkCBxrQyALNRkG+owiZUgt4yT3aH2ln25TV0EzEqZzgjVjcK1RwOyL/MMYz5w==",
"_location": "/vbb-short-station-name",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "vbb-short-station-name@^1.0.1",
"name": "vbb-short-station-name",
"escapedName": "vbb-short-station-name",
"rawSpec": "^1.0.1",
"saveSpec": null,
"fetchSpec": "^1.0.1"
},
"_requiredBy": [
"/hafas-client"
],
"_resolved": "https://registry.npmjs.org/vbb-short-station-name/-/vbb-short-station-name-1.0.1.tgz",
"_shasum": "e6d89a16795b6999d3b43092ac9d8bed90103fdd",
"_spec": "vbb-short-station-name@^1.0.1",
"_where": "/home/pi/MagicMirror/modules/MMM-PublicTransportHafas/node_modules/hafas-client",
"author": {
"name": "Jannis R",
"email": "mail@jannisr.de"
},
"bugs": {
"url": "https://github.com/derhuerst/vbb-short-station-name/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Remove noise from VBB station names.",
"devDependencies": {
"tap-min": "^1.2.1",
"tape": "^4.6.3"
},
"engines": {
"node": ">=6"
},
"files": [
"index.js"
],
"homepage": "https://github.com/derhuerst/vbb-short-station-name",
"keywords": [
"vbb",
"stations",
"short",
"shorten"
],
"license": "ISC",
"main": "index.js",
"name": "vbb-short-station-name",
"repository": {
"type": "git",
"url": "git+https://github.com/derhuerst/vbb-short-station-name.git"
},
"scripts": {
"prepublishOnly": "npm test",
"test": "tape test.js | tap-min"
},
"version": "1.0.1"
}
@@ -0,0 +1,36 @@
# vbb-short-station-name
**Removes stuff like " (Berlin)" from station names.** Shortens "strasse" to "str.".
- `S+U Foobar Bhf` -> `S+U Foobar`
- `S+U Foo Bar (Berlin)` -> `S+U Foo Bar`
- `S Foo-Straße` -> `S Foo-Str.`
- `S Foostrasse` -> `S Foostr.`
[![npm version](https://img.shields.io/npm/v/vbb-short-station-name.svg)](https://www.npmjs.com/package/vbb-short-station-name)
[![build status](https://img.shields.io/travis/derhuerst/vbb-short-station-name.svg)](https://travis-ci.org/derhuerst/vbb-short-station-name)
[![dependency status](https://img.shields.io/david/derhuerst/vbb-short-station-name.svg)](https://david-dm.org/derhuerst/vbb-short-station-name)
[![dev dependency status](https://img.shields.io/david/dev/derhuerst/vbb-short-station-name.svg)](https://david-dm.org/derhuerst/vbb-short-station-name#info=devDependencies)
![ISC-licensed](https://img.shields.io/github/license/derhuerst/vbb-short-station-name.svg)
[![gitter channel](https://badges.gitter.im/derhuerst/vbb-rest.svg)](https://gitter.im/derhuerst/vbb-rest)
[![support me on Patreon](https://img.shields.io/badge/support%20me-on%20patreon-fa7664.svg)](https://patreon.com/derhuerst)
## Installing
```shell
npm install vbb-short-station-name
```
## Usage
```js
const shorten = require('vbb-short-station-name')
shorten('S Südkreuz Bhf (Berlin)') // -> 'S Südkreuz'
```
## Contributing
If you **have a question**, **found a bug** or want to **propose a feature**, have a look at [the issues page](https://github.com/derhuerst/vbb-short-station-name/issues).