Skip to content

Commit 715c50f

Browse files
authored
Merge pull request #264 from geomatician/main
Use map instead of foreach/push
2 parents 9f44240 + 694b536 commit 715c50f

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [0.5.0] - 2022-05-20
9+
10+
### Changed
11+
12+
- Used map instead of foreach/push in api.js file
13+
814
## [0.5.0] - 2022-05-18
915

1016
### Added

src/lib/api.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,16 @@ const extractSortby = function (params) {
184184
if (sortby) {
185185
if (typeof sortby === 'string') {
186186
// GET request - different syntax
187-
sortbyRules = []
188187
const sortbys = sortby.split(',')
189-
sortbys.forEach((sortbyRule) => {
188+
189+
sortbyRules = sortbys.map((sortbyRule) => {
190190
if (sortbyRule[0] === '-') {
191-
sortbyRules.push({ field: sortbyRule.slice(1), direction: 'desc' })
192-
} else if (sortbyRule[0] === '+') {
193-
sortbyRules.push({ field: sortbyRule.slice(1), direction: 'asc' })
194-
} else {
195-
sortbyRules.push({ field: sortbyRule, direction: 'asc' })
191+
return { field: sortbyRule.slice(1), direction: 'desc' }
192+
}
193+
if (sortbyRule[0] === '+') {
194+
return { field: sortbyRule.slice(1), direction: 'asc' }
196195
}
196+
return { field: sortbyRule, direction: 'asc' }
197197
})
198198
} else {
199199
// POST request

0 commit comments

Comments
 (0)