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


TypeScript es6-shim.Object類代碼示例

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


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

示例1: switch

const copyFileAndShowSummary = (state: AppState = initialState, action: any) => {
    switch (action.type) {
        
        case types.COPY_FILE_CONTENTS:
            let copy_action: CopyFileContents = action;
            return ES6.Object.assign({}, state, {
                fileNameOrErrorMessage: copy_action.fileName,
                text: copy_action.contents
            })
        
        case types.REJECT_FILE:
            let reject_action: RejectFile = action;
            return ES6.Object.assign({}, state, {
                fileNameOrErrorMessage: reject_action.errorMessage
            })
        
        case types.SHOW_TEXT_SUMMARY:
            let summarize_action: ShowTextSummary = action;
            let line_number = summarize_action.text.split('\n').length;
            if (summarize_action.text === "") {
                line_number = 0
            }
            let char_and_space_count = summarize_action.text.length;
            // convert [\r\n\t\s]+ to spaces
            let text = summarize_action.text.replace(/[\r\n\t\s]+/g, " ").trim();
            let word_count = text.split(" ").length;
            if (text === "") {
                word_count = 0
            }
            // remove spaces
            text = text.replace(/ /g, "");
            let char_count = text.length;
            return ES6.Object.assign({}, state, {
                text: summarize_action.text,
                summary: {
                    character_count: char_count,
                    character_and_space_count: char_and_space_count,
                    word_count: word_count,
                    line_number: line_number
                }
            })
        
        default:
            return state
    
    }
}
開發者ID:NariseT,項目名稱:summarize-text-data-appbar,代碼行數:47,代碼來源:copyFileAndShowSummary.ts

示例2:

const changeColor = (state, action) =>
    ES6.Object.assign({}, state, { color: action.color });
開發者ID:riesvriend,項目名稱:typescript-redux-iefix,代碼行數:2,代碼來源:reducers.ts

示例3:

export const changeShape = (state, action) => {
    var shape = ES6.Object.assign({}, state.shapes.filter(x => x.id === action.id)[0],
        { top: action.top, left: action.left });
    return ES6.Object.assign({}, state, { shapes: [...state.shapes.filter(x => x.id !== action.id), shape] });
};
開發者ID:riesvriend,項目名稱:typescript-redux-iefix,代碼行數:5,代碼來源:shapeReducers.ts


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