New: Project Aphrodite

This commit is contained in:
Qstick
2018-11-23 02:04:42 -05:00
parent 65efa15551
commit 8430cb40ab
1080 changed files with 73015 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import _ from 'lodash';
import isSameCommand from './isSameCommand';
function findCommand(commands, options) {
return _.findLast(commands, (command) => {
return isSameCommand(command.body, options);
});
}
export default findCommand;

View File

@@ -0,0 +1,5 @@
export { default as findCommand } from './findCommand';
export { default as isCommandComplete } from './isCommandComplete';
export { default as isCommandExecuting } from './isCommandExecuting';
export { default as isCommandFailed } from './isCommandFailed';
export { default as isSameCommand } from './isSameCommand';

View File

@@ -0,0 +1,9 @@
function isCommandComplete(command) {
if (!command) {
return false;
}
return command.status === 'complete';
}
export default isCommandComplete;

View File

@@ -0,0 +1,9 @@
function isCommandExecuting(command) {
if (!command) {
return false;
}
return command.status === 'queued' || command.status === 'started';
}
export default isCommandExecuting;

View File

@@ -0,0 +1,12 @@
function isCommandFailed(command) {
if (!command) {
return false;
}
return command.status === 'failed' ||
command.status === 'aborted' ||
command.status === 'cancelled' ||
command.status === 'orphaned';
}
export default isCommandFailed;

View File

@@ -0,0 +1,24 @@
import _ from 'lodash';
function isSameCommand(commandA, commandB) {
if (commandA.name.toLocaleLowerCase() !== commandB.name.toLocaleLowerCase()) {
return false;
}
for (const key in commandB) {
if (key !== 'name') {
const value = commandB[key];
if (Array.isArray(value)) {
if (_.difference(value, commandA[key]).length > 0) {
return false;
}
} else if (value !== commandA[key]) {
return false;
}
}
}
return true;
}
export default isSameCommand;