Update code documentation
This commit is contained in:
parent
8bc56fbbe2
commit
0f88627ab2
@ -36,6 +36,13 @@ function sanitiseURL(string){
|
||||
return `${url_.protocol}//${url_.hostname}${url_.pathname || ''}${url_.search || ''}${url_.hash || ''}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform an array of objects into a dictionary of arrays of objects,
|
||||
* where the objects are grouped into arrays given an arbitrary key function
|
||||
* that gives a key for each object.
|
||||
* @param arr array of objects to group
|
||||
* @param keyAccessor function returning the grouping key for each object in the original array
|
||||
*/
|
||||
function arrayToDictionary<T>(arr: T[], keyAccessor: (obj: T) => string): {[key: string]: T[]} {
|
||||
return arr.reduce((obj, item) => {
|
||||
(obj[keyAccessor(item)] = obj[keyAccessor(item)] || []).push(item);
|
||||
@ -44,9 +51,9 @@ function arrayToDictionary<T>(arr: T[], keyAccessor: (obj: T) => string): {[key:
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a string containing
|
||||
* @param isoUtcDate a date string in ISO8601 format
|
||||
*
|
||||
* Parse a string containing an ISO8601 formatted date
|
||||
* @param isoUtcDate a date string in ISO8601 format, assuming UTC
|
||||
* @returns a JS Date object with the UTC time encoded
|
||||
*/
|
||||
function parseDate(isoUtcDate: string): Date {
|
||||
const [year, month, day, hour, minute, second, millisecond] = isoUtcDate.match(/^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d).(\d{3})Z$/)
|
||||
|
Loading…
Reference in New Issue
Block a user