本文整理匯總了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 };
}