当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ramda.pick函数代码示例

本文整理汇总了TypeScript中ramda.pick函数的典型用法代码示例。如果您正苦于以下问题:TypeScript pick函数的具体用法?TypeScript pick怎么用?TypeScript pick使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pick函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: describe

    describe('ramda', function () {

        function filterUserData(username) {
            return R.filter(R.propEq('username', username));
        }

        const isUnComplete = (task) => !task.complete;
        const filterOutstandingTasks = R.pipe(
            R.filter(isUnComplete),
            R.map(R.pick(['id', 'title', 'dueDate', 'priority'])));

        function descSort(property) {
            return (a, b) => a[property].localeCompare(b[property]);
        }

        function getIncompleteTaskSummaries(username) {
            return R.pipeP(fetchTaskData, R.prop('tasks'), filterUserData(username), filterOutstandingTasks, R.sort(descSort('dueDate')));
        }

        it('returns unfinished tasks sorted by due dates in ascending order', function (done) {
            getIncompleteTaskSummaries('Scott')()
                .then((answer) => done(assert.deepEqual(answer, expectedAnswer)))
                .catch((error) => done(error));
        });
    });
开发者ID:dhassaine-scottlogic,项目名称:fp_experiments,代码行数:25,代码来源:ts_ramda.test.ts

示例2: checkOneBrowser

function checkOneBrowser(browser: Browser) {
  const platform = os.platform()
  const pickBrowserProps = pick([
    'name',
    'displayName',
    'type',
    'version',
    'path'
  ])

  const logBrowser = (props: any) => {
    log('setting major version for %j', props)
  }

  const failed = (err: NotInstalledError) => {
    if (err.notInstalled) {
      log('browser %s not installed', browser.name)
      return false
    }
    throw err
  }

  log('checking one browser %s', browser.name)
  return lookup(platform, browser)
    .then(merge(browser))
    .then(pickBrowserProps)
    .then(tap(logBrowser))
    .then(setMajorVersion)
    .catch(failed)
}
开发者ID:lgandecki,项目名称:cypress,代码行数:30,代码来源:detect.ts

示例3: merge

 const set = data => {
   for (let x = 0; x < data.width; x++) {
     for (let y = 0; y < data.height; y++) {
       // cant read from MST array above bounds, so check length first
       // @ts-ignore
       self.field[x] = x === self.field.length ? [] : self.field[x]
       self.field[x][y] = y === self.field[x].length ? {} : self.field[x][y]
       // merge to preserve flags on UI
       self.field[x][y] = merge(self.field[x][y], data.field[x][y])
     }
   }
   Object.assign(
     self,
     pick(
       [
         'width',
         'height',
         'bombCount',
         'cellsLeft',
         'isFinished',
         'isWon',
         'isLost'
       ],
       data
     )
   )
 }
开发者ID:NotBadDevs,项目名称:minesweepers,代码行数:27,代码来源:game.ts

示例4: buildJoiSpec

 .map(handler => [
     {
         method,
         path,
         handler,
         validate: buildJoiSpec(Joi, spec),
         meta: pick(['summary', 'description'], spec)
     }
 ])
开发者ID:benjambles,项目名称:my-own-world,代码行数:9,代码来源:get-route-mapping.ts

示例5: switch

const panesReducer = (previousState = initialState, action) => {
  if (isPanesModule(action)) {
    switch (action.type) {
      case panesActionTypes.OPEN: {
        const {
          payload: { pane },
        } = action;
        return { activeKey: pane.key, panes: { ...previousState.panes, [pane.key]: pane } };
      }
      case panesActionTypes.ACTIVE: {
        const {
          payload: { key },
        } = action;
        return { ...previousState, activeKey: key };
      }
      case panesActionTypes.CLOSE: {
        const { activeKey, panes } = previousState;
        const {
          payload: { key },
        } = action;

        // prettier-ignore
        const index = R.compose(R.indexOf(activeKey), R.keys)(panes);
        const nextPanes = _.omit(panes, key);

        const nextKeys = _.keys(nextPanes);
        const nextKey =
          activeKey && _.has(nextPanes, activeKey)
            ? activeKey
            : // 关闭当前 tab 时定位到后面一个 tab
              nextKeys[_.min([index, nextKeys.length - 1]) as number];
        return { activeKey: nextKey, panes: nextPanes };
      }
      case panesActionTypes.CLOSE_ALL: {
        return {};
      }
      case panesActionTypes.CLOSE_WITHOUT: {
        const {
          payload: { activeKey },
        } = action;
        if (activeKey) {
          const panes = R.pick([activeKey])(previousState.panes);
          return R.merge(previousState, { panes });
        }
        return {};
      }
      default:
        return { ...previousState, ...action.payload };
    }
  }
  return previousState;
};
开发者ID:danielwii,项目名称:asuna-admin,代码行数:52,代码来源:panes.redux.ts

示例6: async

TaskCardRouter.post('/v2/task-card', authJwt, async (req, res, next) => {
  try {
    const data = R.pick(['title', 'boardId', 'trackId', 'type'], req.body);

    const { jw } = req;

    const card: ITaskCard = await createTaskCard({
      title: data.title,
      type: data.type,
      creatorId: jw.user.id,
      boardId: data.boardId,
      trackId: data.trackId
    });
    res.status(201).send(card);
  } catch (error) {
    next(error);
  }
});
开发者ID:A-Horse,项目名称:bblist-backend,代码行数:18,代码来源:task-card.router.ts

示例7: pick

const createFormatError = (details: any) => (error: any) => {
  const formattedError = pick(ERROR_FIELD_WHITELIST, error)

  if (formattedError.extensions && formattedError.extensions.exception) {
    formattedError.extensions.exception = cleanError(formattedError.extensions.exception)
    if (formattedError.stack === formattedError.extensions.exception.stack) {
      delete formattedError.extensions.exception.stack
    }
  }

  if (formattedError.originalError) {
    formattedError.originalError = cleanError(formattedError.originalError)
    if (formattedError.stack === formattedError.originalError.stack) {
      delete formattedError.originalError.stack
    }
  }

  Object.assign(formattedError, details)

  return formattedError as any
}
开发者ID:vtex,项目名称:apps-client-node,代码行数:21,代码来源:formatters.ts

示例8: async

export const response = async (ctx: GraphQLServiceContext, next: () => Promise<void>) => {
  const {responseInit, graphqlResponse} = ctx.graphql

  const {
    maxAge = '',
    scope = '',
    segment = null,
  } = graphqlResponse ? cacheControl(graphqlResponse, ctx) : {}

  ctx.set({
    ...responseInit && responseInit.headers,
    'Cache-Control': `${maxAge}, ${scope}`,
  })

  if (segment) {
    ctx.vary(SEGMENT_HEADER)
  }

  ctx.body = pick(['data', 'errors'], graphqlResponse!)

  await next()
}
开发者ID:vtex,项目名称:apps-client-node,代码行数:22,代码来源:response.ts

示例9: propOr

  },
  // propOr :: a → String → Object → a
  propOr(defaultVal, fieldsArr, obj) {
    return R.propOr(defaultVal, fieldsArr, obj)
  },
  // [Idx] → {a} → a | Undefined
  // Idx = String | Int
  path(fieldsLevelArr, obj) {
    return R.path(fieldsLevelArr, obj)
  },
  pathOr(defaultVal, fieldsLevelArr, obj) {
    return R.path(defaultVal, fieldsLevelArr, obj)
  },
  // pick :: [k] → {k: v} → {k: v}
  pick(fieldsArr, obj) {
    return R.pick(fieldsArr, obj)
  },

  // assoc/assocPath
  // assoc :: String → a → {k: v} → {k: v}
  assoc(field, val, obj) {
    return R.assoc(field, val, obj)
  },
  // [Idx] → a → {a} → {a}
  // Idx = String | Int
  assocPath(fieldsLevelArr, val, obj) {
    return R.assocPath(fieldsLevelArr, val, obj)
  },

  // dissoc/dissocPath
  // String → {k: v} → {k: v}
开发者ID:stefaniepei,项目名称:react-redux-scaffold,代码行数:31,代码来源:ramda.ts

示例10: canAttack

import * as R from 'ramda';
import { canAttack } from '../../../Character';
import { CardType } from '../../../enums';
import { MinionProps } from './Minion';
import TargetableMinion from './TargetableMinion';
import { performAttack } from '../characterReducer';

const collect: DnD.DragSourceCollector = (connector, monitor) => ({
  connectDragSource: connector.dragSource(),
  canDrag: monitor.canDrag(),
});

const spec: DnD.DragSourceSpec<MinionProps> = {
  beginDrag: (props, monitor, component) => props,
  canDrag: (props, monitor: DnD.DragSourceMonitor) =>
    props.character.owner === props.state.activePlayer &&
    canAttack(props.character),
};

const DraggableMinion = DnD.DragSource<MinionProps>(
  CardType.Minion,
  spec,
  collect
)(TargetableMinion);

const mapStateToProps = R.pick(['state', 'entities']);

export default connect(mapStateToProps, { performAttack })(
  DraggableMinion
) as React.ComponentClass<Partial<MinionProps>>;
开发者ID:zernie,项目名称:typescript-redux-card-game,代码行数:30,代码来源:DraggableMinion.ts


注:本文中的ramda.pick函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。