bbo
Version:
bbo is a utility library of zero dependencies for javascript.
49 lines (38 loc) • 1.27 kB
JavaScript
import { _ as _extends } from './internal/_rollupPluginBabelHelpers.js';
import isObject from './is_object.js';
import './get_tag.js';
import isArray from './is_array.js';
function column(input, ColumnKey) {
var IndexKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
if (input !== null && (isObject(input) || isArray(input))) {
var newarray = [];
if (isObject(input)) {
var temparray = [];
for (var key of Object.keys(input)) {
temparray.push(input[key]);
} // eslint-disable-next-line no-param-reassign
input = temparray;
}
if (isArray(input)) {
for (var _key of input.keys()) {
if (IndexKey && input[_key][IndexKey]) {
if (ColumnKey) {
newarray[input[_key][IndexKey]] = input[_key][ColumnKey];
} else {
newarray[input[_key][IndexKey]] = input[_key];
}
} else {
if (ColumnKey) {
newarray.push(input[_key][ColumnKey]);
} else {
newarray.push(input[_key]);
}
}
}
} // eslint-disable-next-line prefer-object-spread
return _extends({}, newarray);
} else {
throw new Error('throw an error');
}
}
export default column;