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.

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<string, OpenAPIObject>): Record<string, OpenAPIObject> =>
  objectToArray<OpenAPIObject>()
  .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<PathItem>()(operation)
      .composeOptional(Optional.fromNullableProp<Operation>()("parameters"))
      .composeTraversal(fromTraversable(array)<Reference | Parameter>()),
    vname,
    pathItem,
    oas,
  );

monocle-ts

A porting of scala monocle library to TypeScript

MIT
Latest version published 6 months ago

Package Health Score

72 / 100
Full package analysis

Similar packages