Example #1
0
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)
}
Example #2
0
 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
     )
   )
 }
Example #3
0
        function writeFileStreamCB(e, file) {
            if (e) return observer.error(e);

            observer.next(merge(
                getFilenameMetaData(path || ''),
                {file}
            ));
            observer.complete();
        }
Example #4
0
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
}
      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;

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

  return R.merge(state, {
    destroyed: health <= 0,
    health: health,
  });
};
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,
  });
};
Example #8
0
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;
};
Example #9
0
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)
    })
}
Example #10
0
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;
    }
}