當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。