Example #1
0
  function normalItemSets() {
    const builds = [];
    if (R.equals(freq_start.build, highest_start.build)) {
      builds.push({
        items: freq_start.build,
        type: templates.combindedStart(freq_start.wins, freq_start.games)
      });
    } else {
      builds.push({
        items: freq_start.build,
        type: templates.freqStart(freq_start.wins, freq_start.games)
      });
      builds.push({
        items: highest_start.build,
        type: templates.highestStart(highest_start.wins, highest_start.games)
      });
    }
    if (R.equals(freq_core.build, highest_core.build)) {
      builds.push({
        items: freq_core.build,
        type: templates.combinedCore(freq_core.wins, freq_core.games)
      });
    } else {
      builds.push({
        items: freq_core.build,
        type: templates.freqCore(freq_core.wins, freq_core.games)
      });
      builds.push({
        items: highest_core.build,
        type: templates.highestCore(highest_core.wins, highest_core.games)
      });
    }

    return trinksCon(builds, skills);
  }
Example #2
0
    _addService = function _addService(service) {

        var createProxy;

        if (!service.name) {
            throw 'service name is mandatory';
        }
        if (!service.namespace) {
            throw 'service namespace is mandatory';
        }
        _validadeService(service);
        _services = _services || [];
        _services.push(service.name);

        service.async = (service.async === undefined ? true : service.async);

        createProxy = R.curry(_createPromisifyProxy);

        R.pipe(
            R.flatten,
            R.uniq,
            R.filter(R.compose(R.not, R.either(R.equals('constructor'), R.compose(R.equals('_'), R.head)))),
            R.forEach(createProxy(service))
        )([
            Object.getOwnPropertyNames(Object.getPrototypeOf(service)),
            Object.keys(service)
        ]);

        _servicePubFunctions[service.name] = service;
        return service;
    };
Example #3
0
  return boards.find((board2) => {
    const analogPins2 = [];
    const pwmPins2 = [];
    let digitalPins2 = [];

    Object.keys(board2.pins).forEach((key) => {
      const pin = board2.pins[key];

      if (pin.categories.includes('Analog')) {
        analogPins2.push(key);
      }
      if (pin.categories.includes('PWM')) {
        pwmPins2.push(key);
      }
      if (pin.categories.includes('Digital')) {
        digitalPins2.push(key);
      }
    });

    // exclude D0 & D1 (serial Rx & Tx on most arduinos)
    digitalPins2 = difference(digitalPins2, ['0', '1']);

    return equals(digitalPins.sort(), digitalPins2.sort()) &&
           equals(analogPins.sort(), analogPins2.sort()) &&
           equals(pwmPins.sort(), pwmPins2.sort());
  });
Example #4
0
File: cd.js Project: lpan/rebash
const getPath = (currentPath, homePath) => cond([
  [equals('~'), always(homePath)],
  [equals('.'), always(currentPath)],
  [equals('..'), always(init(currentPath))],
  [isAbsolutePath, splitPath],
  [T, flip(append)(currentPath)],
]);
Example #5
0
const onComponentShouldUpdate = (domNode, lastProps, nextProps) => {
  console.log(lastProps, nextProps);
  console.log('items equal?', R.equals(lastProps.item, nextProps.item));
  console.log('children equal?', R.equals(lastProps.children, nextProps.children));
  console.log('children dom properties', lastProps.children.dom, nextProps.children.dom);
  return !R.equals(lastProps, nextProps);
}
Example #6
0
export function textForValue (value) {
  return cond([
    [equals(null), always(NULL_TEXT)],
    [equals(undefined), always(UNDEFINED_TEXT)],
    [x => typeof x === 'boolean', always(value ? TRUE_TEXT : FALSE_TEXT)],
    [T, identity]
  ])(value)
}
Example #7
0
PatchType.fromPatch = function fromPath(patch) {
  if (patch[$$type]) return patch[$$type]
  
  const { path, op } = patch

  let tok

  const pathElements = path.split('/').slice(1)
      , advance = () => (tok = pathElements.shift())

  if (!advance()) {
    return patch[$$type] = PatchType.Unknown
  }

  if (tok === '@context') {
    return patch[$$type] = PatchType.ChangeContext
  }

  if (tok !== 'authorities') {
    return patch[$$type] = PatchType.Unknown
  }

  // Move on from authorities
  if (!advance()) {
    return patch[$$type] = PatchType.Unknown
  }

  const authorityID = pointer.unescape(tok)

  if (!advance()) {
    return patch[$$type] = R.cond([
      [R.equals('add'), () => PatchType.AddAuthority(authorityID)],
      [R.equals('remove'), () => PatchType.RemoveAuthority(authorityID)],
      [R.T, () => PatchType.Unknown]
    ])(op)
  }

  if (tok !== 'periods') {
    return patch[$$type] = PatchType.ChangeAuthority(authorityID, tok)
  }

  // Move on to period definition
  if (!advance()) {
    return patch[$$type] = PatchType.Unknown
  }

  const periodID = pointer.unescape(tok)

  if (!advance()) {
    return patch[$$type] = R.cond([
      [R.equals('add'), () => PatchType.AddPeriod(authorityID, periodID)],
      [R.equals('remove'), () => PatchType.RemovePeriod(authorityID, periodID)],
      [R.T, () => PatchType.Unknown]
    ])(op)
  }

  return patch[$$type] = PatchType.ChangePeriod(authorityID, periodID, tok)
}
Example #8
0
		it('should render the child component the value is eq the nr', () => {
			let component = TestUtils.renderIntoDocument(
				<Cond value={10}>
					{[ R.equals(11), <h1 key={1}>unexpected</h1>]}
					{[ R.equals(10), <h1 key={2}>expected</h1>]}
					{[ R.T, <h1 key={1}>unexpected</h1>]}
				</Cond>
			);
			let val = TestUtils.findRenderedDOMComponentWithTag(component, 'h1');
			equal(val.textContent, 'expected');
		});
Example #9
0
 .scan((state, latest) => {
   Console.log({state, latest})
   switch (state) {
   case (States.stopped):
     return R.equals(latest, ClockStart) ? States.armed : States.stopped
   case (States.armed):
     return !R.contains(latest, [ClockStart, ClockStop]) ? States.recording : States.armed
   case (States.recording):
     return R.equals(latest, ClockStop) ? States.stopped : States.recording
   default:
     throw Error('Weird state')
   }
 }, States.armed)
Example #10
0
 .scan(([phrase, bar, beat, tick], message) => {
     //Console.log('tick')
   if (R.equals(message, ClockStart)) {
     return [0, 0, 0, 0]
   } else if (R.equals(message, ClockTick)) {
     const tickOverflow = tick === 23 ? 1 : 0
     tick = (tick + 1) % 24
     const beatOverflow = beat === 3 && tickOverflow ? 1 : 0
     beat = (beat + tickOverflow) % 4
     const barOverflow = bar === 3 && beatOverflow ? 1 : 0
     bar = (bar + beatOverflow) % 4
     phrase += barOverflow
     return [phrase, bar, beat, tick]
   }
 }, [0, 0, 0, 0])
Example #11
0
  const placeMark = (cell, turn) => {
    const CLOSED = 0
    if (equals(cell.state, CLOSED)) {
      cell.state = turn

      if (equals(turn, 1)) {
        turn++
      } else {
        turn--
      }

      checkGameStatus(board)
      listeners[0](clone(turn))
    }
  }
 it('should generate a symmetric multi dimensional array', (done) => {
   const ROWS = 2
   const COLUMNS = 2
   const matrix = generateMatrix(ROWS, COLUMNS)
   assert(R.equals(twoBytwoMatrix, matrix))
   done()
 })
Example #13
0
    jsv.property('composition law', 'ZipArray nat', 'nat', env, (xs, x) => {
      const f = R.curry((a, b) => a + b);
      const left = xs.map(y => f(x)(y)).runZipArray;
      const right = xs.map(f).map(f => f(x)).runZipArray;

      return R.equals(left, right);
    });
 [R.map(value => R.cond([
   [
     R.equals(selected),
     R.always(option({ value, selected: true }, props.render(value))),
   ],
   [R.T, R.always(option({ value }, props.render(value)))],
 ])(value), values)]
export default async function (event) {
    log.info(event, "event");
    /*
    *   Workaround: some events have been incorrectly generated and thus don't
    *   have an `element` property. When processing said events, just return and
    *   move on without failing, as failures can block the kinesis stream.
    */
    const rawReading = event.data.element;
    if (!rawReading) {
        return null;
    }
    // Skip if answers type isn't survey
    if (!equals(rawReading.type, SURVEY)) {
        return null;
    }

    // retrieve user
    const user = await getUserById(rawReading.userId);
    if (!user) {
        log.error(`User ${rawReading.userId} not found`);
        return null;
    }

    // Upsert user with new survey set to completed
    await upsertCompletedSurvey(rawReading, user);

    return null;
}
 it('should generate a non symmetric multi dimensional array', (done) => {
   const ROWS = 1
   const COLUMNS = 3
   const matrix = generateMatrix(ROWS, COLUMNS)
   assert(R.equals(oneBythreeMatrix, matrix))
   done()
 })
const updateFinancialAidValidation = (dispatch, current) => {
  const errors = validateFinancialAid(current)
  if (!R.equals(errors, current.validation)) {
    dispatch(updateCalculatorValidation(errors))
  }
  return R.isEmpty(errors)
}
Example #18
0
function removeTagFromRepo(state, payload) {
  return u({
    [payload.repo_id]: {
      tags: reject(equals(payload.tag_id))
    }
  }, state);
}
function viewsTextToNum(text) {
  const numPart = R.pipe(R.trim, R.split(' '), R.head);
  const ifEmptyToBeZero = R.when(R.equals('No'), R.always('0'));
  const toNumber = R.pipe(R.replace(/,/g, ''), parseInt);

  return R.pipe(numPart, ifEmptyToBeZero, toNumber)(text);
}
Example #20
0
 isPrivileged = (username: string): boolean =>
   R.or(
     hasAnyStaffRole(SETTINGS.roles),
     R.isNil(SETTINGS.user)
       ? R.F()
       : R.equals(R.prop("username", SETTINGS.user), username)
   )
Example #21
0
 const check = actual => {
   if (!R.equals(actual, expect)) {
     done(Error(`Expected: ${show(expect)}, actual: ${show(actual)}`))
   } else {
     done()
   }
 }
Example #22
0
    checkTransaction(transaction, referenceBlockchain = this.blocks) {

        // Check the transaction
        transaction.check(transaction);

        // Verify if the transaction isn't already in the blockchain
        let isNotInBlockchain = R.all((block) => {
            return R.none(R.propEq('id', transaction.id), block.transactions);
        }, referenceBlockchain);

        if (!isNotInBlockchain) {
            console.error(`Transaction '${transaction.id}' is already in the blockchain`);
            throw new TransactionAssertionError(`Transaction '${transaction.id}' is already in the blockchain`, transaction);
        }

        // Verify if all input transactions are unspent in the blockchain
        let isInputTransactionsUnspent = R.all(R.equals(false), R.flatten(R.map((txInput) => {
            return R.map(
                R.pipe(
                    R.prop('transactions'),
                    R.map(R.pipe(
                        R.path(['data', 'inputs']),
                        R.contains({ transaction: txInput.transaction, index: txInput.index })
                    ))
                ), referenceBlockchain);
        }, transaction.data.inputs)));

        if (!isInputTransactionsUnspent) {
            console.error(`Not all inputs are unspent for transaction '${transaction.id}'`);
            throw new TransactionAssertionError(`Not all inputs are unspent for transaction '${transaction.id}'`, transaction.data.inputs);
        }

        return true;
    }
Example #23
0
    jsv.property('composition law', 'array nat', 'nat', (xs, x) => {
      const f = R.curry((a, b) => a + b);
      const left = map(y => f(x)(y), xs);
      const right = map(g => g(x), map(f, xs));

      return R.equals(left, right);
    });
Example #24
0
export const updateConfirm = () => {
  if (!store.statusClean) return false
  // TODO: 只去除 null 的即可,如果为空也是合法的
  const editing = pickUpdatable(store.accountInfo)
  const origin = pickUpdatable(store.accountOrigin)
  /* debug('editing: ', editing) */
  /* debug('origin: ', origin) */

  // TODO: 唯一的限制是 昵称不能为空
  if (R.equals(editing, origin)) {
    meteorState(store, 'warn', 3)
    return false
  }

  store.markState({ updating: true })

  sr71$.mutate(S.updateProfile, { profile: editing })

  /*
  setTimeout(() => {
    store.markState({
      updating: false,
    })
    meteorState(store, 'error', 5, '自定义错误')
  }, 3000)
  */
}
let constantActionLogger = (logger) => (store) => (next) => (action) => {
  const stateBefore = store.getState()
  const result = next(action);
  const stateAfter = store.getState()
  if (R.equals(stateBefore, stateAfter)) {
    logger.warn("An action was dispatched that did not change state", action);
  }
}
Example #26
0
test('utils.sortHand', t => {
  const hand1 = ['S_3', 'H_14', 'D_10']
  const actual = utils.sortHand(hand1)

  const expected = ['H_14', 'S_3', 'D_10']
  t.deepEqual(actual, expected)
  t.true(!R.equals(actual, hand1))
})
Example #27
0
/* [String] -> [ComplexObject]
 *
 * Part One:
 * Hint: try each complex parser (parsers which read complex types)
 * and use the first one which has any result, if none do then we can
 * return an empty list, because we couldn't parse anything.
 *
 * Further Hint: Use recursion.
 */
function parseTokens (tokens) {
    var firstDefined = _.compose (_.head, _.dropWhile (_.compose (_.equals (undefined), _.prop ('Parsed'))));
    var parsed = firstDefined ([undefined]);
    if (parsed == undefined) {
        undefined;
    }
    return _.concat ([parsed.Parsed], parseTokens (undefined));
}
Example #28
0
 componentWillReceiveProps(nextProps) {
   if (!R.equals(this.props.query, nextProps.query) && !R.isEmpty(nextProps.query)) {
     this.setState({
       novels: List(),
     });
     this.addNextNovelList(nextProps.query, 0);
   }
 }
Example #29
0
export const multivarka = (...reqBuildChain) => compose(
  tap(startRequest),
  over(lensProp('query'), RWhen(
    pathSatisfies(equals(0), ['$and', 'length']),
    omit(['$and'])
  )),
  ...reqBuildChain
)(RequestType);
Example #30
0
function testProduces (output, fn) {
  try {
    const o = fn()
    return R.equals(o, output)
  } catch (err) {
    return false
  }
}