mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
18 lines
457 B
JavaScript
18 lines
457 B
JavaScript
'use strict';
|
|
|
|
const currify = require('currify');
|
|
|
|
const not = currify((array, value) => !array.includes(value));
|
|
const notOneOf = currify((a, b) => a.filter(not(b)));
|
|
|
|
module.exports = (currentName, names, removedNames) => {
|
|
const i = names.indexOf(currentName);
|
|
|
|
const nextNames = notOneOf(names, removedNames);
|
|
const {length} = nextNames;
|
|
|
|
if (nextNames[i])
|
|
return nextNames[i];
|
|
|
|
return nextNames[length - 1];
|
|
};
|