当前位置: 首页>>代码示例>>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;未经允许,请勿转载。