How to use the sanctuary.Left function in sanctuary

To help you get started, we’ve selected a few sanctuary 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 ramda / ramda / test / commute.js View on Github external
it('traverses left to right', function() {
    eq(R.commute(S.Either.of, [S.Right(1), S.Right(2)]), S.Right([1, 2]));
    eq(R.commute(S.Either.of, [S.Right(1), S.Left('XXX')]), S.Left('XXX'));
    eq(R.commute(S.Either.of, [S.Left('XXX'), S.Right(1)]), S.Left('XXX'));
    eq(R.commute(S.Either.of, [S.Left('XXX'), S.Left('YYY')]), S.Left('XXX'));
  });
github Risto-Stevcev / lazy-either / test / either.js View on Github external
LazyEither.Left('bad').value(res => {
      expect(res).to.deep.equal(S.Left('bad'))
      done()
    })
  })
github Risto-Stevcev / lazy-either / test / either.js View on Github external
LazyEither.Right(1500)[FL.chain](this.delayed).value(res => {
      let endTime = Date.now()
      expect(res).to.deep.equal(S.Left('Delay too long'))
      expect(endTime - startTime).to.be.closeTo(0, 100)
      done()
    })
  })
github Risto-Stevcev / lazy-either / examples / readme1.js View on Github external
let delayed = (ms, val) => LazyEither(resolve => {
  ms > 1000 ? resolve(S.Left(Error('Delay too long')))
            : setTimeout(() => resolve(S.Right(val)), ms)
})
github Risto-Stevcev / pure-random / src / pure-random.js View on Github external
const validate = (seed, min, max, randFn) => {
  if (!R.all(R.both(Number.isInteger, inRange), seed))
    return S.Left(TypeError(`Seed must be an array of four integers between [${UINT32_MIN}, ${UINT32_MAX}]`))
  else if (typeof min !== 'number')
    return S.Left(TypeError('Min must be a number')) 
  else if (typeof max !== 'number')
    return S.Left(TypeError('Max must be a number')) 
  else if (min >= max)
    return S.Left(Error('Min must be less than max'))
  else
    return S.Right(randFn(seed, min, max))
}
github node-gh / gh / src / fp.ts View on Github external
return function convertMaybe(val) {
        const result = monadReturningFunction(val)

        return S.isJust(result) ? S.Right(result.value) : S.Left(null)
    }
}
github Risto-Stevcev / lazy-either / examples / vs-future1.js View on Github external
                (err, data) => resolve(err != null ? S.Left(err) : S.Right(data)))
  })