Skip to content

Commit

Permalink
refactor: modernise Helper as a plain function
Browse files Browse the repository at this point in the history
  • Loading branch information
MrChocolatine committed Jul 8, 2024
1 parent cf1b5b2 commit a0cd7de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions addon/helpers/reading-time.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { helper } from '@ember/component/helper';
import readingTime from 'reading-time';
import humanizeDuration from 'humanize-duration';

export default helper(function helperReadingTime(positional /*, named*/) {
const stats = readingTime(String(positional[0]));
const userOptions = positional[1];
export default function helperReadingTime(value, options) {
const stats = readingTime(String(value));
const userOptions = options ?? {};

const defaultOptions = {
round: true,
Expand All @@ -17,4 +16,4 @@ export default helper(function helperReadingTime(positional /*, named*/) {
stats.time < 60000 ? 60000 : stats.time,
Object.assign({}, defaultOptions, userOptions),
);
});
}
2 changes: 1 addition & 1 deletion app/helpers/reading-time.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default, readingTime } from 'ember-reading-time/helpers/reading-time';
export { default } from 'ember-reading-time/helpers/reading-time';

0 comments on commit a0cd7de

Please sign in to comment.