UNPKG

graphql

Version:

A Query Language and Runtime which can target any service.

44 lines (41 loc) 1.19 kB
/** * Copyright (c) 2019-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ import objectEntries from '../polyfills/objectEntries'; /** * Creates an object map with the same keys as `map` and values generated by * running each value of `map` thru `fn`. */ export default function mapValue(map, fn) { var result = Object.create(null); var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = objectEntries(map)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var _ref2 = _step.value; var _key = _ref2[0]; var _value = _ref2[1]; result[_key] = fn(_value, _key); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } return result; }