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


TypeScript ramda.merge函數代碼示例

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


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

示例1: checkOneBrowser

function checkOneBrowser(browser: Browser) {
  const platform = os.platform()
  const pickBrowserProps = pick([
    'name',
    'displayName',
    'type',
    'version',
    'path'
  ])

  const logBrowser = (props: any) => {
    log('setting major version for %j', props)
  }

  const failed = (err: NotInstalledError) => {
    if (err.notInstalled) {
      log('browser %s not installed', browser.name)
      return false
    }
    throw err
  }

  log('checking one browser %s', browser.name)
  return lookup(platform, browser)
    .then(merge(browser))
    .then(pickBrowserProps)
    .then(tap(logBrowser))
    .then(setMajorVersion)
    .catch(failed)
}
開發者ID:lgandecki,項目名稱:cypress,代碼行數:30,代碼來源:detect.ts

示例2: merge

 const set = data => {
   for (let x = 0; x < data.width; x++) {
     for (let y = 0; y < data.height; y++) {
       // cant read from MST array above bounds, so check length first
       // @ts-ignore
       self.field[x] = x === self.field.length ? [] : self.field[x]
       self.field[x][y] = y === self.field[x].length ? {} : self.field[x][y]
       // merge to preserve flags on UI
       self.field[x][y] = merge(self.field[x][y], data.field[x][y])
     }
   }
   Object.assign(
     self,
     pick(
       [
         'width',
         'height',
         'bombCount',
         'cellsLeft',
         'isFinished',
         'isWon',
         'isLost'
       ],
       data
     )
   )
 }
開發者ID:NotBadDevs,項目名稱:minesweepers,代碼行數:27,代碼來源:game.ts

示例3: writeFileStreamCB

        function writeFileStreamCB(e, file) {
            if (e) return observer.error(e);

            observer.next(merge(
                getFilenameMetaData(path || ''),
                {file}
            ));
            observer.complete();
        }
開發者ID:r-k-b,項目名稱:newsblur-feed-info,代碼行數:9,代碼來源:index.ts

示例4: merge

const frameReducer = (state: FrameState, action: FrameAction): FrameState => {
  if (action.type === "cycle") {
    if (state.view === "score") {
      return merge(state, {
        view: "pins",
        squareNumber: 1,
      })
    } else {
      const nextSquare = state.squareNumber + 1
      if (nextSquare > state.frame.squares.length) {
        return merge(state, { view: "score" })
      }
      return merge(state, {
        view: "pins",
        squareNumber: nextSquare,
      })
    }
  }
  return state
}
開發者ID:nordfjord,項目名稱:eyc-live,代碼行數:20,代碼來源:Frame.ts

示例5:

      this[actionType] = (_payload) => {

        // Check to see if the payload is an object or not
        let payload = R.is(Object, _payload) ? _payload : {};
        // Attach action type to the payload
        payload = R.merge(_payload, { actionType: actionType });
        this.dispatcher.dispatch(payload);
        // return payload for testing
        return payload;

      };
開發者ID:webintensive,項目名稱:angular-2-transition-utils,代碼行數:11,代碼來源:actions.ts

示例6: reduceHealth

const damageMinionHandler = (
  state: Minion,
  payload: DealDamagePayload
): Minion => {
  const health = reduceHealth(state, payload.amount);

  return R.merge(state, {
    destroyed: health <= 0,
    health: health,
  });
};
開發者ID:zernie,項目名稱:typescript-redux-card-game,代碼行數:11,代碼來源:minionReducer.ts

示例7: reduceHealth

const damageHeroHandler = (state: Hero, payload: DealDamagePayload): Hero => {
  const health = reduceHealth(state, payload.amount);
  const destroyed = health <= 0;

  return R.merge(state, {
    armor: reduceArmor(state, payload.amount),
    destroyed,
    playState: destroyed ? PlayState.Lost : state.playState,
    health: health,
  });
};
開發者ID:zernie,項目名稱:typescript-redux-card-game,代碼行數:11,代碼來源:heroReducer.ts

示例8: switch

const panesReducer = (previousState = initialState, action) => {
  if (isPanesModule(action)) {
    switch (action.type) {
      case panesActionTypes.OPEN: {
        const {
          payload: { pane },
        } = action;
        return { activeKey: pane.key, panes: { ...previousState.panes, [pane.key]: pane } };
      }
      case panesActionTypes.ACTIVE: {
        const {
          payload: { key },
        } = action;
        return { ...previousState, activeKey: key };
      }
      case panesActionTypes.CLOSE: {
        const { activeKey, panes } = previousState;
        const {
          payload: { key },
        } = action;

        // prettier-ignore
        const index = R.compose(R.indexOf(activeKey), R.keys)(panes);
        const nextPanes = _.omit(panes, key);

        const nextKeys = _.keys(nextPanes);
        const nextKey =
          activeKey && _.has(nextPanes, activeKey)
            ? activeKey
            : // 關閉當前 tab 時定位到後麵一個 tab
              nextKeys[_.min([index, nextKeys.length - 1]) as number];
        return { activeKey: nextKey, panes: nextPanes };
      }
      case panesActionTypes.CLOSE_ALL: {
        return {};
      }
      case panesActionTypes.CLOSE_WITHOUT: {
        const {
          payload: { activeKey },
        } = action;
        if (activeKey) {
          const panes = R.pick([activeKey])(previousState.panes);
          return R.merge(previousState, { panes });
        }
        return {};
      }
      default:
        return { ...previousState, ...action.payload };
    }
  }
  return previousState;
};
開發者ID:danielwii,項目名稱:asuna-admin,代碼行數:52,代碼來源:panes.redux.ts

示例9: detect

export function detect(browser: Browser): Promise<FoundBrowser> {
  let fn = browsers[browser.name]

  if (!fn) {
    // ok, maybe it is custom alias?
    log('detecting custom browser %s on darwin', browser.name)
    return linuxHelper.detect(browser)
  }

  return fn()
    .then(merge({ name: browser.name }))
    .catch(() => {
      log('could not detect %s using traditional Mac methods', browser.name)
      log('trying linux search')
      return linuxHelper.detect(browser)
    })
}
開發者ID:YOU54F,項目名稱:cypress,代碼行數:17,代碼來源:index.ts

示例10: constructors

function constructors(state = [], action): Array<Constructor> {
    // CREATE A NEW TEST CONTROLER

    let newConstructorcopy = Array.from(state);

    switch (action.type) {
        case constants.CREATE_NEW_CONSTRUCTOR:

            newConstructorcopy.push(R.merge(action.elements, {

                browsers: R.clone(getState("browsersSelect"))

            }));

            return newConstructorcopy;
        default:
            return state;
    }
}
開發者ID:thehachez,項目名稱:maduk,代碼行數:19,代碼來源:index.ts


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