How to use the fp-ts/lib/Option.fromNullable function in fp-ts

To help you get started, we’ve selected a few fp-ts 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 musicglue / pg-ts / src / utils / camelify.ts View on Github external
const isMappable: Predicate = x =>
  fromNullable(x)
    .filter(isObject)
    .filter(not(isDate))
    .fold(false, constTrue);
github gcanti / docs-ts / src / parser.ts View on Github external
function getSince(annotation: doctrine.Annotation): O.Option {
  return pipe(
    O.fromNullable(annotation.tags.filter(tag => tag.title === 'since')[0]),
    O.mapNullable(tag => tag.description)
  )
}
github mikearnaldi / matechs-effect / packages / http-client-fetch / src / index.ts View on Github external
resp.text().then(b => {
                  r(
                    left({
                      _tag: H.HttpErrorReason.Response,
                      response: {
                        headers: h,
                        status: resp.status,
                        body: fromNullable(
                          d[H.httpDeserializerEnv].errorResponse(b)
                        )
                      }
                    })
                  );
                });
              }
github gcanti / docs-ts / src / parser.ts View on Github external
function getDescription(annotation: doctrine.Annotation): O.Option {
  return pipe(
    O.fromNullable(annotation.description),
    O.filter(s => s !== '')
  )
}
github teamdigitale / io-functions / lib / utils / mailup.ts View on Github external
const emailPayload = {
        Bcc: fromNullable(addresses.bcc)
          .map(toMailupAddresses)
          .toUndefined(),
        Cc: fromNullable(addresses.cc)
          .map(toMailupAddresses)
          .toUndefined(),
        ExtendedHeaders: headers,
        From: fromNullable(addresses.from)
          .chain(toMailupAddress)
          .toUndefined(),
        Html: {
          Body: mail.data.html
        },
        ReplyTo: fromNullable(addresses["reply-to"])
          .chain(toMailupAddress)
          .map(addr => addr.Email)
          .toUndefined(),
        Subject: mail.data.subject,
        Text: mail.data.text,
        To: fromNullable(addresses.to)
          .map(toMailupAddresses)
          .toUndefined()
      };

      const errorOrEmail = EmailPayload.decode(emailPayload);

      if (isLeft(errorOrEmail)) {
        const errors = readableReport(errorOrEmail.value);
        winston.error("MailUpTransport|errors", errors);
        return callback(
github gcanti / docs-ts / lib / parser.js View on Github external
function isInternal(annotation) {
    return Option_1.fromNullable(annotation.tags.filter(function (tag) { return tag.title === 'internal'; })[0]).isSome();
}
function getExamples(annotation) {
github paritytech / substrate-light-ui / packages / accounts-app / src / Accounts / AccountOverviewDetailed.tsx View on Github external
const renderGeneral = (): React.ReactElement => {
    const isStashNominating = fromNullable(stakingInfo)
      .mapNullable(({ nominators }) => nominators)
      .map(nominators => nominators.length > 0)
      .getOrElse(false);

    const isStashValidating = fromNullable(allStashes)
      .map(allStashes => allStashes.includes(createType('AccountId', currentAccount)))
      .getOrElse(false);

    const accountType = fromNullable(stakingInfo).map(stakingInfo => createType('AccountId', currentAccount).eq(stakingInfo.controllerId) ? 'controller' : 'stash');

    const bondingPair = fromNullable(stakingInfo)
      .map(stakingInfo => accountType.fold(
        undefined,
        (accountType) => accountType === 'controller' ? stakingInfo.stashId : stakingInfo.controllerId
      ))
      .getOrElse(undefined);

    return (
github musicglue / pg-ts / src / pool.ts View on Github external
.chain(pool =>
      fromNullable(parsers)
        .map(setupParsers(pool))
        .getOrElse(taskEither.of(pool)),
    )
github teamdigitale / io-functions / lib / created_message_queue_handler.ts View on Github external
function getEmailAddressFromProfile(
  profile: RetrievedProfile
): Option {
  return fromNullable(profile.email).map(email => ({
    addressSource: NotificationAddressSourceEnum.PROFILE_ADDRESS,
    toAddress: email
  }));
}
github paritytech / substrate-light-ui / packages / accounts-app / src / Validators / ValidatorListHeader.tsx View on Github external
const renderEraProgress = (): React.ReactElement => {
    return (
      
        
          
             New Validator Set: 
            {
              fromNullable(sessionInfo)
                .map(sessionInfo =>
                  <progress value="{sessionInfo.eraProgress.toNumber()}" size="small" color="pink">
                )
                .getOrElse()
            }
            A New Validator Set is Elected Every Era.
          </progress>
        
      
    );