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