Skip to content

Commit

Permalink
added exports to index
Browse files Browse the repository at this point in the history
  • Loading branch information
dopecodez committed Aug 31, 2021
1 parent bc62c33 commit f4f5c32
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,25 @@ const wiki = require('wikipedia');
})();
```

You can export types or even specific methods if you are using modern ES6 js or TypeScript.
```js
import wiki from 'wikipedia';
import { wikiSummary, summaryError } from 'wikipedia';
import { summary } from 'wikipedia';

(async () => {
try {
let summary: wikiSummary; //sets the object as type wikiSummary
summary = await wiki.summary('Batman');
console.log(summary);
let summary2 = await summary('Batman');//using summary directly
} catch (error) {
console.log(error);
//=> Typeof summaryError, helpful in case you want to handle this error separately
}
})();
```

## Options

All methods have options you can pass them. You can find them in [optionTypes documentation][5].
Expand Down
5 changes: 5 additions & 0 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,3 +589,8 @@ export default wiki;
// For CommonJS default export support
module.exports = wiki;
module.exports.default = wiki;

export * from './errors';
export * from './resultTypes';
export * from './optionTypes';
export * from './page';

0 comments on commit f4f5c32

Please sign in to comment.