Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getOwnPropertyDescriptorsFn(): (o: T) => { [P in keyof T]: TypedPropertyDescriptor; } & {
[x: string]: PropertyDescriptor;
} {
// @ts-ignore: A polyfill for getOwnPropertyDescriptors
return isFunction(Object.getOwnPropertyDescriptors)
? Object.getOwnPropertyDescriptors
: (obj: any) => {
return getOwnKeys(obj).reduce((descs: { [x: string]: PropertyDescriptor }, key) => {
// @ts-ignore: ignore symbol
descs[key] = getOwnPropertyDescriptor(obj, key);
return descs;
}, {});
};
}
set,
}: {
get?: ((v: any) => any) | Array<(v: any) => any>,
set?: ((v: any) => any) | Array<(v: any) => any>,
} = {},
{
preGet = false,
preSet = true,
}: {
preGet?: boolean,
preSet?: boolean,
} = {}): MethodDecorator | PropertyDecorator {
if (!(isArray(get) && get.length > 0) &&
!(isArray(set) && set.length > 0) &&
!isFunction(get) &&
!isFunction(set)
) {
throw new TypeError('@accessor need a getter or setter. If you don\'t need to add setter/getter. You should remove @accessor');
}
const errmsg = '@accessor only accept function or array of function as getter/setter';
const singleFnGet = isArray(get)
? compressOneArgFnArray(get, errmsg)
: get;
const singleFnSet = isArray(set)
? compressOneArgFnArray(set, errmsg)
: set;
return function(obj: object, prop: string, descriptor: PropertyDescriptor): AccessorDescriptor {
const {
configurable = true,
enumerable = true,
} = descriptor || {};
requirement(obj: any, prop: string, desc: PropertyDescriptor) {
return isDataDescriptor(desc) && isFunction(desc.value);
},
})()(obj);
export function getOwnKeysFn() {
const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
return isFunction(getOwnPropertySymbols)
? (obj: any) => [ ...getOwnPropertySymbols(obj), ...getOwnPropertyNames(obj)]
: getOwnPropertyNames;
}
obj,
breadcrumbsFor,
titleFunc,
style,
customData,
badge,
} = props;
const extraResources = _.reduce(
props.resourceKeys,
(extraObjs, key) => ({ ...extraObjs, [key]: _.get(props[key], 'data') }),
{},
);
const data = _.get(obj, 'data');
const resourceTitle = titleFunc && data ? titleFunc(data) : title;
const hasButtonActions = !_.isEmpty(buttonActions);
const hasMenuActions = _.isFunction(menuActions) || !_.isEmpty(menuActions);
const showActions =
(hasButtonActions || hasMenuActions) && !_.isEmpty(data) && !_.get(data, 'deletionTimestamp');
return (
<div style="{style}">
{breadcrumbsFor && !_.isEmpty(data) && (
</div>
return fns.reduce(function (prev, curr) {
if (!lodashEs.isFunction(curr) || !lodashEs.isFunction(prev)) {
throw new TypeError(errmsg);
}
return function (value) {
return lodashEs.bind(curr, this)(lodashEs.bind(prev, this)(value));
};
});
}
function scheduleAnnotationQueueApplication() {
if ( isFunction( window.requestIdleCallback ) ) {
window.requestIdleCallback( applyAnnotationQueueItem, { timeout: 1000 } );
} else {
setTimeout( applyAnnotationQueueItem, 150 );
}
}
App.prototype.registerCustomDataCallback = function( callback ) {
if ( ! this.callbacks.custom ) {
this.callbacks.custom = [];
}
if ( isFunction( callback ) ) {
this.callbacks.custom.push( callback );
}
};
export function merge(base: any, add: any, custom?: CustomMergeFunctions): void {
for (const key of Object.keys(add)) {
if (key in base) {
const customEntry = custom && custom[key]
if (customEntry && isFunction(customEntry)) {
base[key] = customEntry(base[key], add[key])
} else if (isPlainObject(base[key]) && isPlainObject(add[key])) {
merge(base[key], add[key], customEntry)
} else {
base[key] = add[key]
}
} else {
base[key] = add[key]
}
}
}
availableFilters() {
const available = []
for (const key of orderedFilterKeys) {
const filterSpec = FILTER_SPECIFICATIONS[key]
if (filterSpec.levels.includes(this.level)
&& !this.activeKeys.includes(key)
&& (filterSpec.hidden == null || filterSpec.hidden === false
|| (isFunction(filterSpec.hidden) && !filterSpec.hidden()))) {
available.push({ key, description: filterSpec.description })
}
}
return available
},