MCPcopy
hub / github.com/YMFE/yapi / unique

Method unique

server/controllers/interfaceCol.js:862–873  ·  view source on GitHub ↗
(array, compare)

Source from the content-addressed store, hash-verified

860
861 // 数组去重
862 unique(array, compare) {
863 let hash = {};
864 let arr = array.reduce(function(item, next) {
865 hash[next[compare]] ? '' : (hash[next[compare]] = true && item.push(next));
866 // console.log('item',item.project_id)
867 return item;
868 }, []);
869 // 输出去重以后的project_id
870 return arr.map(item => {
871 return item[compare];
872 });
873 }
874}
875
876module.exports = interfaceColController;

Callers 2

getCaseEnvListMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected