本文整理汇总了TypeScript中ramda.uniq函数的典型用法代码示例。如果您正苦于以下问题:TypeScript uniq函数的具体用法?TypeScript uniq怎么用?TypeScript uniq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uniq函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: deps
function deps(file: string, exists: string[]): string[] {
let _deps = requires(fs.readFileSync(file, "utf-8"))
.map(dep => path.resolve(path.dirname(file), `${dep}.js`))
.filter(fs.existsSync)
.filter(dep => exists.indexOf(dep) == -1);
return _.uniq(_deps.concat(_.flatten(_deps.map(d => deps(d, exists.concat(_deps))))));
}
示例2: subscribe
/**
* Subscribes to some paths in state. Allows the user to track a subset of
* data within the state that will be sent to them every time it changes.
*
* @param command The command received from the reactotron app.
*/
function subscribe(command: any) {
const trackedNode = trackedNodes[command.mstNodeName || "default"]
const paths: string[] = (command && command.payload && command.payload.paths) || []
if (trackedNode && trackedNode.node && paths) {
subscriptions = uniq(flatten(paths))
const state = getSnapshot(trackedNode.node)
sendSubscriptions(state)
}
}
示例3: deepMerge
function deepMerge(v1, v2) {
if (Array.isArray(v1) && Array.isArray(v2)) {
return R.uniq(R.concat(v1, v2));
}
else if (typeof v1 === 'object' && typeof v2 === 'object') {
return R.mergeWith(deepMerge, v1, v2);
}
else {
return v2;
}
}
示例4:
const getVocabularyRecursive = (node: AbstractNode): string[] => {
if (node instanceof Leaf) {
return node.getNewVocabulary();
}
const internalNode = node as InternalNode;
return R.uniq([
...internalNode.getNewVocabulary(),
...R.flatten<string>(
R.map(getVocabularyRecursive, internalNode.getChildren())
)
]);
};
示例6: generateOrBranch
function generateOrBranch(modules: PrereqTree[]) {
const children = R.uniq(modules);
return { or: children };
}