UNPKG

@amplience/dc-cli

Version:
21 lines (20 loc) 822 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.transformYargObjectToArray = void 0; const validateArrayIndex = (yargObject) => { const index = Object.keys(yargObject); if (index.length === 0) { return; } const isIndexSequential = index .sort((a, b) => (parseInt(a) > parseInt(b) ? 1 : -1)) .every((suppliedIndex, actualIndex) => parseInt(suppliedIndex) == actualIndex); if (!isIndexSequential) { throw new Error('Targeted array indexes are unsupported, please provide a full array index starting at 0'); } }; const transformYargObjectToArray = (yargObject) => { validateArrayIndex(yargObject); return Object.entries(yargObject).map(entry => entry[1]); }; exports.transformYargObjectToArray = transformYargObjectToArray;