當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript object-assign類代碼示例

本文整理匯總了TypeScript中object-assign的典型用法代碼示例。如果您正苦於以下問題:TypeScript object-assign類的具體用法?TypeScript object-assign怎麽用?TypeScript object-assign使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了object-assign類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: assign

export default function reducer(state: LightsState = initialState, action: any = {}) {  
  switch (action.type) {
    case SHOW_SELECTOR:
      return assign({}, state, { showLightSelector: action.show });
    case SELECT_LIGHT:
      return assign({}, state, { selectedIndex: action.selectedLight.index });
    case SET_LIGHTS:
      return assign({}, state, {
        lights: action.lights,
        selectedIndex: 0,
      });
    case UPDATE_LIGHT_COLOR:
      setSelectedLight(state, assign({}, getSelectedLight(state), { color: action.color }));
      saveLights(state.lights);
      return assign({}, state, { list: [...state.lights] });
    case UPDATE_LIGHT_RADIUS:
      setSelectedLight(state, assign({}, getSelectedLight(state), { radius: action.radius }));
      saveLights(state.lights);
      return assign({}, state, { list: [...state.lights] });
    case UPDATE_LIGHT_INTENSITY:
      setSelectedLight(state, assign({}, getSelectedLight(state), { intensity: action.intensity }));
      saveLights(state.lights);
      return assign({}, state, { list: [...state.lights] });
    default: return state;
  }
}
開發者ID:JoelTerMeer,項目名稱:Camelot-Unchained,代碼行數:26,代碼來源:lights.ts

示例2: objectAssign

export const trackerStore = (state = initialState, action: Action): TrackerState => {
  switch (action.type) {
    case ActionType.UPDATE_AUTH_FORM:
      return objectAssign({}, state, {loginForm: action.loginForm});
    case ActionType.AUTHENTICATED:
      return objectAssign({}, state, {authenticated: true});
    case ActionType.NOT_AUTHENTICATED:
      return objectAssign({}, state, {authenticated: false});
    case ActionType.SET_CONFIG:
      return objectAssign({}, state, {config: action.config, profileId: action.profileId});
    default:
      return state;
  }
};
開發者ID:halversondm,項目名稱:toilet-training-tracker,代碼行數:14,代碼來源:index.ts

示例3: processPosts

function processPosts(params: IPostProcessingParams) {
    const { action, count, pageSize } = params;
    const current = params.state[action.props.id] || { count, pageSize, pages: {} };
    const currentPage = current.pages[action.props.page];
    const itemSet: Pages = objectAssign({}, current.pages, {
        [action.props.page]: pageReducer(currentPage, params.action)
    });
    const nestedPage: IItemPages = {
        pages: itemSet,
        count: count !== undefined ? count : current.count,
        pageSize: pageSize !== undefined ? pageSize : current.pageSize
    };
    return objectAssign({}, params.state, {
        [action.props.id]: nestedPage
    });
}
開發者ID:hwkns,項目名稱:streisand,代碼行數:16,代碼來源:reducer.ts

示例4: addGroups

function addGroups(current: ItemMap, groups: IForumGroup[]): ItemMap {
    let map: ItemMap = {};
    for (const item of groups) {
        map[item.id] = objectAssign({}, current[item.id], item);
    }
    return map;
}
開發者ID:hwkns,項目名稱:streisand,代碼行數:7,代碼來源:reducer.ts

示例5: saveLocal

 static saveLocal(data: TrackingBundle): Rx.Subject<string> {
   return recordStore.put(assign({
     _id              : `${data.context.timestamp}-${data.context.href}`,
     navigationTiming : data.navigationTiming,
     chromeLoadTimes  : data.chromeLoadTimes
   }, data.context))
 }
開發者ID:ahomu,項目名稱:webperf-collector,代碼行數:7,代碼來源:tracker.ts

示例6: assign

export default function reducer(state: BuildingState = initialState, action: any = {}) {
  switch (action.type) {
    case CHANGE_MODE:
      return assign({}, state, { mode: action.mode });
    default: return state;
  }
}
開發者ID:JoelTerMeer,項目名稱:Camelot-Unchained,代碼行數:7,代碼來源:building.ts

示例7: byId

function byId(state: ItemMap = {}, action: Action): ItemMap {
    switch (action.type) {
        case 'RECEIVED_FORUM_POST_UPDATE':
        return objectAssign({}, state, {[action.post.id]: action.post});
        case 'RECEIVED_FORUM_GROUPS':
        case 'RECEIVED_FORUM_TOPIC':
        case 'RECEIVED_FORUM_THREAD':
        case 'RECEIVED_NEWS_POST':
            let map: ItemMap = {};
            for (const item of action.props.data.posts) {
                map[item.id] = item;
            }
            return objectAssign({}, state, map);
        default:
            return state;
    }
}
開發者ID:hwkns,項目名稱:streisand,代碼行數:17,代碼來源:reducer.ts

示例8: assign

export default function reducer(state: MaterialsReplaceState = initialState, action: any = {}) {
  switch (action.type) {
    case BLOCKS_SELECTED:
      return assign({}, state, {
        blocksSelected: action.selected,
      });
    case SELECT_FROM_MATERIAL:
      return assign({}, state, {
        from: action.selectedMaterial,
      });
    case SELECT_TO_MATERIAL:
      return assign({}, state, {
        to: action.selectedMaterial,
      });
    default: return state;
  }
}
開發者ID:JoelTerMeer,項目名稱:Camelot-Unchained,代碼行數:17,代碼來源:materials-replace.ts

示例9: removeTopic

function removeTopic(group: IForumGroup, topicId: number): IForumGroup {
    if (group && group.topics) {
        const topics = group.topics.filter((topic: number) => {
            return topic !== topicId;
        });
        return objectAssign({}, group, { topics });
    }
    return group;
}
開發者ID:hwkns,項目名稱:streisand,代碼行數:9,代碼來源:reducer.ts

示例10: assign

export default function reducer(state: BlueprintsState = initialState, action: any = {}) {
  switch (action.type) {
    case UPDATE_BLUEPRINTS:
      return assign({}, state, {
        blueprints: [...action.blueprints],
      });
    case SELECT_BLUEPRINT:
      return assign({}, state, {
        selected: action.blueprint,
      });
    case MODE_CHANGED:
      return assign({}, state, {
        copyable: action.copy === undefined ? state.copyable : action.copy,
        pastable: action.paste === undefined ? state.pastable : action.paste,
      });
    default: return state;
  }
}
開發者ID:JoelTerMeer,項目名稱:Camelot-Unchained,代碼行數:18,代碼來源:blueprints.ts

示例11: assign

function assign() {
  return objectAssign({hellow: "world"}, {source1: "U"}, {source2: "V"}, {source3: "W"}, {source4: "Q"}, {source5: "R"}, {
    hellow: "hellow",
    source1: "source1",
    source2: "source2",
    source3: "source3",
    source4: "source4",
    source5: "source5",
    generic: "any"
  });
}
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:11,代碼來源:object-assign-tests.ts

示例12: assign

export default function reducer(state: MaterialsState = initialState, action: any = {}) {
  switch (action.type) {
    case SET_MATERIALS:
      return assign({}, state, {
        materials: action.materials,
        selectedMaterial: action.materials[0],
        selectedBlock: action.materials[0].blocks[0],
      });
    case SELECT_MATERIAL:
      return assign({}, state, {
        selectedMaterial: action.selectedMaterial,
      });
    case SELECT_BLOCK:
      const block: BuildingBlock = action.selectedBlock;
      const newState: MaterialsState = { selectedBlock: block } as MaterialsState;
      if (state.selectedMaterial.id !== block.materialId)
        newState.selectedMaterial = getMaterialById(block.materialId, state.materials);
      return assign({}, state, newState);
    default: return state;
  }
}
開發者ID:JoelTerMeer,項目名稱:Camelot-Unchained,代碼行數:21,代碼來源:materials.ts

示例13: assign

export function post<T>(options: IPostRequestOptions): Promise<T> {
    const headers = assign({
        'Accept': 'application/json',
        'Content-Type': 'application/json'
    }, options.headers || {});
    if (options.token) {
        headers['Authorization'] = `Token ${options.token}`;
    }
    const formatted = !options.data || typeof options.data === 'string' || options.data instanceof File;
    const data = formatted ? options.data : JSON.stringify(options.data);
    return makeRequest<T>({ url: options.url, method: 'POST', headers, data });
}
開發者ID:hwkns,項目名稱:streisand,代碼行數:12,代碼來源:Requestor.ts

示例14: byTorrentId

function byTorrentId(state: Peers = {}, action: Action): Peers {
    switch (action.type) {
        case 'REQUEST_PEERS':
        case 'RECEIVED_PEERS':
        case 'FAILED_PEERS':
            const currentItemSet = state[action.props.id];
            const newItemSet = torrentPagesReducer(currentItemSet, action);
            return objectAssign({}, state, { [action.props.id]: newItemSet });
        default:
            return state;
    }
}
開發者ID:hwkns,項目名稱:streisand,代碼行數:12,代碼來源:reducer.ts

示例15: objectAssign

export function addLoadedNode<T extends IItem>(current: INodeMap<T>, item: T): INodeMap<T> {
    const node: IItemNode<T> = {
        status: {
            loading: false,
            loaded: true,
            failed: false,
            outdated: false
        },
        item: item
    };
    return objectAssign({}, current, { [item.id]: node });
}
開發者ID:hwkns,項目名稱:streisand,代碼行數:12,代碼來源:mutations.ts


注:本文中的object-assign類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。