@dillonkearns/elm-graphql
Version:
<img src="https://cdn.jsdelivr.net/gh/martimatix/logo-graphqelm/logo.svg" alt="dillonearns/elm-graphql logo" width="40%" align="right">
32 lines (23 loc) • 1.13 kB
JavaScript
;
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var _extends = _interopDefault(require('babel-runtime/helpers/extends'));
var _Array$from = _interopDefault(require('babel-runtime/core-js/array/from'));
var _Object$keys = _interopDefault(require('babel-runtime/core-js/object/keys'));
var _toConsumableArray = _interopDefault(require('babel-runtime/helpers/toConsumableArray'));
var _newArrowCheck = _interopDefault(require('babel-runtime/helpers/newArrowCheck'));
var _this = undefined;
var getObjectLength = function (object) {
_newArrowCheck(this, _this);
return Math.max.apply(Math, _toConsumableArray(_Object$keys(object))) + 1;
}.bind(undefined);
/**
* Creates a new array using the given object
* If all of its entries are array keys.
*
* (it could also have a property length with its size)
*/
var fromObject = function (object) {
_newArrowCheck(this, _this);
return _Array$from("length" in object ? object : _extends({}, object, { length: getObjectLength(object) }));
}.bind(undefined);
module.exports = fromObject;