项目作者: perseids-tools

项目描述 :
Convert Greek Beta Code to Greek characters
高级语言: JavaScript
项目地址: git://github.com/perseids-tools/beta-code-js.git
创建时间: 2017-04-30T00:51:33Z
项目社区:https://github.com/perseids-tools/beta-code-js

开源协议:MIT License

下载


Beta Code JS

Converts Greek Beta Code to Greek characters and vice versa.

Try it Out

https://apps.perseids.org/beta-code/

Installation

yarn add beta-code-js

or

npm install beta-code-js

(See project on npm)

Usage

  1. import { greekToBetaCode, betaCodeToGreek } from 'beta-code-js';
  2. greekToBetaCode('χαῖρε ὦ κόσμε');
  3. // => 'xai=re w)= ko/sme'
  4. betaCodeToGreek('mh=nin a)/eide qea\\ *phlhi+a/dew *)axilh=os');
  5. // => 'μῆνιν ἄειδε θεὰ Πηληϊάδεω Ἀχιλῆος'

or

  1. var bc = require('beta-code-js');
  2. bc.greekToBetaCode('χαῖρε ὦ κόσμε');
  3. // => 'xai=re w)= ko/sme'
  4. bc.betaCodeToGreek('mh=nin a)/eide qea\\ *phlhi+a/dew *)axilh=os');
  5. // => 'μῆνιν ἄειδε θεὰ Πηληϊάδεω Ἀχιλῆος'

With additional mappings

  1. import { betaCodeToGreek } from 'beta-code-js';
  2. betaCodeToGreek('f2a/nac', { f2: 'ϝ' })
  3. // => 'ϝάναξ'

Usage in Browser

  1. <html>
  2. <script src="bundle/beta-code.js"></script>
  3. <body>
  4. <script>
  5. console.log(BetaCode.greekToBetaCode('χαῖρε ὦ κόσμε'));
  6. // => 'xai=re w)= ko/sme'
  7. console.log(BetaCode.betaCodeToGreek('mh=nin a)/eide qea\\ *phlhi+a/dew *)axilh=os'));
  8. // => 'μῆνιν ἄειδε θεὰ Πηληϊάδεω Ἀχιλῆος'
  9. </script>
  10. </body>
  11. </html>

Setup

yarn install

Tests

yarn test

Building for Browser

yarn bundle

Updating JSON

  1. git subtree pull --prefix vendor/beta-code-json/ https://github.com/perseids-tools/beta-code-json master --squash

In the case of a merge conflict:

  1. git checkout --theirs vendor/beta-code-json/
  2. git add vendor/beta-code-json
  3. git commit

Publishing

  • Bump version in package.json
  • Run yarn bundle
  • Commit and push to GitHub
  • On GitHub, create a new release
  • Run npm publish

Notes

For the mappings between Beta Code and Unicode, see https://github.com/perseids-tools/beta-code-json.
For an example of this package being used, see https://github.com/perseids-project/beta-code-converter-js.