UNPKG

@atlaskit/atlassian-navigation

Version:

A horizontal navigation component for Atlassian apps.

28 lines (27 loc) 938 B
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.stripEmptyProperties = stripEmptyProperties; var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); /** * Returns a new object with only non-empty properties of the input object. * * In this context, "empty" refers to properties with `null`, `undefined`, or `""` * (empty string) values. * * @param obj - The input object. * @returns A new object with non-empty properties of the input object. */ function stripEmptyProperties(obj) { return Object.entries(obj).reduce(function (acc, _ref) { var _ref2 = (0, _slicedToArray2.default)(_ref, 2), key = _ref2[0], value = _ref2[1]; if (value !== null && value !== undefined && value !== '') { acc[key] = value; } return acc; }, {}); }