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


TypeScript lodash.sortedIndexBy函数代码示例

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


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

示例1:

 _.forEach(newObjects, (newObject: any) => {
     let uiObject = _.find(uiObjects, {id: newObject.id});
     if (uiObject) {
         Object.assign(uiObject, newObject);
     } else {
         uiObjects.splice(_.sortedIndexBy(uiObjects, newObject, options.sort || 'id'), 0, newObject);
     }
 });
开发者ID:mactanxin,项目名称:gui,代码行数:8,代码来源:data-object-change-service.ts

示例2: getIndexBoundsForPointData

export function getIndexBoundsForPointData(data: SeriesData, xValueBounds: Interval, xValuePath: string): IndexBounds {
  const lowerBound = _.set({}, xValuePath, xValueBounds.min);
  const upperBound = _.set({}, xValuePath, xValueBounds.max);

  const firstIndex = _.sortedIndexBy(data, lowerBound, xValuePath);
  const lastIndex = _.sortedLastIndexBy(data, upperBound, xValuePath);

  return adjustBounds(firstIndex, lastIndex, data.length);
}
开发者ID:abe732,项目名称:react-layered-chart,代码行数:9,代码来源:renderUtils.ts

示例3: getBoundsForInstantaeousData

export function getBoundsForInstantaeousData(timestampedData: SeriesData, timeRange: Range, timestampPath: string = 'timestamp'): IndexBounds {
  const lowerBound = _.set({}, timestampPath, timeRange.min);
  const upperBound = _.set({}, timestampPath, timeRange.max);

  const firstIndex = _.sortedIndexBy(timestampedData, lowerBound, timestampPath);
  const lastIndex = _.sortedLastIndexBy(timestampedData, upperBound, timestampPath);

  return adjustBounds(firstIndex, lastIndex, timestampedData.length);
}
开发者ID:briann,项目名称:react-layered-chart,代码行数:9,代码来源:util.ts

示例4: createRoom

export function createRoom(roomName: string, socket: LobbySocket) {
  const room =  new Room(roomName);

  byName[roomName] = room;

  const index = _.sortedIndexBy(sortedByPlayerCount, room.entry, (x) => -x.playerCount);
  sortedByPlayerCount.splice(index, 0, room.entry);

  return room;
}
开发者ID:elisee,项目名称:make-game,代码行数:10,代码来源:rooms.ts

示例5:

 return _.mapValues(dataBySeriesId, (data: any[], seriesId: SeriesId) => {
   // -1 because sortedIndexBy returns the first index that would be /after/ the input value, but we're trying to
   // get whichever value comes before. Note that this may return undefined, but that's specifically allowed:
   // there may not be an appropriate hover value for this series.
   return data[ _.sortedIndexBy(data, haxWrappedHover, xIterator.bind(null, seriesId)) - 1 ];
 });
开发者ID:abe732,项目名称:react-layered-chart,代码行数:6,代码来源:exportableSelectors.ts

示例6: switch

const todos = (state = initialState, action: Action): TodosState => {
    switch (action.type) {
        case TodoActionType.Add:
            const lastTodo = state.todosById[last(state.orderedTodos)]
            const addId = lastTodo ? last(state.todos) + 1 : 0
            return assign({}, state, {
                todos: [...state.todos, addId],
                orderedTodos: [...state.orderedTodos, addId],
                todosById: assign({}, state.todosById, {
                    [addId]: {
                        id: addId,
                        order: state.orderedTodos.length,
                        isDone: false,
                        startHour: lastTodo ? (
                            moment(lastTodo.startHour)
                            .add(lastTodo.duration, 'minutes')
                            .toDate()
                        ) : (
                            moment({ hour: 9 }).toDate()
                        ),
                        duration: 60,
                        task: '',
                        detail: '',
                        isCreating: true,
                        isDeleting: false
                    }
                })
            })
        case TodoActionType.Added:
            return assign({}, state, {
                todosById: state.todos.reduce((obj, id) => {
                    let todo = state.todosById[id]
                    if (todo.isCreating) {
                        todo = assign({}, todo, {
                            isCreating: false
                        })
                    }
                    obj[id] = todo
                    return obj
                }, {} as TodosMap)
            })
        case TodoActionType.Delete:
            const { id: deleteId } = action as TodoAction
            return assign({}, state, {
                todosById: assign({}, state.todosById, {
                    [deleteId]: assign({}, state.todosById[deleteId], {
                        isDeleting: true
                    })
                })
            })
        case TodoActionType.Deleted:
            const { id: deletedId } = action as TodoAction
            const deletedTodo = state.todosById[deletedId]
            if (!deletedTodo) {
                return state
            }
            return assign({}, state, {
                todos: without(state.todos, deletedId),
                orderedTodos: without(state.orderedTodos, deletedId),
                todosById: state.todos.reduce((obj, id) => {
                    if (id === deletedId) {
                        return obj
                    }
                    let todo = state.todosById[id]
                    if (todo.order > deletedTodo.order) {
                        todo = assign({}, todo, {
                            order: todo.order - 1,
                            startHour: moment(todo.startHour)
                                .subtract(deletedTodo.duration, 'minutes')
                                .toDate()
                        })
                    }
                    obj[id] = todo
                    return obj
                }, {} as TodosMap)
            })
        case TodoActionType.Move:
            const { fromPos: moveFromPos, toPos: moveToPos } = action as MoveAction
            return moveTodo(state, moveFromPos, moveToPos)
        case TodoActionType.SetStartHour:
            const { id: startHourId, value: startHour } = action as SetValueAction
            let startHourTodo = state.todosById[startHourId]
            let nextState = state
            if (startHourTodo.startHour > startHour) {
                const startHourFromPos = startHourTodo.order
                const startHourToPos = sortedIndexBy(
                    state.orderedTodos,
                    startHourId,
                    id => {
                        if (id === startHourId) {
                            return startHour
                        }
                        return state.todosById[id].startHour
                    }
                )
                nextState = moveTodo(state, startHourFromPos, startHourToPos)
                startHourTodo = nextState.todosById[startHourId]
            }
            const startHourDiff = moment(startHour)
                .diff(moment(startHourTodo.startHour), 'minutes')
//.........这里部分代码省略.........
开发者ID:Volcomix,项目名称:time-shifter,代码行数:101,代码来源:index.ts

示例7: sortedIndexBy

 this.on(eventType, (data: T) => {
   if (!matcher || matcher(data)) {
     const index = sortedIndexBy(list, data, 'id');
     list.splice(index, 0, data);
   }
 });
开发者ID:CWSpear,项目名称:name-game,代码行数:6,代码来源:base-model.class.ts


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