当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript join.bind方法代码示例

本文整理汇总了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);
开发者ID:dickendd,项目名称:myhaiku,代码行数:26,代码来源:constants.ts

示例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;
开发者ID:nrudenko,项目名称:kin-devplatform-jwt-service,代码行数:31,代码来源:utils.ts

示例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();
开发者ID:Kineolyan,项目名称:Jarvis,代码行数:31,代码来源:tools.ts

示例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]);
开发者ID:katallaxie,项目名称:katallaxie.github.com,代码行数:8,代码来源:helpers.ts


注:本文中的path.join.bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。