How to use the ramda.is function in ramda

To help you get started, we’ve selected a few ramda examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zerobias / speak-r / app / core / say.js View on Github external
function collectData(obj) {
  const collect = R.cond([
    [R.is(Array),sayPipe],
    // [Lexeme.its.arg,P(R.path(['head','value']),e=>e.arg())],
    [Lexeme.its.pipe,sayPipe],

    // [eq.type.arg,P(pipelog('arg'),R.prop('pipe'))],
    [Lexeme.its.atomic,sayAtomic],
    [P(HeadList.isList,R.not),util.prop.val],
    [R.T,e=>{throw new CompileException(e)}]
  ])
  return collect(obj)
}
github flow-typed / flow-typed / definitions / npm / ramda_v0.x.x / flow_v0.39.x-v0.48.x / test_ramda_v0.x.x_misc.js View on Github external
const ss3: string = _.replace(",", "|", "b,d,d");
  const ss2: Array = _.split(",", "b,d,d");
  const ss1: boolean = _.test(/h/, "b");
  const s: string = _.trim("s");
  const x: string = _.head("one");
  const sss: string = _.concat("H", "E");
  const sss1: string = _.concat("H")("E");
  const ssss: string = _.drop(1, "EF");
  const ssss1: string = _.drop(1)("E");
  const ssss2: string = _.dropLast(1, "EF");
  const ys: string = _.nth(2, "curry");
  const ys1: string = _.nth(2)("curry");
}
//Type
{
  const x: boolean = _.is(Number, 1);
  const x1: false = _.isNil(1);
  const x1a: true = _.isNil();
  const x1b: true = _.isNil(null);
  const x2: boolean = _.propIs(1, "num", { num: 1 });
}
github calmm-js / partial.lenses.validation / test / tests.js View on Github external
const dateRE = /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/

  const matches = re => R.both(R.is(String), R.test(re))

  const PregradingStaged = V.and(
    V.props({
      tutkintokerta: matches(/^\d{4}[KS]$/),
      koe: R.is(String),
      osa: R.equals(null),
      koulunumero: R.is(Number),
      arvostelunPäivämäärä: matches(dateRE),
      kysymykset: V.arrayId(R.is(String)),
      kokelaat: V.arrayId(
        V.props({
          etunimet: V.arrayId(R.is(String)),
          sukunimi: R.is(String),
          kokelasnumero: R.is(Number),
          valmistavaArvostelu: V.arrayId(
            V.props({
              kysymys: R.is(String),
              pisteet: R.both(Number.isInteger, R.lte(0))
            })
          ),
          pisteidenSumma: R.is(Number)
        })
      )
    }),
    V.choose(({kysymykset}) => {
      const kysymysCounts = L.counts(L.elems, kysymykset)
      return V.propsOr(V.accept, {
        kysymykset: V.arrayId(mapsTo(1, kysymysCounts)),
github calmm-js / partial.lenses.validation / test / tests.js View on Github external
  testAccepted(['1', 2], () => V.tuple(R.is(String), R.is(Number)))
  testAccepted([1, undefined, '2'], () => V.tuple(V.accept, V.accept, V.accept))
github flow-typed / flow-typed / definitions / npm / ramda_v0.x.x / flow_v0.62.x-v0.81.x / test_ramda_v0.x.x_logic.js View on Github external
{ x: { y: 2 } }
);
const psatPart = _.pathSatisfies(y => typeof y === "number" && y > 0);
const psat2: boolean = psatPart(["x", "y"])({ x: { y: 2 }, z: true });
const psatPart2 = _.pathSatisfies(y => typeof y === "number" && y > 0, [
  "x",
  "y"
]);
const psat3: boolean = psatPart2({ x: { y: 2 }, z: true });

const propSat: boolean = _.propSatisfies(x => x > 0, "x", { x: 1, y: 2 });
const coerceArray = _.unless(_.isArrayLike, _.of);
const coer: Array> | number = coerceArray([1, 2, 3]);
const coer1: Array> | number = coerceArray(1);

const coerceString = _.unless(_.is(String), _.toString);
const coer2: string | Array = coerceString([1, 2, 3]);
const coer3: string | Array = coerceString("s");

const unlPrt = _.unless(_.is(Number), _.T);
const unl: number | boolean | Array = unlPrt([1, 2, 3]);
const unl2: number | boolean | Array = unlPrt(1);

const un: number = _.until(_.gt(100), _.multiply(2))(1);
github beizhedenglong / react-multi-crops / src / components / Crop.js View on Github external
const {
      index,
      coordinate,
      coordinate: { x, y },
      coordinates,
      onResize,
      onChange,
    } = this.props
    const { width, height } = e.rect
    const { left, top } = e.deltaRect

    const nextCoordinate = {
      ...coordinate, x: x + left, y: y + top, width, height,
    }
    const nextCoordinates = update(index, nextCoordinate)(coordinates)
    if (is(Function, onResize)) {
      onResize(nextCoordinate, index, nextCoordinates)
    }
    if (is(Function, onChange)) {
      onChange(nextCoordinate, index, nextCoordinates)
    }
  }
  handleDragMove = (e) => {
github diegomura / react-pdf / src / stylesheet / flatten.js View on Github external
/**
 * Remove nil values from array
 *
 * @param {Array} array
 * @returns {Array} array without nils
 */
const compact = R.filter(Boolean);

/**
 * Checks if value is array
 *
 * @param {any} value
 * @returns {Boolean} is value an array
 */
const isArray = R.is(Array);

/**
 * Merges style objects array
 *
 * @param {Array} style objects array
 * @returns {Object} merged style object
 */
const mergeStyles = styles =>
  styles.reduce((acc, style) => {
    const s = isArray(style) ? flatten(style) : style;

    Object.keys(s).forEach(key => {
      if (s[key] !== null && s[key] !== undefined) {
        acc[key] = s[key];
      }
    });
github viddo / atom-textual-velocity / lib / path-watcher.js View on Github external
_createFileStream (event, File) {
    return Bacon
      .fromEvent(this._watch, event, (relPath, stat) => {
        if (File.accepts(relPath)) {
          return new File(relPath, stat)
        }
      })
      .filter(R.is(Object))
  }
github reduxjs / redux-devtools / packages / d3tooltip / src / index.js View on Github external
tip.style = function setStyle(d) {
    if (is(Object, d)) {
      styles = { ...styles, ...d };
    }
    return this;
  };
github SeanCannon / prettycats / dist / predicates / strings.js View on Github external
var stringIsOneOf = R.curry(function (selectionArr, str) {
  return R.allPass([R.is(String), R.contains(R.__, selectionArr)])(str);
});
var isStringOfLengthBetween = R.curry(function (min, max, str) {