How to use the fp-ts/lib/Option.none 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 OliverJAsh / twitter-api-ts / src / helpers.ts View on Github external
import { ErrorResponse, OAuthOptions, Response, StatusesHomeTimelineQueryT } from './types';

export const createErrorResponse = (errorResponse: ErrorResponse): Response =>
    either.left(errorResponse);

export const typecheck = <a>(a: A) =&gt; a;

// Defaults

export const defaultOAuthOptions: Pick&lt;
    OAuthOptions,
    'callback' | 'verifier' | 'token' | 'tokenSecret'
&gt; = {
    callback: option.none,
    verifier: option.none,
    token: option.none,
    tokenSecret: option.none,
};

export const defaultStatusesHomeTimelineQuery: Pick&lt;
    StatusesHomeTimelineQueryT,
    'count' | 'max_id'
&gt; = {
    count: option.none,
    max_id: option.none,
};
</a>
github mikearnaldi / matechs-effect / packages / effect / src / stream / support.ts View on Github external
export function runFromQueue(
  op: Ops,
  callback: (r: E.Either&gt;) =&gt; void
): () =&gt; void {
  switch (op._tag) {
    case "error":
      callback(E.left(op.e));
      // this will never be called
      /* istanbul ignore next */
      // tslint:disable-next-line: no-empty
      return () =&gt; {};
    case "complete":
      callback(E.right(O.none));
      // tslint:disable-next-line: no-empty
      return () =&gt; {};
    case "offer":
      callback(E.right(O.some(op.a)));
      // tslint:disable-next-line: no-empty
      return () =&gt; {};
  }
}
github SamHH / bukubrow-webext / src / components / bookmark-form.tsx View on Github external
const BookmarkForm: FC = (props) =&gt; {
	const firstInputRef = useRef(null);

	const [bookmarkInput, setBookmarkInput] = useState({
		id: O.none,
		title: '',
		desc: '',
		url: '',
		tags: [],
	});
	const setInputBookmarkPartial = (partialBookmark: Partial): void =&gt; {
		setBookmarkInput({ ...bookmarkInput, ...partialBookmark });
	};

	const [tagInput, setTagInput] = useState('');

	useEffect(() =&gt; {
		// Copy bookmark props into state
		if (O.isSome(props.bookmark)) {
			// Ensure not to copy unwanted properties into state
			// eslint-disable-next-line @typescript-eslint/no-unused-vars
github OliverJAsh / twitter-api-ts / src / helpers.ts View on Github external
export const createErrorResponse = (errorResponse: ErrorResponse): Response =&gt;
    either.left(errorResponse);

export const typecheck = <a>(a: A) =&gt; a;

// Defaults

export const defaultOAuthOptions: Pick&lt;
    OAuthOptions,
    'callback' | 'verifier' | 'token' | 'tokenSecret'
&gt; = {
    callback: option.none,
    verifier: option.none,
    token: option.none,
    tokenSecret: option.none,
};

export const defaultStatusesHomeTimelineQuery: Pick&lt;
    StatusesHomeTimelineQueryT,
    'count' | 'max_id'
&gt; = {
    count: option.none,
    max_id: option.none,
};
</a>
github OliverJAsh / twitter-api-ts / src / helpers.ts View on Github external
// tslint:disable-next-line no-duplicate-imports
import { ErrorResponse, OAuthOptions, Response, StatusesHomeTimelineQueryT } from './types';

export const createErrorResponse = (errorResponse: ErrorResponse): Response =&gt;
    either.left(errorResponse);

export const typecheck = <a>(a: A) =&gt; a;

// Defaults

export const defaultOAuthOptions: Pick&lt;
    OAuthOptions,
    'callback' | 'verifier' | 'token' | 'tokenSecret'
&gt; = {
    callback: option.none,
    verifier: option.none,
    token: option.none,
    tokenSecret: option.none,
};

export const defaultStatusesHomeTimelineQuery: Pick&lt;
    StatusesHomeTimelineQueryT,
    'count' | 'max_id'
&gt; = {
    count: option.none,
    max_id: option.none,
};
</a>
github stoplightio / prism / packages / http / src / validator / validators / __tests__ / query.spec.ts View on Github external
it('validates positively against schema', () => {
                assertRight(
                  httpQueryValidator.validate({ param: 'abc' }, [
                    {
                      name: 'param',
                      style: HttpParamStyles.Form,
                      schema: { type: 'string' },
                    },
                  ])
                );

                expect(validateAgainstSchemaModule.validateAgainstSchema).toReturnWith(O.none);
              });
            });
github gcanti / docs-ts / src / parser.ts View on Github external
const lastIndexOf = (big: string, small: string) => {
  const i = big.lastIndexOf(small)
  return i !== -1 ? O.some(i) : O.none
}
github gcanti / fp-ts-codegen / src / ast.ts View on Github external
const getDomainParameterName = (type: M.Type): O.Option =&gt; {
  switch (type.kind) {
    case 'Ref':
      return O.some(getFirstLetterLowerCase(type.name))
    case 'Tuple':
      return O.some('tuple')
    case 'Fun':
      return O.some('f')
    case 'Unit':
      return O.none
  }
}
github gcanti / docs-ts / lib / parser.js View on Github external
var lastIndexOf = function (big, small) {
    var i = big.lastIndexOf(small);
    return i !== -1 ? Option_1.some(i) : Option_1.none;
};
function getFunctionVariableDeclarationSignature(vd) {
github SamHH / bukubrow-webext / src / webextension-env.ts View on Github external
			get: (): Promise =&gt; Promise.resolve({ theme: O.some(activeTheme), badgeDisplay: O.none }),
		},