-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
492 additions
and
569 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
rules: { | ||
'type-enum': [ | ||
2, | ||
'always', | ||
['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test', 'wip'], | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# These are supported funding model platforms | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] | ||
patreon: # Replace with a single Patreon username | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
custom: ['https://hust.cc', 'https://paypal.me/hustcc', 'https://atool.vip'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: build | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: macOS-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [8.x, 10.x, 12.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: ci | ||
run: | | ||
npm install | ||
npm run build | ||
npm run test | ||
- name: coverall | ||
if: success() | ||
uses: coverallsapp/github-action@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,21 @@ | ||
.project | ||
.settings | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Sys | ||
.DS_STORE | ||
.idea | ||
|
||
# Node | ||
node_modules/ | ||
|
||
# Build | ||
lib | ||
esm | ||
|
||
# Test | ||
coverage | ||
node_modules/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"bracketSpacing": true, | ||
"printWidth": 120, | ||
"arrowParens": "always" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { encode, decode } from '../src'; | ||
import { STANDARD } from '../src/const'; | ||
import casual from 'casual'; | ||
|
||
describe('XMorse', function() { | ||
it('test morse unicode.', function() { | ||
// unicode | ||
expect(encode('I love you, 我爱你。')).toBe( | ||
'../.-../---/...-/./-.--/---/..-/--..--/--...-....-...-/---..-...--...-/-..----.--...../--..........-.', | ||
); | ||
expect( | ||
decode('../.-../---/...-/./-.--/---/..-/--..--/--...-....-...-/---..-...--...-/-..----.--...../--..........-.'), | ||
).toBe('ILOVEYOU,我爱你。'); | ||
}); | ||
|
||
it('test morse STANDARD.', function() { | ||
for (var k in STANDARD) { | ||
expect(encode(k)).toBe(STANDARD[k].replace(/0/g, '.').replace(/1/g, '-')); | ||
expect(decode(STANDARD[k].replace(/0/g, '.').replace(/1/g, '-'))).toBe(k); | ||
} | ||
// combine | ||
expect(encode('I love you.')).toBe('../.-../---/...-/./-.--/---/..-/.-.-.-'); | ||
expect(decode('../.-../---/...-/./-.--/---/..-/.-.-.-')).toBe('ILOVEYOU.'); | ||
}); | ||
|
||
it('test xmorse random text.', function() { | ||
// random test | ||
var w; | ||
for (var i = 10000; i >= 0; i--) { | ||
w = casual.sentence; | ||
expect(w.replace(/\s+/g, '').toLocaleUpperCase()).toBe(decode(encode(w))); | ||
} | ||
}); | ||
|
||
it('test xmorse option.', function() { | ||
// test options | ||
var option = { | ||
space: ' ', | ||
long: '-', | ||
short: '*', | ||
}; | ||
expect(encode('I love you. 我爱你', option)).toBe( | ||
'** *-** --- ***- * -*-- --- **- *-*-*- --***-****-***- ---**-***--***- -**----*--*****', | ||
); | ||
expect( | ||
decode('** *-** --- ***- * -*-- --- **- *-*-*- --***-****-***- ---**-***--***- -**----*--*****', option), | ||
).toBe('ILOVEYOU.我爱你'); | ||
|
||
expect(encode('Hello', { space: ' ' })).toBe('.... . .-.. .-.. ---'); | ||
expect(decode('.... . .-.. .-.. ---', { space: ' ' })).toBe('HELLO'); | ||
}); | ||
|
||
it('test some cases.', function() { | ||
// test some cases | ||
expect(encode('')).toBe(''); | ||
expect(decode('')).toBe(''); | ||
|
||
expect(decode('a')).toBe(''); | ||
expect(decode(' ')).toBe(''); | ||
}); | ||
}); |
Oops, something went wrong.