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


TypeScript Set.has方法代码示例

本文整理汇总了TypeScript中Immutable.Set.has方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Set.has方法的具体用法?TypeScript Set.has怎么用?TypeScript Set.has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Immutable.Set的用法示例。


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

示例1: reducer


//.........这里部分代码省略.........
      if(redoList.size > 0) {
        const redoSnapshot = redoList.first() as Record<ProjectSnapshot>
        const currentSnapshot = new ProjectSnapshotRecordFactory({
          timestamp: Date.now(),
          state: state.get('meta', null)!
        })
        const updatedUndo = state.setIn(['snapshots', 'undo'], undoList.unshift(currentSnapshot))
        const updatedRedo = updatedUndo.setIn(['snapshots', 'redo'], redoList.shift())
        return updatedRedo.set('meta', redoSnapshot.get('state', null))
      }
      return state
    }
    case project.PROJECT_SELECT_ANNOTATION: {
      const {type, selection} = action.payload
      switch(type) {
        case project.AnnotationSelectionType.Default: {
          return state.withMutations(mState => {
            mState.setIn(['selection', 'annotation', 'range'], Set())
            mState.setIn(['selection', 'annotation', 'pick'], Set())
            mState.setIn(['selection', 'annotation', 'selected'], selection)
          })
        }
        case project.AnnotationSelectionType.Pick: {
          const track = selection.get('track', null)!
          const filterByTrackFunc = (sel: Record<AnnotationSelection>) => {
            return sel.getIn(['track', 'id']) === track.get('id', null)
          }

          const rangeSelections: Set<Record<AnnotationSelection>> =
            state.getIn(['selection', 'annotation', 'range']).filter(filterByTrackFunc)
          const pickSelections: Set<Record<AnnotationSelection>> =
            state.getIn(['selection', 'annotation', 'pick']).filter(filterByTrackFunc)
          const peekSelected: Record<AnnotationSelection>|null = state.getIn(['selection', 'annotation', 'selected'])
          const isAlreadyPicked = rangeSelections.has(selection) || pickSelections.has(selection)

          return state.withMutations(mState => {
            if(isAlreadyPicked) {
              mState.setIn(['selection', 'annotation', 'range'], rangeSelections.delete(selection))
              mState.setIn(['selection', 'annotation', 'pick'], pickSelections.delete(selection))

              if(peekSelected && peekSelected.getIn(['annotation', 'id']) === selection.getIn(['annotation', 'id'])) {
                mState.setIn(['selection', 'annotation', 'selected'], null)
              }
            } else {
              // Set range, might be different due to filter
              mState.setIn(['selection', 'annotation', 'range'], rangeSelections)
              if(peekSelected && peekSelected.getIn(['track', 'id']) === track.get('id', null) && rangeSelections.isEmpty()) {
                mState.setIn(['selection', 'annotation', 'pick'], pickSelections.add(selection).add(peekSelected))
              } else {
                mState.setIn(['selection', 'annotation', 'pick'], pickSelections.add(selection))
              }
              mState.setIn(['selection', 'annotation', 'selected'], selection)
            }
          })
        }
        case project.AnnotationSelectionType.Range: {
          const source = selection.get('source', null)!
          const track = selection.get('track', null)!
          const filterByTrackFunc = (sel: Record<AnnotationSelection>) => {
            return sel.get('track', null)!.get('id', null)! === track.get('id', null)
          }
          const annotation = selection.get('annotation', null)!
          const annotations = track.get('annotationStacks', null).flatMap(stack => stack)

          const sortFunc = (a1: Record<Annotation>, a2: Record<Annotation>) => {
            return a1.get('utc_timestamp', null)! - a2.get('utc_timestamp', null)!
开发者ID:StudioProcess,项目名称:rvp,代码行数:67,代码来源:project.ts

示例2:

 layers: mapStyle.layers.filter(l => visible.has(l.id)),
开发者ID:cmc333333,项目名称:mapusaurus,代码行数:1,代码来源:Mapbox.ts


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