Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding default to exports for ES6 and updating TS definitions #113

Merged
merged 1 commit into from
Mar 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
adding default to exports for ES6 and updating TS definitions to remo…
…ve anys
  • Loading branch information
riley-stroud-ck committed Feb 28, 2017
commit b32036134b01773053add6044eddcafca4da6d95
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ or link with `script` in html files:
<script src="dist/timeago.min.js"></script>
```

or import to a typescript file
```ts
impor timeago from 'timeago.js';

// or

import timeago = require("timeago.js");
```

**3. Use class `timeago`**

```js
Expand Down Expand Up @@ -151,12 +160,12 @@ var test_local_dict = function(number, index) {
};
// register your locale with timeago
timeago.register('test_local', test_local_dict);
// use the locale with timeago instance
// use the locale with timeago instance
var timeagoInstance = new timeago();
timeagoInstance.format('2016-06-12', 'test_local');
```

You can see [locales](locales) dir for more locales.
You can see [locales](locales) dir for more locales.

[Locale contributions](#3-contributions) are welcomed, thank you for submitting a GitHub pull request for corrections or additional languages. ^_^~

Expand All @@ -167,7 +176,7 @@ You can see [locales](locales) dir for more locales.

2. **locale translations**: The library needs more locale translations. You can:

- Open an issue to write the locale translations, or submit a pull request. How to ? see [en's translation](locales/en.js).
- Open an issue to write the locale translations, or submit a pull request. How to ? see [en's translation](locales/en.js).
- Please **test** the locale by exec `npm test` or `node tests/locales_test.js`. How to write testcase, see [en's test cases](tests/locales/en.js).


Expand Down
6 changes: 4 additions & 2 deletions src/timeago.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
**/
/* jshint expr: true */
!function (root, factory) {
if (typeof module === 'object' && module.exports)
module.exports = factory(root);
if (typeof module === 'object' && module.exports) {
module.exports = factory(root); // nodejs support
module.exports['default'] = module.exports; // es6 support
}
else
root.timeago = factory(root);
}(typeof window !== 'undefined' ? window : this,
Expand Down
6 changes: 3 additions & 3 deletions timeago.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export interface TimeAgoConstructor {
}
export interface TimeagoFactory {
(): TimeAgoConstructor;
(nowDate: any): TimeAgoConstructor;
(nowDate: any, defaultLocale: any): TimeAgoConstructor;
register(locale: any, localeFunc: any): any;
(nowDate: string): TimeAgoConstructor;
(nowDate: string, defaultLocale: string): TimeAgoConstructor;
register(locale: string, localeFunc: Function): void;
}
declare let timeagoFactory: TimeagoFactory;
export default timeagoFactory;