async Mutation(resolve, root, args, context, info) { const mutation = info.schema.getMutationType().getFields()[info.fieldName] if (isFunction(mutation.authorize)) { await mutation.authorize(root, args, context, info) } return resolve(root, args, context, info) }
const checkMapData = (mapData) => { invariant( isFunction(mapData), 'Expected mapData to be a function that returns a data to display in table.', ); return mapData; }
setDefault(callback) { if (!isFunction(callback)) throw new Error(`Failed to execute 'setDefaultAction': Parameter 1 is not of type 'function'.`); this.default = callback; }
function isEqualValue(value, other) { if (value === other) { return true; } var isImmutableDS = isEqualImmutableDS(value, other); if (isImmutableDS !== undefined) { return isImmutableDS; } return isEqual(value, other, (current, next) => { if (current === next) { return true; } if (isFunction(current) && isFunction(next)) { return current.toString() === next.toString(); } return isEqualImmutableDS(current, next); }); }
test('logger factory functionality', t => { var inst = logger('test'); t.true(isFunction(logger), 'The logger module should export a function'); t.is(inst.name, 'debug', 'Invoking the function should return an instance of the debug module'); t.notThrows(() => logger(), 'Should be able to create an instance of the logger without providing a namespace'); });
/** * * @param {*} middlewareReceiver * @param {Function[]} middleware * @returns {Promise<*[]>} */ async function initMiddlewareOn(middlewareReceiver, middleware) { return Promise.all( toArray(middleware) .filter(mw => isFunction(mw)) .map(mw => invokeOn(middlewareReceiver, 'use', mw)) ); }
inflect(commandName, handler) { if (isFunction(handler[this.methodName]) === false) { InvalidHandlerMethodException.forMethod(this.methodName); } return this.methodName; }
const looper = (result, resource, authObject) => reduce(resource, (result, func, key) => { result[key] = isFunction(func) ? binder(func, authObject) : looper(result, func, authObject) return result }, {})
/** * Checks if provided function is an AsyncFunction * @param {Function} fn * @returns {boolean} */ function isAsyncFunction(fn) { if (!isFunction(fn)) { return false; } return fn.constructor.name === 'AsyncFunction'; }
/** * * @param {Function} fn * @returns {boolean} */ function isArrowFunction(fn) { return isFunction(fn) && !fn.prototype; }
async Query(resolve, root, args, context, info) { const query = info.schema.getQueryType().getFields()[info.fieldName] if (isFunction(query.authorize)) { await query.authorize(root, args, context, info) } return resolve(root, args, context, info) }
/** * Checks if provided function is an AsyncFunction * @param {Function} fn * @returns {boolean} */ function isAsyncFunction(fn) { if (!isFunction(fn)) { return false; } return fn.constructor.name === 'AsyncFunction'; }
const checkActionCreator = (actionCreator) => { invariant( isFunction(actionCreator), 'Expected actionCreator to be a function that returns an API action.', ); return actionCreator; }
async Mutation(resolve, root, args, context, info) { const mutation = info.schema.getMutationType().getFields()[info.fieldName] if (isFunction(mutation.authorize)) { await mutation.authorize(root, args, context, info) } return resolve(root, args, context, info) }
async Query(resolve, root, args, context, info) { const query = info.schema.getQueryType().getFields()[info.fieldName] if (isFunction(query.authorize)) { await query.authorize(root, args, context, info) } return resolve(root, args, context, info) }