UNPKG

@cloudscape_innovation/react-images-viewer

Version:
61 lines (56 loc) 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.bindFunctions = bindFunctions; exports.canUseDom = void 0; exports.deepMerge = deepMerge; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function deepMerge(source) { var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var extended = Object.assign({}, target); Object.keys(source).forEach(function (key) { if (_typeof(source[key]) !== "object" || !source[key]) { extended[key] = source[key]; } else { if (!target[key]) { extended[key] = source[key]; } else { extended[key] = deepMerge(target[key], source[key]); } } }); return extended; } // export function deepMerge(source, target = {}) { // // initialize with source styles // const styles = { ...source } // // massage in target styles // Object.keys(target).forEach(key => { // if (source[key]) { // styles[key] = (rsCss, props) => { // return target[key](source[key](rsCss, props), props) // } // } else { // styles[key] = target[key] // } // }) // return styles // } var canUseDom = exports.canUseDom = !!(typeof window !== "undefined" && window.document && window.document.createElement); /** * Bind multiple conponent methods: * @param {this} context * @param {Array} functions * * constructor() { * ... * bindFunctions.call(this, ['handleClick', 'handleOther']) * } */ function bindFunctions(functions) { var _this = this; functions.forEach(function (f) { return _this[f] = _this[f].bind(_this); }); }