本文整理匯總了TypeScript中path.join.bind方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript join.bind方法的具體用法?TypeScript join.bind怎麽用?TypeScript join.bind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類path.join
的用法示例。
在下文中一共展示了join.bind方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: require
import * as path from 'path';
import * as mkdirp from 'mkdirp';
export const isMac = process.platform === 'darwin';
export const isLinux = process.platform === 'linux';
export const isWindows = process.platform === 'win32';
// use %LOCALAPPDATA%/devcert on Windows otherwise use ~/.config/devcert
export let configDir: string;
if (isWindows && process.env.LOCALAPPDATA) {
configDir = path.join(process.env.LOCALAPPDATA, 'devcert', 'config');
} else {
let uid = process.getuid && process.getuid();
let userHome = (isLinux && uid === 0) ? path.resolve('/usr/local/share') : require('os').homedir();
configDir = path.join(userHome, '.config', 'devcert');
}
export const configPath: (...pathSegments: string[]) => string = path.join.bind(path, configDir);
export const opensslConfTemplate = path.join(__dirname, '..', 'openssl.conf');
export const opensslConfPath = configPath('openssl.conf');
export const rootKeyPath = configPath('devcert-ca-root.key');
export const rootCertPath = configPath('devcert-ca-root.crt');
export const caCertsDir = configPath('certs');
mkdirp.sync(configDir);
mkdirp.sync(caCertsDir);
示例2: path
import * as _path from "path";
const fromProjectRoot = _path.join.bind(path, __dirname, "../../");
export function path(...paths: string[]): string {
return fromProjectRoot(...paths);
}
export type ServerError = Error & { syscall: string; code: string; };
export function random(): number;
export function random(min: number, max: number): number;
export function random(min?: number, max?: number): number {
if (min !== undefined && max !== undefined) {
return Math.random() * (max - min) + min;
}
return Math.random();
}
export function randomInteger(min: number, max: number): number {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
export function randomItem<T = any>(array: T[]): T {
return array[Math.floor(Math.random() * array.length)];
}
const ID_LENGTH = 20;
示例3: Promise
import * as fs from 'fs';
import * as path from 'path';
import * as readline from 'readline';
import * as Maybe from '../../func/Maybe';
const PLEX_FOLDER = '/mnt/Grishka/Media/TV Shows';
const plexPath: (...string) => string = path.join.bind(null, PLEX_FOLDER);
const toPromise = f => (...args) => new Promise((resolve, reject) => {
try {
f(...args, (err, result) => {
if (err) {
reject(err);
} else {
resolve(result);
}
});
} catch (fErr) {
reject(fErr);
}
});
const access = toPromise(fs.access);
//*
const symlink: (...any) => Promise<any> = toPromise(fs.symlink);
const unlink: (string) => Promise<any> = toPromise(fs.unlink);
const rmdir: (string) => Promise<any> = toPromise(fs.rmdir);
/*/
const symlink = (from, to) => new Promise(r => {
console.log('linking', from, '->', to);
r();
示例4:
import * as path from 'path';
import * as process from 'process';
export const root = path.join.bind(path, path.resolve(__dirname, '..'));
export const hasProcessFlag = flag => process.argv.join('').indexOf(flag) > -1;
export const isWebpackDevServer = () =>
process.argv[1] && !!/webpack-dev-server/.exec(process.argv[1]);