Added ordinal numbers to config checker.
This commit is contained in:
@@ -332,6 +332,17 @@ export class ODChecker extends ODManagerData {
|
|||||||
this.options = options ?? {}
|
this.options = options ?? {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**Get a human-readable number string. */
|
||||||
|
#ordinalNumber(num:number){
|
||||||
|
const i = Math.abs(Math.round(num))
|
||||||
|
const cent = i % 100
|
||||||
|
if (cent >= 10 && cent <= 20) return i+'th'
|
||||||
|
const dec = i % 10
|
||||||
|
if (dec === 1) return i+'st'
|
||||||
|
if (dec === 2) return i+'nd'
|
||||||
|
if (dec === 3) return i+'rd'
|
||||||
|
return i+'th'
|
||||||
|
}
|
||||||
/**Run this checker. Returns all errors*/
|
/**Run this checker. Returns all errors*/
|
||||||
check(): ODCheckerResult {
|
check(): ODCheckerResult {
|
||||||
this.messages = []
|
this.messages = []
|
||||||
@@ -343,12 +354,12 @@ export class ODChecker extends ODManagerData {
|
|||||||
messages:this.messages
|
messages:this.messages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**Create a string from the location trace (path)*/
|
/**Create a string from the location trace/path in a human readable format. */
|
||||||
locationTraceToString(trace:ODCheckerLocationTrace){
|
locationTraceToString(trace:ODCheckerLocationTrace){
|
||||||
const final: ODCheckerLocationTrace = []
|
const final: ODCheckerLocationTrace = []
|
||||||
trace.forEach((t) => {
|
trace.forEach((t) => {
|
||||||
if (typeof t == "number"){
|
if (typeof t == "number"){
|
||||||
final.push(`:${t}`)
|
final.push(`:(${this.#ordinalNumber(t+1)})`)
|
||||||
}else{
|
}else{
|
||||||
final.push(`."${t}"`)
|
final.push(`."${t}"`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,11 @@ export interface ODUtilities {
|
|||||||
*
|
*
|
||||||
* It shouldn't be used by plugins because this is an internal API feature!
|
* It shouldn't be used by plugins because this is an internal API feature!
|
||||||
*/
|
*/
|
||||||
ODVersionMigration:new (version:api.ODVersion,func:() => void|Promise<void>,afterInitFunc:() => void|Promise<void>) => ODVersionMigration
|
ODVersionMigration:new (version:api.ODVersion,func:() => void|Promise<void>,afterInitFunc:() => void|Promise<void>) => ODVersionMigration,
|
||||||
|
/**## ordinalNumber `utility function`
|
||||||
|
* Get a human readable ordinal number (e.g. 1st, 2nd, 3rd, 4th, ...) from a Javascript number.
|
||||||
|
*/
|
||||||
|
ordinalNumber(num:number): string,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**## ODVersionMigration `utility class`
|
/**## ODVersionMigration `utility class`
|
||||||
@@ -252,5 +256,15 @@ export const utilities: ODUtilities = {
|
|||||||
"LOREMIPSUM", //TODO
|
"LOREMIPSUM", //TODO
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
ODVersionMigration
|
ODVersionMigration,
|
||||||
|
ordinalNumber(num:number){
|
||||||
|
const i = Math.abs(Math.round(num))
|
||||||
|
const cent = i % 100
|
||||||
|
if (cent >= 10 && cent <= 20) return i+'th'
|
||||||
|
const dec = i % 10
|
||||||
|
if (dec === 1) return i+'st'
|
||||||
|
if (dec === 2) return i+'nd'
|
||||||
|
if (dec === 3) return i+'rd'
|
||||||
|
return i+'th'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user