voxa-cli
Version:
The Voxa CLI tools
66 lines • 2.69 kB
JavaScript
;
/*
* Copyright (c) 2018 Rain Agency <contact@rain.agency>
* Author: Rain Agency <contact@rain.agency>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = __importDefault(require("lodash"));
const VoxaSheet_1 = require("../VoxaSheet");
function findSheetType(spreadsheet) {
const processorFound = lodash_1.default.chain(VoxaSheet_1.SheetTypes)
.invert()
.find((key, value) => {
return spreadsheet.sheetTitle.indexOf(value) >= 0;
})
.value();
spreadsheet.type = processorFound;
if (processorFound) {
return spreadsheet;
}
return undefined;
}
exports.findSheetType = findSheetType;
function rowFormatted(acc, next, iindex, arr, reestrictFormat) {
const item = lodash_1.default.chain(arr).head()
.zip(next)
.map((zipObj) => [zipObj[0], valueFormatted(zipObj[1], reestrictFormat)])
.fromPairs()
.value();
acc.push(item);
return acc;
}
exports.rowFormatted = rowFormatted;
function valueFormatted(val, reestrictFormat) {
const valTemp = lodash_1.default.toLower(val);
if (reestrictFormat && lodash_1.default.includes(["true", "yes"], valTemp)) {
val = true;
}
if (reestrictFormat && lodash_1.default.includes(["false", "no"], valTemp)) {
val = false;
}
if (typeof valTemp === "string" && valTemp.length === 0) {
val = undefined;
}
return val;
}
//# sourceMappingURL=utils.js.map