(alias, expectedType)
| 684 | Validates alias. Must be a string or single key object |
| 685 | */ |
| 686 | function isValidAlias(alias, expectedType) { |
| 687 | let type = typeof alias; |
| 688 | let value, valueType; |
| 689 | if (type === 'string') { |
| 690 | return true; |
| 691 | } else if (type === 'object') { |
| 692 | // no arrays, no multi-key objects |
| 693 | if (!Array.isArray(alias) && Object.keys(alias).length === 1) { |
| 694 | value = alias[Object.keys(alias)[0]]; |
| 695 | valueType = typeof value; |
| 696 | if (!Array.isArray(expectedType)) { |
| 697 | if (valueType === expectedType.name.toLowerCase()) { |
| 698 | return true; |
| 699 | } |
| 700 | } else if (expectedType.indexOf(value) > -1) { |
| 701 | return true; |
| 702 | } |
| 703 | } |
| 704 | } |
| 705 | |
| 706 | return false; |
| 707 | } |
| 708 | |
| 709 | module.exports = Command; |
no outgoing calls
no test coverage detected
searching dependent graphs…