Skip to content

Commit

Permalink
docs(Morse): Fix import instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlexLichter committed Mar 31, 2018
1 parent 6cd7ec1 commit 8bc6782
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions docs/ciphers/morse.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,28 @@ const options = {
#### Default

```
// Direct import if you need encode and decode
import { morse } from 'cipher-collection'
// morse.encode()/morse.decoode()
// Alternative
import { encode } from 'cipher-collection/morse'
console.log(encode('SOS')) // ... --- ...
console.log(morse.encode('SOS')) // ... --- ...
```

#### With custom glue

```
import { encode } from 'cipher-collection/morse'
import { morse } from 'cipher-collection'
const options = { separator: '~' }
console.log(encode('SOS', options)) // ...~---~...
console.log(morse.encode('SOS', options)) // ...~---~...
```

#### Without error throwing

There are **two options** when disabling errors:

```
import { encode } from 'cipher-collection/morse'
import { morse } from 'cipher-collection'
const preserveOptions = {
separator: '',
Expand All @@ -63,7 +58,7 @@ const preserveOptions = {
}
// Preserve chraracters that can't get encoded
console.log(encode('€€€', preserveOptions)) // €€€
console.log(morse.encode('€€€', preserveOptions)) // €€€
const omitOptions = {
separator: '',
Expand All @@ -72,7 +67,7 @@ const omitOptions = {
}
// omit chraracters that can't get encoded
console.log(encode('€€€S', omitOptions)) // ...
console.log(morse.encode('€€€S', omitOptions)) // ...
```


Expand All @@ -81,41 +76,41 @@ console.log(encode('€€€S', omitOptions)) // ...
#### Default

```
import { decode } from 'cipher-collection/morse'
import { morse } from 'cipher-collection'
console.log(decode('... --- ...')) // SOS
console.log(morse.decode('... --- ...')) // SOS
```

#### With custom delimiter

```
import { decode } from 'cipher-collection/morse'
import { morse } from 'cipher-collection'
const options = { separator: '~' }
console.log(decode('...~---~...', options)) // SOS
console.log(morse.decode('...~---~...', options)) // SOS
```

#### Without error throwing

Similar to `encode`, there are **two options** when disabling errors:

```
import { decode } from 'cipher-collection/morse'
import { morse } from 'cipher-collection'
const preserveOptions = {
failOnUnknownCharacter: false,
omitUnknownCharacter: false
}
// Preserve chraracters that can't get decoded
console.log(decode('.-.-.-.-.-', preserveOptions)) // .-.-.-.-.-
console.log(morse.decode('.-.-.-.-.-', preserveOptions)) // .-.-.-.-.-
const omitOptions = {
failOnUnknownCharacter: false,
omitUnknownCharacter: true
}
// omit chraracters that can't get decoded
console.log(decode('.-.-.-.-.- ...', omitOptions)) // S
console.log(morse.decode('.-.-.-.-.- ...', omitOptions)) // S
```

0 comments on commit 8bc6782

Please sign in to comment.