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


TypeScript Map.merge方法代码示例

本文整理汇总了TypeScript中Immutable.Map.merge方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Map.merge方法的具体用法?TypeScript Map.merge怎么用?TypeScript Map.merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Immutable.Map的用法示例。


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

示例1: appdb

export default function appdb(state:Map<string, any> = Map<string, any>({}), action:any):Map<string, any> {
    switch (action.type) {
        case StationsAction.RECEIVE_TOTAL_STATIONS:
            return state.merge({
                totalStations: {time: Date.now(), totalStations: action.totalStations}
            });
        case AppdbAction.AUTH_FAIL:
        case AppdbAction.AUTH_PASS:
            return state.merge({
                credentials: {
                    authenticated: action.authenticated,
                    user: action.user,
                    pass: action.pass,
                    remember: action.remember,
                    reason: action.reason
                },
                appBaseUrlUser: `${baseUrl}?resellerUserName=${action.user}&resellerPassword=${action.pass}`
            });
        case AppdbAction.APP_INIT:
            return state.merge({
                appStartTime: Date.now(),
                appBaseUrl: `${baseUrl}`
            });
        case AppdbAction.CLOUD_SERVERS:
            return state.merge({
                cloudServers: action.payload
            });
        case AppdbAction.SERVERS_STATUS:
            return state.merge({serversStatus: action.payload});
        default:
            return state;
    }
}
开发者ID:Floodlight-Studios,项目名称:studioDashboard,代码行数:33,代码来源:AppdbReducer.ts

示例2: applyAction

function applyAction(state:Map<string,string>, action:IAction):Map<string,string> {
    switch (action.key) {
        case Keys.ChangeName :
        {
            var name:string = action.payload.get('name');
            state = state.merge({name});
            break;
        }
        default:
    }
    return state;
}
开发者ID:darcy-buttrose,项目名称:rx-ko-phantom-mocha,代码行数:12,代码来源:Model.ts

示例3: addFile

  addFile(xmileDoc: XMLDocument, isMain = false): [Project, undefined] | [undefined, Error] {
    const [file, err] = Project.parseFile(xmileDoc);
    if (err) {
      return [undefined, err];
    }

    const files = this.files.push(defined(file));

    // FIXME: merge the other parts of the model into the project
    const models = Map(
      defined(file).models.map(
        (xModel): [string, Model] => {
          const model = new Model(this, xModel);
          return [model.ident, model];
        },
      ),
    );

    let dupErr: Error | undefined;
    models.forEach((model, name) => {
      if (this.models.has(name)) {
        dupErr = new Error(`duplicate name ${name}`);
      }
    });
    if (dupErr) {
      return [undefined, dupErr];
    }

    const xMod = new xmile.Variable({
      type: 'module',
      name: 'main',
    });
    const main = new Module(xMod);

    let newProject = this.mergeDeep({
      files,
      models: this.models.merge(models),
      main,
    });

    if (models.has('main') && defined(file).header && defined(defined(file).header).name) {
      newProject = newProject.set('name', defined(defined(file).header).name);
    }

    return [newProject, undefined];
  }
开发者ID:sdlabs,项目名称:sd.js,代码行数:46,代码来源:project.ts

示例4: fill

    /**
     * Merges data provided with data contained in this.data.
     *
     * @param data
     * @returns {Item}
     */
    fill(data : ItemData) : this {
        this.data = this.data.merge(data);

        return this;
    }
开发者ID:aaronheath,项目名称:afl-2016,代码行数:11,代码来源:item.ts

示例5: switch


//.........这里部分代码省略.........
                    // it just doesn't have a model
                    // entry.type
                    assumedType: entry.type,
                    lastSaved: entry.last_modified,
                    filepath: entry.path
                  })
                ];
              }
            )
          );

          const items = List<ContentRef>(dummyRecords.keys());
          const sorted: List<string> = items.sort((aRef, bRef) => {
            const a:
              | RecordOf<DummyContentRecordProps>
              | undefined = dummyRecords.get(aRef) as RecordOf<
              DummyContentRecordProps
            >;
            const b:
              | RecordOf<DummyContentRecordProps>
              | undefined = dummyRecords.get(bRef) as RecordOf<
              DummyContentRecordProps
            >;

            if (a.assumedType === b.assumedType) {
              return a.filepath.localeCompare(b.filepath);
            }
            return a.assumedType.localeCompare(b.assumedType);
          });

          return (
            state
              // Bring in all the listed records
              .merge(dummyRecords)
              // Set up the base directory
              .set(
                fetchContentFulfilledAction.payload.contentRef,
                makeDirectoryContentRecord({
                  model: makeDirectoryModel({
                    type: "directory",
                    // The listing is all these contents in aggregate
                    items: sorted
                  }),
                  filepath: fetchContentFulfilledAction.payload.filepath,
                  lastSaved:
                    fetchContentFulfilledAction.payload.model.last_modified,
                  created: fetchContentFulfilledAction.payload.model.created,
                  loading: false,
                  saving: false,
                  error: null
                })
              )
          );
        }
        case "notebook": {
          const immutableNotebook = fromJS(
            fetchContentFulfilledAction.payload.model.content
          );

          return state.set(
            fetchContentFulfilledAction.payload.contentRef,
            makeNotebookContentRecord({
              created: fetchContentFulfilledAction.payload.created,
              lastSaved: fetchContentFulfilledAction.payload.lastSaved,
              filepath: fetchContentFulfilledAction.payload.filepath,
              model: makeDocumentRecord({
开发者ID:nteract,项目名称:nteract,代码行数:67,代码来源:index.ts


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