How to use the monocle-ts.fromTraversable function in monocle-ts

To help you get started, we’ve selected a few monocle-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 unmock / unmock-js / packages / unmock-core / src / nock.ts View on Github external
const keepOptionals = (i: IExtendedObjectType): ITameExtendedObjectType =>
  new Iso<
    IExtendedObjectType,
    Array<[string, ExtendedValueType | IMaybeJSONValue]>
  >(
    a => Object.entries(a),
    q => q.reduce((a, b) => ({ ...a, [b[0]]: b[1] }), {}),
  )
    .composeTraversal(fromTraversable(array)())
    .composePrism(
      new Prism<
        [string, ExtendedValueType | IMaybeJSONValue],
        [string, ExtendedValueType]
      >(a => (MaybeJSONValue.is(a[1]) ? some([a[0], a[1].val]) : none), a => a),
    )
    .composeGetter(identityGetter())
    .getAll(i)
    .reduce((a, b) => ({ ...a, [b[0]]: b[1] }), {});
github unmock / unmock-js / packages / unmock-core / src / generator-experimental.ts View on Github external
(req: ISerializedRequest, r: Record): Record =>
  objectToArray()
  .composeTraversal(
    fromTraversable(array)<[string, OpenAPIObject]>()
      .filter(([__, o]) =>
        matchUrls(req.protocol, req.host, o).length > 0))
  .composeLens(valueLens()).modify(oai => f({
    ...req,
    path: truncatePath(req.path, oai, req),
    pathname: truncatePath(req.pathname, oai, req),
  }, oai))(r);
github unmock / unmock-js / packages / unmock-core / src / generator.ts View on Github external
const operationPathParameter = (
  vname: string,
  pathItem: PathItem,
  operation: MethodNames,
  oas: OpenAPIObject,
) =>
  internalGetParameter(
    Optional.fromNullableProp()(operation)
      .composeOptional(Optional.fromNullableProp()("parameters"))
      .composeTraversal(fromTraversable(array)()),
    vname,
    pathItem,
    oas,
  );