-
-
Save Dobby233Liu/fe2c363e52c00392da70f40af9012864 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
index = [ | |
{ | |
obj: window.getListByCountryTypeService1, | |
data: { | |
creationDate: "createTime", | |
modifiedDate: "modifyTime", | |
op: "operator" | |
} | |
}, | |
{ | |
obj: window.getListByCountryTypeService2, | |
data: { | |
creationDate: "createTime", | |
modifiedDate: "modifyTime", | |
op: "operator" | |
} | |
}, | |
{ | |
obj: window.getIndexRecommendList, | |
data: { | |
creationDate: "createTime", | |
modifiedDate: "modifyTime", | |
op: "operator" | |
} | |
}, | |
{ | |
obj: window.getTimelineService, | |
data: { | |
creationDate: "createTime", | |
modifiedDate: "modifyTime", | |
op: "dataInfoOperator" | |
} | |
}] | |
myCompound = { | |
creationDate: [], | |
modifiedDate: [], | |
op: [] | |
}; | |
shouldConvertToDate = v => v.toLowerCase().indexOf("date") >= 0 || v.toLowerCase().indexOf("time") >= 0; | |
washCompound = function (data, curIndex) { | |
var ret = Array.from(new Set(data[curIndex])).filter(Boolean); | |
if(!shouldConvertToDate(curIndex)) return ret; // fun starts down here | |
var isJSDate = v => !isNaN(v) && v.toString().length == 13; | |
var isUnixTime = v => !isNaN(v) && v.toString().length == 10; | |
ret = ret.map(x => (!isJSDate(x) && !isUnixTime(x) ? x : new Date(x * (isUnixTime(x) ? 1000 : 1)))); | |
return ret; | |
} | |
for(i of index) { | |
for(i2 in i.data) { | |
for(foundStuff in i.obj) { | |
foundStuff = i.obj[foundStuff]; | |
gotData = foundStuff[i.data[i2]]; | |
myCompound[i2].push(gotData); | |
myCompound[i2] = washCompound(myCompound, i2); // wash data often | |
} | |
} | |
} | |
myCompound; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment