问题标签 [monocle-ts]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
16 浏览

typescript - Customize Monocle policy regarding missing interposed nodes?

Is there a way in monocle (monocle-ts especially) to change the policy of how to handle missing interposed nodes in a structured data, such as in examples A, B and C below, to create them instead of no-oping? I have a use case where that different behavior is desirable. Can I work within the library to achieve it?

Further, can we define a policy to always replace empties during updates with undefined (recursively) so that the reverse operation is consistent?

0 投票
2 回答
65 浏览

ramda.js - Ramda 选择 fp-ts 选项/也许

使用fp-ts。我有一个数组选项

和一个记录选项

我想选择 Ks 与数组相交的记录的 Vs 并将结果粘贴到选项中。

在拉姆达:R.pick(arrayOfKeys, record)

我如何使用 fp-ts 或 fp-ts 生态系统中的其他软件包解决这个问题?

0 投票
0 回答
14 浏览

typescript - 动态 Optional.fromPath

我可以以动态方式访问带有 monocle-ts 的嵌套属性吗?

我可以直接从库中找到的最接近的是 Optional.fromPath,并结合了动态路径。根据fromPath文档中的示例,我们可以为该特定父对象创建一个小型实用程序函数。但是,您需要输入路径。

有一种方法可以从对象类型递归地创建路径类型。但是,这也会导致错误。

创建路径类型的代码:

摘要: Optional.fromPath 不能开箱即用地动态选择路径。有没有办法使用 Optional.fromPath 或来自 monocle-ts 的其他方法来创建类似于上述“responsePath”的函数?