Skip to content

Commit 5ae9a9f

Browse files
committed
Update docs
1 parent af47a96 commit 5ae9a9f

File tree

6 files changed

+111
-64
lines changed

6 files changed

+111
-64
lines changed

packages/franc-all/readme.md

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ usage information.
1111

1212
## Install
1313

14+
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
15+
Node 12+ is needed to use it and it must be
16+
`import`ed instead of `require`d.
17+
1418
npm:
1519

1620
```sh

packages/franc-cli/readme.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and usage information.
77

88
## Install
99

10+
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
11+
Node 12+ is needed to use it.
12+
1013
npm:
1114

1215
```sh

packages/franc-min/readme.md

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ usage information.
1111

1212
## Install
1313

14+
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
15+
Node 12+ is needed to use it and it must be
16+
`import`ed instead of `require`d.
17+
1418
npm:
1519

1620
```sh

packages/franc/readme.md

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ usage information.
1111

1212
## Install
1313

14+
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
15+
Node 12+ is needed to use it and it must be
16+
`import`ed instead of `require`d.
17+
1418
npm:
1519

1620
```sh

readme.md

+31-16
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Make sure to pass it big documents to get reliable results.
2323

2424
## Install
2525

26+
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
27+
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
28+
2629
[npm][]:
2730

2831
```sh
@@ -40,8 +43,11 @@ available on [GitHub Releases][releases].
4043

4144
## Use
4245

46+
This package exports the following identifiers: `franc`, `francAll`.
47+
There is no default export.
48+
4349
```js
44-
var franc = require('franc')
50+
import {franc, francAll} from 'franc'
4551

4652
franc('Alle menslike wesens word vry') // => 'afr'
4753
franc('এটি একটি ভাষা একক IBM স্ক্রিপ্ট') // => 'ben'
@@ -57,47 +63,56 @@ franc('the', {minLength: 3}) // => 'sco'
5763
###### `.all`
5864

5965
```js
60-
console.log(franc.all('O Brasil caiu 26 posições'))
66+
console.log(francAll('Considerando ser essencial que os direitos humanos'))
6167
```
6268

6369
Yields:
6470

6571
```js
66-
[ [ 'por', 1 ],
67-
[ 'src', 0.8797557538750587 ],
68-
[ 'glg', 0.8708313762329732 ],
69-
[ 'snn', 0.8633161108501644 ],
70-
[ 'bos', 0.8172851103804604 ],
71-
... 116 more items ]
72+
[
73+
[ 'por', 1 ],
74+
[ 'glg', 0.771284519307895 ],
75+
[ 'spa', 0.6034146900423971 ],
76+
[ 'cat', 0.5367251059928957 ],
77+
[ 'src', 0.47461899851037015 ],
78+
... 122 more items ]
7279
```
7380

7481
###### `only`
7582

7683
```js
77-
console.log(franc.all('O Brasil caiu 26 posições', {only: ['por', 'spa']}))
84+
console.log(
85+
francAll('Considerando ser essencial que os direitos humanos', {
86+
only: ['por', 'spa']
87+
})
88+
)
7889
```
7990

8091
Yields:
8192

8293
```js
83-
[ [ 'por', 1 ], [ 'spa', 0.799906059182715 ] ]
94+
[ [ 'por', 1 ], [ 'spa', 0.6034146900423971 ] ]
8495
```
8596

8697
###### `ignore`
8798

8899
```js
89-
console.log(franc.all('O Brasil caiu 26 posições', {ignore: ['src', 'glg']}))
100+
console.log(
101+
francAll('Considerando ser essencial que os direitos humanos', {
102+
ignore: ['src', 'glg']
103+
})
104+
)
90105
```
91106

92107
Yields:
93108

94109
```js
95110
[ [ 'por', 1 ],
96-
[ 'snn', 0.8633161108501644 ],
97-
[ 'bos', 0.8172851103804604 ],
98-
[ 'hrv', 0.8107092531705026 ],
99-
[ 'lav', 0.810239549084077 ],
100-
... 114 more items ]
111+
[ 'spa', 0.6034146900423971 ],
112+
[ 'cat', 0.5367251059928957 ],
113+
[ 'ita', 0.4740460639394981 ],
114+
[ 'fra', 0.44757648676521145 ],
115+
... 120 more items ]
101116
```
102117

103118
## CLI

script/build.js

+65-48
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,25 @@ async function main() {
378378
depth: 2,
379379
children: [{type: 'text', value: 'Install'}]
380380
},
381+
{
382+
type: 'paragraph',
383+
children: [
384+
{type: 'text', value: 'This package is '},
385+
{
386+
type: 'link',
387+
url: 'https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c',
388+
children: [{type: 'text', value: 'ESM only'}]
389+
},
390+
{
391+
type: 'text',
392+
value: ':\nNode 12+ is needed to use it and it must be\n'
393+
},
394+
{type: 'inlineCode', value: 'import'},
395+
{type: 'text', value: 'ed instead of '},
396+
{type: 'inlineCode', value: 'require'},
397+
{type: 'text', value: 'd.'}
398+
]
399+
},
381400
{type: 'paragraph', children: [{type: 'text', value: 'npm:'}]},
382401
{type: 'code', lang: 'sh', value: 'npm install ' + pack.name},
383402
{
@@ -409,7 +428,52 @@ async function main() {
409428
}
410429
]
411430
},
412-
...list.map((d) => row(d))
431+
...list.map((info) => ({
432+
type: 'tableRow',
433+
children: [
434+
{
435+
type: 'tableCell',
436+
children: [
437+
{
438+
type: 'link',
439+
url:
440+
'http://www-01.sil.org/iso639-3/documentation.asp?id=' +
441+
info.code,
442+
title: null,
443+
children: [{type: 'inlineCode', value: info.code}]
444+
}
445+
]
446+
},
447+
{
448+
type: 'tableCell',
449+
children: [
450+
{
451+
type: 'text',
452+
value:
453+
info.name +
454+
(counts[info.code] === 1
455+
? ''
456+
: ' (' + info.script + ')')
457+
}
458+
]
459+
},
460+
{
461+
type: 'tableCell',
462+
children: [
463+
{
464+
type: 'text',
465+
value:
466+
typeof info.speakers === 'number'
467+
? info.speakers.toLocaleString('en', {
468+
notation: 'compact',
469+
maximumFractionDigits: 0
470+
})
471+
: 'unknown'
472+
}
473+
]
474+
}
475+
]
476+
}))
413477
]
414478
},
415479
{
@@ -437,53 +501,6 @@ async function main() {
437501
}
438502

439503
return unified().use(stringify).use(gfm).stringify(tree)
440-
441-
function row(info) {
442-
return {
443-
type: 'tableRow',
444-
children: [
445-
{
446-
type: 'tableCell',
447-
children: [
448-
{
449-
type: 'link',
450-
url:
451-
'http://www-01.sil.org/iso639-3/documentation.asp?id=' +
452-
info.code,
453-
title: null,
454-
children: [{type: 'inlineCode', value: info.code}]
455-
}
456-
]
457-
},
458-
{
459-
type: 'tableCell',
460-
children: [
461-
{
462-
type: 'text',
463-
value:
464-
info.name +
465-
(counts[info.code] === 1 ? '' : ' (' + info.script + ')')
466-
}
467-
]
468-
},
469-
{
470-
type: 'tableCell',
471-
children: [
472-
{
473-
type: 'text',
474-
value:
475-
typeof info.speakers === 'number'
476-
? info.speakers.toLocaleString('en', {
477-
notation: 'compact',
478-
maximumFractionDigits: 0
479-
})
480-
: 'unknown'
481-
}
482-
]
483-
}
484-
]
485-
}
486-
}
487504
}
488505

489506
function count(list) {

0 commit comments

Comments
 (0)