How to use the lodash-es.isFunction function in lodash-es

To help you get started, we’ve selected a few lodash-es examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github toxic-johann / toxic-decorators / src / helper / utils.ts View on Github external
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;
      }, {});
    };
}
github toxic-johann / toxic-decorators / src / accessor.ts View on Github external
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 || {};
github toxic-johann / toxic-decorators / src / autobind.ts View on Github external
requirement(obj: any, prop: string, desc: PropertyDescriptor) {
        return isDataDescriptor(desc) && isFunction(desc.value);
      },
    })()(obj);
github toxic-johann / toxic-decorators / src / helper / utils.ts View on Github external
export function getOwnKeysFn() {
  const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
  return isFunction(getOwnPropertySymbols)
    ? (obj: any) => [ ...getOwnPropertySymbols(obj), ...getOwnPropertyNames(obj)]
    : getOwnPropertyNames;
}
github openshift / console / frontend / public / components / utils / headings.tsx View on Github external
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 &amp;&amp; !_.isEmpty(data) &amp;&amp; (
        
          
            </div>
github toxic-johann / toxic-decorators / lib / index.js View on Github external
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));
    };
  });
}
github Yoast / wordpress-seo / js / src / decorator / gutenberg.js View on Github external
function scheduleAnnotationQueueApplication() {
	if ( isFunction( window.requestIdleCallback ) ) {
		window.requestIdleCallback( applyAnnotationQueueItem, { timeout: 1000 } );
	} else {
		setTimeout( applyAnnotationQueueItem, 150 );
	}
}
github Yoast / YoastSEO.js / src / app.js View on Github external
App.prototype.registerCustomDataCallback = function( callback ) {
	if ( ! this.callbacks.custom ) {
		this.callbacks.custom = [];
	}

	if ( isFunction( callback ) ) {
		this.callbacks.custom.push( callback );
	}
};
github sourcegraph / sourcegraph / packages / extensions-client-common / src / settings.ts View on Github external
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]
        }
    }
}
github metaspace2020 / metaspace / metaspace / webapp / src / modules / Filters / FilterPanel.vue View on Github external
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
    },