const addIds = () => { return articleData.map(e => { if (e.type === 'article') { return e // already has an id } // needs an id to be used as component key const id = { id: uuidv4() } return merge(e, id) }) }
build() { const content = { type: this.type, payload: this._getPayload() } if (isEmpty(this.quickReplies)) return content return merge(content, {quick_replies: this.quickReplies}) }
const captureExceptionAndReturnPromise = (error, kwargs) => { if (process.env.enable_sentry !== 'true') { return Promise.resolve() } const messageFromError = error.message || '<no message>' const customSentryMessage = `${process.env.AWS_LAMBDA_FUNCTION_NAME} - ${messageFromError}` const updatedKwargs = R.merge(kwargs, { message: customSentryMessage, fingerprint: [process.env.AWS_LAMBDA_FUNCTION_NAME, customSentryMessage] }) return new Promise(resolve => Raven.captureException(error, updatedKwargs, () => resolve())) }
function wrapperCollectin(db, collName) { let coll = db.collection(collName) return R.merge(bindCollFn(coll),{insert: R.partial(insertWithAutoIncrement, [db, coll, collName])}) }
const routes = (handlers, req) => { for (let route in handlers) { const params = pathMatch(route)(req.pathname) if (params) { return Promise.resolve({ params, route }) .then(merge(req)) .then(handlers[route]) } } return Promise.reject(Boom.notFound()) }
const requests = (state = {}, { type, payload, meta }) => { switch (type) { case 'app/markRequestPending': return merge(state, { [meta.key]: { status: 'pending', error: null } }) case 'app/markRequestSuccess': return merge(state, { [meta.key]: { status: 'success', error: null } }) case 'app/markRequestFailed': return merge(state, { [meta.key]: { status: 'failure', error: payload } }) default: return state } }
/** * Parses given command arguments into a more useful format. * * @param commandArray Command string or list of command parts. * @param extraOpts Extra options. * @returns Normalized parameters. */ export function parseParams(commandArray: string | string[], extraOpts: Options = {}): IParameters { // use the command line args if not passed in if (is(String, commandArray)) { commandArray = (commandArray as string).split(COMMAND_DELIMITER) } // remove the first 2 args if it comes from process.argv if (equals(commandArray, process.argv)) { commandArray = commandArray.slice(2) } // chop it up yargsParse! const parsed = yargsParse(commandArray) const array = parsed._.slice() delete parsed._ const options = merge(parsed, extraOpts) return { array, options } }
export default function(state = initialState, action) { const update = merge(state); switch (action.type) { case CHANGE_MEAL_ATTRIBUTE: return update({active: undefined}); case SELECT_EDITABLE_ELEMENT: return update({active: action.element}); default: return state; } }
curry((response, request) => merge(request, { original: request, // legacy request, response }))
log(level, msg, meta = {}) { if (!R.contains(level, ['debug', 'info', 'warn', 'error'])) { throw new Error(`"${level}" is not a valid log level`); } if (level === 'debug' && !this.config.debug) { return } if (R.is(Error, meta)) { meta = { name: meta.name, errorMessage: meta.message, stack: meta.stack } } const method = level === 'debug' ? 'log' : level const data = R.merge({ level, version: this.version, message: msg }, meta) /* eslint-disable no-console */ console[method](JSON.stringify(data)) /* eslint-disable no-console */ }
const loadConnectors = (context: Context): void => { try { logger.info('loading connectors'); const baseDir = resolve(__dirname, './projects/'); const pattern = baseDir + '/**/index.ts'; const g = new glob.Glob(pattern, { mark: true, sync: true, }); Object.defineProperty(context, 'connector', { get() { if (!this[SYMBOL_CONNECTOR_CLASS]) { let connectorsMap: any = {}; R.map(R.compose( (connectorss: object) => { connectorsMap = R.merge(connectorsMap, connectorss); }, require, ))(g.found); this[SYMBOL_CONNECTOR_CLASS] = connectorsMap; } return this[SYMBOL_CONNECTOR_CLASS]; }, }); } catch (error) { logger.error(error); throw error; } }
export default function(state = initialState, action) { const update = merge(state); let meal; switch (action.type) { case NEW_MEAL: meal = newMeal(state); return update({[meal.id]: meal}); case ADD_FOOD_TO_MEAL: const food = action.food.id, dose = action.dose, id = action.meal_id; meal = evolve({ingredients: append({food, dose}) }, findMealById(state, id)); return update({[id]: meal}); case CHANGE_MEAL_ATTRIBUTE: meal = merge(state[action.meal_id], { [action.attribute]: action.val }); return update({[action.meal_id]: meal}); default: return state; } }
R.merge(attributes, { onKeyDown: onKeyDown, ref: function (node) {
const systemError = ({ message, name, statusCode=500 }) => merge(json({ message, name }), { statusCode })
export default function(state = initialState, action) { const update = merge(state); switch(action.type){ case SELECT_FOOD_ITEM: const active = action.foodId; return update({active}); case FILTER_FOODS: const filter = action.filterQuery; return update({filter, active: undefined}); case CHANGE_FOOD_DOSEAGE: const doseage = action.val; return update({doseage}); default: return state; } }