JavaScript开源:Xmorse - 摩斯密码编码库
eaqo1843
8年前
<h2>Xmorse</h2> <p>Xmorseis a pure javascript(~1.4kb) library for encoding / decoding morse code messages, <strong>unicode supported</strong> .</p> <p>1. Install</p> <p>npm install xmorse</p> <p>Or download dist/xmorse.min.js source file。</p> <h2>2. Import It</h2> <ul> <li>Script tag.</li> </ul> <pre> <code class="language-javascript"><script type="text/javascript" src="dist/xmorse.min.js"></script></code></pre> <ul> <li>ES6 style.</li> </ul> <pre> <code class="language-javascript">var xmorse = require('xmorse'); //or import xmorse from 'xmorse';</code></pre> <h2>3. Usage & API</h2> <p>There is only 2 API named encode , decode .</p> <p>For encode(msg) , example:</p> <pre> <code class="language-javascript">// standart morse xmorse.encode('Hello, Xmorse!'); // unicode xmorse.encode('コンニチハ, セカイ!'); xmorse.encode('越过长城,走向世界');</code></pre> <p>For decode(morse) , example:</p> <pre> <code class="language-javascript">xmorse.decode('../.-../---/...-/./-.--/---/..-/-/---/---/--...-....-...-/-..---..-.-----/---..-...--...-/-..----.--.....');</code></pre> <h2>4. Test</h2> <p>npm install</p> <p>npm test</p> <h2> </h2> <p> </p> <p> </p>