本文整理匯總了TypeScript中@jupyterlab/coreutils.PathExt.basename方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript PathExt.basename方法的具體用法?TypeScript PathExt.basename怎麽用?TypeScript PathExt.basename使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@jupyterlab/coreutils.PathExt
的用法示例。
在下文中一共展示了PathExt.basename方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: _evtDrop
/**
* Handle the `'p-drop'` event for the widget.
*/
private _evtDrop(event: IDragEvent): void {
event.preventDefault();
event.stopPropagation();
if (event.proposedAction === 'none') {
event.dropAction = 'none';
return;
}
if (!event.mimeData.hasData(CONTENTS_MIME)) {
return;
}
event.dropAction = event.proposedAction;
let target = event.target as HTMLElement;
while (target && target.parentElement) {
if (target.classList.contains(DROP_TARGET_CLASS)) {
target.classList.remove(DROP_TARGET_CLASS);
break;
}
target = target.parentElement;
}
// Get the path based on the target node.
let index = ArrayExt.findFirstIndex(this._crumbs, node => node === target);
if (index === -1) {
return;
}
const model = this._model;
const path = PathExt.resolve(model.path, BREAD_CRUMB_PATHS[index]);
const manager = model.manager;
// Move all of the items.
let promises: Promise<any>[] = [];
let oldPaths = event.mimeData.getData(CONTENTS_MIME) as string[];
for (let oldPath of oldPaths) {
let localOldPath = manager.services.contents.localPath(oldPath);
let name = PathExt.basename(localOldPath);
let newPath = PathExt.join(path, name);
promises.push(renameFile(manager, oldPath, newPath));
}
Promise.all(promises).catch(err => {
showErrorMessage('Move Error', err);
});
}
示例2: it
it('should return the last portion of a path', () => {
expect(PathExt.basename(TESTPATH)).to.equal('test-path.js');
});
示例3: findByFileName
export function findByFileName(name: string): ISpec {
let basename = PathExt.basename(name);
return CodeMirror.findModeByFileName(basename);
}