mirror of
https://github.com/LukeHagar/api-specs.git
synced 2025-12-09 12:27:48 +00:00
initial script creation
This commit is contained in:
37
postman-script/partialUpdate/Utils.js
Normal file
37
postman-script/partialUpdate/Utils.js
Normal file
@@ -0,0 +1,37 @@
|
||||
const uuid = require('uuid')
|
||||
const NAMESPACE = '33c4e6fc-44cb-4190-b19f-4a02821bc8c3'
|
||||
|
||||
const genID = (objectJSON = null) => {
|
||||
if (objectJSON) {
|
||||
return uuid.v5(objectJSON, NAMESPACE)
|
||||
} else {
|
||||
return uuid.v4()
|
||||
}
|
||||
}
|
||||
|
||||
// Sort 2 objects by name
|
||||
const byName = (a, b) => {
|
||||
if (a.name < b.name) {
|
||||
return -1
|
||||
} else if (a.name > b.name) {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Sort two object by priority
|
||||
const byPriority = (a, b) => {
|
||||
if (a['x-box-priority']) {
|
||||
return -1
|
||||
} else if (b['x-box-priority']) {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
GenID: genID,
|
||||
ByName: byName,
|
||||
ByPriority: byPriority
|
||||
// logAxiosError
|
||||
}
|
||||
Reference in New Issue
Block a user