本文整理汇总了TypeScript中tree.path.contains方法的典型用法代码示例。如果您正苦于以下问题:TypeScript path.contains方法的具体用法?TypeScript path.contains怎么用?TypeScript path.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree.path
的用法示例。
在下文中一共展示了path.contains方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: throttle
var getDests = throttle(800, function() {
if (!vm.node.dests && treePath.contains(vm.path, vm.initialPath))
socket.sendAnaDests({
fen: vm.node.fen,
path: vm.path
});
});
示例2: nodeClasses
export function nodeClasses(ctx: Ctx, path: Tree.Path): NodeClasses {
return {
active: path === ctx.ctrl.path,
context_menu: path === ctx.ctrl.contextMenuPath,
current: path === ctx.currentPath,
nongame: !ctx.currentPath && !!ctx.ctrl.gamePath && treePath.contains(path, ctx.ctrl.gamePath) && path !== ctx.ctrl.gamePath
};
}
示例3: h
return h('lines', nodes.map(n => {
return retroLine(ctx, n, opts) || h('line', renderMoveAndChildrenOf(ctx, n, {
parentPath: opts.parentPath,
isMainline: false,
withIndex: true,
truncate: n.comp && !treePath.contains(ctx.ctrl.path, opts.parentPath + n.id) ? 3 : undefined
}));
}));
示例4: nodeClasses
export function nodeClasses(c: AnalyseCtrl, path: Tree.Path): NodeClasses {
const current = (path === c.initialPath && game.playable(c.data)) || (
c.retro && c.retro.current() && c.retro.current().prev.path === path
);
return {
active: path === c.path,
context_menu: path === c.contextMenuPath,
current,
nongame: !current && !!c.gamePath && treePath.contains(path, c.gamePath) && path !== c.gamePath
};
}
示例5: function
return function() {
if (vm.mode === 'view') return;
if (!pathOps.contains(vm.path, vm.initialPath)) return;
var playedByColor = vm.node.ply % 2 === 1 ? 'white' : 'black';
if (playedByColor !== puzzle.color) return;
var nodes = vm.nodeList.slice(pathOps.size(vm.initialPath) + 1).map(function(node) {
return {
uci: node.uci,
castle: node.san.startsWith('O-O')
};
});
var progress = puzzle.lines;
for (var i in nodes) {
if (progress[nodes[i].uci]) progress = progress[nodes[i].uci];
else if (nodes[i].castle) progress = progress[altCastles[nodes[i].uci]] || 'fail';
else progress = 'fail';
if (typeof progress === 'string') break;
}
if (typeof progress === 'string') {
vm.node.puzzle = progress;
return progress;
}
var nextKey = Object.keys(progress)[0]
if (progress[nextKey] === 'win') {
vm.node.puzzle = 'win';
return 'win';
}
// from here we have a next move
vm.node.puzzle = 'good';
var opponentUci = decomposeUci(nextKey);
var promotion = opponentUci[2] ? sanToRole[opponentUci[2].toUpperCase()] : null;
var move: any = {
orig: opponentUci[0],
dest: opponentUci[1],
fen: vm.node.fen,
path: vm.path
};
if (promotion) move.promotion = promotion;
return move;
};
示例6: first
export function first(ctrl) {
var toInit = ctrl.vm.path !== ctrl.vm.initialPath && treePath.contains(ctrl.vm.path, ctrl.vm.initialPath);
ctrl.userJump(
toInit ? ctrl.vm.initialPath : treePath.root
);
}
示例7: last
export function last(ctrl) {
var toInit = !treePath.contains(ctrl.vm.path, ctrl.vm.initialPath);
ctrl.userJump(
toInit ? ctrl.vm.initialPath : treePath.fromNodeList(ctrl.vm.mainline)
);
}
示例8: function
//.........这里部分代码省略.........
obj.path = ctrl.path;
return obj;
}
return {
data,
form,
members,
chapters,
notif,
commentForm,
glyphForm,
share,
tags,
desc,
vm,
isUpdatedRecently() {
return Date.now() - vm.updatedAt < 300 * 1000;
},
toggleLike() {
send("like", {
liked: !data.liked
});
},
position() {
return data.position;
},
currentChapter,
isChapterOwner,
canJumpTo(path: Tree.Path) {
if (gamebookPlay) return gamebookPlay.canJumpTo(path);
return data.chapter.conceal === undefined ||
isChapterOwner() ||
treePath.contains(ctrl.path, path) || // can always go back
ctrl.tree.lastMainlineNode(path).ply <= data.chapter.conceal!;
},
onJump() {
chapters.localPaths[vm.chapterId] = ctrl.path;
if (practice) practice.onJump();
if (gamebookPlay) gamebookPlay.onJump();
},
withPosition,
setPath(path, node) {
onSetPath(path);
setTimeout(() => commentForm.onSetPath(path, node), 100);
},
deleteNode(path) {
makeChange("deleteNode", addChapterId({
path,
jumpTo: ctrl.path
}));
},
promote(path, toMainline) {
makeChange("promote", addChapterId({
toMainline,
path
}));
},
setChapter(id, force) {
if (id === vm.chapterId && !force) return;
if (!vm.mode.sticky || !makeChange("setChapter", id)) {
vm.mode.sticky = false;
if (!vm.behind) vm.behind = 1;
vm.chapterId = id;
xhrReload();
}
示例9: pathContains
function pathContains(ctx, path) {
return treePath.contains(ctx.ctrl.vm.path, path);
}
示例10: function
return function(path: Tree.Path, node: Tree.Node) {
if (!conceal || (isMainline && conceal.ply >= node.ply)) return null;
if (treePath.contains(ctrl.path, path)) return null;
return conceal.owner ? 'conceal' : 'hide';
};