Skip to content

Commit 8c09a8e

Browse files
committed
feat: use named exports, export utils from main entry point
BREAKING CHANGE: There is no longer a default export, please update any imports as per the readme
1 parent a06c7dd commit 8c09a8e

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

readme.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
[![Codecov branch](https://img.shields.io/codecov/c/github/DJTB/hatsuon/master.svg?style=flat-square)](https://codecov.io/github/DJTB/hatsuon)
99
<br />
1010
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/)
11-
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
1211
[![Code of Conduct](https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square)](./code_of_conduct.md)
1312

1413
## Why?
@@ -28,7 +27,7 @@ npm install --save hatsuon
2827
## Usage
2928

3029
```js
31-
import hatsuon from 'hatsuon';
30+
import { hatsuon } from 'hatsuon';
3231

3332
hatsuon({ reading: 'ちゅうがっこう', pitchNum: 3 });
3433
// =>
@@ -53,7 +52,7 @@ import {
5352
makePitchPattern,
5453
getPitchPatternName,
5554
getPitchNumFromPattern,
56-
} from 'hatsuon/dist/utils';
55+
} from 'hatsuon';
5756
```
5857

5958
## Related

src/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import { getMorae, makePitchPattern, getPitchPatternName } from './utils';
22

3+
export {
4+
isDigraph,
5+
getMorae,
6+
getMoraCount,
7+
makePitchPattern,
8+
getPitchPatternName,
9+
getPitchNumFromPattern,
10+
} from './utils';
11+
312
/**
413
* Returns pitch accent information for the provided word and pitch number
514
*
@@ -8,8 +17,9 @@ import { getMorae, makePitchPattern, getPitchPatternName } from './utils';
817
* @param {number} [pitchNum=-1] pitch number
918
* @returns {object} pitch data
1019
*/
11-
export default function hatsuon({ reading = '', pitchNum = -1, locale = 'JA' } = {}) {
20+
export function hatsuon({ reading = '', pitchNum = -1, locale = 'JA' } = {}) {
1221
const morae = getMorae(reading);
22+
1323
return {
1424
reading,
1525
morae,

src/index.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import hatsuon from './index';
1+
import { hatsuon } from './index';
22

33
describe('hatsuon()', () => {
44
it('sane default', () =>
@@ -9,6 +9,7 @@ describe('hatsuon()', () => {
99
pattern: [],
1010
patternName: '不詳',
1111
}));
12+
1213
it('works', () => {
1314
expect(hatsuon({ reading: 'よみかた', pitchNum: 3 })).toEqual({
1415
reading: 'よみかた',
@@ -18,6 +19,7 @@ describe('hatsuon()', () => {
1819
patternName: '中高',
1920
});
2021
});
22+
2123
it('accepts locale', () => {
2224
expect(hatsuon({ reading: 'とっきゅう', pitchNum: 0, locale: 'EN' })).toEqual({
2325
reading: 'とっきゅう',

0 commit comments

Comments
 (0)