Skip to content

Commit

Permalink
refactor to modern js
Browse files Browse the repository at this point in the history
  • Loading branch information
smhg committed Mar 21, 2019
1 parent 4f160a0 commit f0c9409
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
15 changes: 8 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,19 @@ function isLanguageOrLocale (locale) {
}

function createLocaleMiddleware (options = {}) {
options = Object.assign({
options = {
priority: ['accept-language', 'default'],
requestProperty: 'locale'
}, options);
requestProperty: 'locale',
...options
};

const lookups = Object.assign(
Object.keys(LOOKUP_CREATORS).reduce((result, lookup) => {
const lookups = {
...Object.keys(LOOKUP_CREATORS).reduce((result, lookup) => {
result[lookup] = LOOKUP_CREATORS[lookup](options[lookup]);
return result;
}, {}),
options.lookups || {}
);
...(options.lookups || {})
};

if (typeof options.priority === 'string') {
options.priority = options.priority.split(/ *, */g);
Expand Down
4 changes: 1 addition & 3 deletions src/lookup/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const createDefaultLookup = (locale = 'en_GB') => {
throw invalidLocaleError;
}

return () => {
return locale;
};
return () => locale;
};

export default createDefaultLookup;

0 comments on commit f0c9409

Please sign in to comment.