智能照明系统APP-本地串口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
LightingSystemApp-serial/.svn/pristine/42/425a5fc6a41963f1d9d83f1435e...

37 lines
887 B

3 years ago
var toArr = require('./toArr');
exports = function() {
var args = toArr(arguments);
var names = args.sort(nameSort);
var ret = {};
var idleMap = {};
for (var i = 0, len = names.length; i < len; i++) {
var str = names[i];
var nextStr = names[i + 1] || '';
if (str === nextStr) continue;
var start = false,
abbrev = '';
for (var j = 0, strLen = str.length; j < strLen; j++) {
abbrev += str[j];
if (!start && (str[j] !== nextStr[j] || j === strLen - 1))
start = true;
if (!start) {
idleMap[abbrev] = str;
} else if (!ret[abbrev] && !idleMap[abbrev]) {
ret[abbrev] = str;
}
}
}
return ret;
};
function nameSort(a, b) {
return a === b ? 0 : a > b ? 1 : -1;
}
module.exports = exports;