本文整理汇总了TypeScript中bluebird.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getTextlintDependencyNames
export const createConfigFile = (options: CreateConfigFileOption) => {
const dir = options.dir;
return getTextlintDependencyNames(dir).then(pkgNames => {
const rcFile = `.${Config.CONFIG_FILE_NAME}rc`;
const filePath = path.resolve(dir, rcFile);
if (isFile(filePath)) {
Logger.error(`${rcFile} is already existed.`);
return Promise.resolve(1);
}
const filters = pkgNames
.filter(pkgName => {
return pkgName.indexOf(TextlintPackageNamePrefix.filterRule) !== -1;
})
.map(filterName => {
return filterName.replace(TextlintPackageNamePrefix.filterRule, "");
});
const rules = pkgNames
.filter(pkgName => {
return pkgName.indexOf(TextlintPackageNamePrefix.rule) !== -1;
})
.map(filterName => {
return filterName.replace(TextlintPackageNamePrefix.rule, "");
});
const defaultTextlintRc = {
filters: arrayToObject(filters, true),
rules: arrayToObject(rules, true)
};
const output = JSON.stringify(defaultTextlintRc, null, 2);
fs.writeFileSync(filePath, output);
if (options.verbose) {
Logger.log(`${rcFile} is created.`);
}
return Promise.resolve(0);
});
};
示例2: getTextlintDependencyNames
array.forEach(item => {
object[item] = defaultValue;
});
return object;
};
/**
* Initializer class for config of textlint.
*/
export const configInit = {
/**
* Create .textlintrc file
* @params {string} dir The directory of .textlintrc file
* @returns {Promise.<number>} The exit code for the operation.
*/
initializeConfig(dir: string) {
return getTextlintDependencyNames(dir).then(pkgNames => {
const rcFile = `.${Config.CONFIG_FILE_NAME}rc`;
const filePath = path.resolve(dir, rcFile);
if (isFile(filePath)) {
Logger.error(`${rcFile} is already existed.`);
return Promise.resolve(1);
}
const filters = pkgNames
.filter(pkgName => {
return pkgName.indexOf(Config.FILTER_RULE_NAME_PREFIX) !== -1;
})
.map(filterName => {
return filterName.replace(Config.FILTER_RULE_NAME_PREFIX, "");
});
const rules = pkgNames
.filter(pkgName => {
示例3: co
return co(function *initiateRecovery() {
const keys = [];
const userKey = params.userKey; // Box A
let backupKey = params.backupKey; // Box B
const bitgoXpub = params.bitgoKey; // Box C
const destinationAddress = params.recoveryDestination;
const passphrase = params.walletPassphrase;
const isKrsRecovery = backupKey.startsWith('xpub') && !userKey.startsWith('xpub');
const isUnsignedSweep = backupKey.startsWith('xpub') && userKey.startsWith('xpub');
if (isKrsRecovery && _.isUndefined(config.krsProviders[params.krsProvider])) {
throw new Error('unknown key recovery service provider');
}
const validatePassphraseKey = function(userKey, passphrase): Promise<HDNode> {
try {
if (!userKey.startsWith('xprv') && !isUnsignedSweep) {
userKey = sjcl.decrypt(passphrase, userKey);
}
const userHDNode = HDNode.fromBase58(userKey);
return Promise.resolve(userHDNode);
} catch (e) {
throw new Error('Failed to decrypt user key with passcode - try again!');
}
};
const key = yield validatePassphraseKey(userKey, passphrase);
keys.push(key);
// Validate the backup key
try {
if (!backupKey.startsWith('xprv') && !isKrsRecovery && !isUnsignedSweep) {
backupKey = sjcl.decrypt(passphrase, backupKey);
}
const backupHDNode = HDNode.fromBase58(backupKey);
keys.push(backupHDNode);
} catch (e) {
throw new Error('Failed to decrypt backup key with passcode - try again!');
}
try {
const bitgoHDNode = HDNode.fromBase58(bitgoXpub);
keys.push(bitgoHDNode);
} catch (e) {
if (this.getFamily() !== 'xrp') {
// in XRP recoveries, the BitGo xpub is optional
throw new Error('Failed to parse bitgo xpub!');
}
}
// Validate the destination address
if (!this.isValidAddress(destinationAddress)) {
throw new Error('Invalid destination address!');
}
return keys;
}).call(this);
示例4: a
async function a(): Bluebird<void> {
try {
const b = async function b(): Bluebird<void> {
try {
await Bluebird.resolve(); // -- remove this and it compiles
} catch (error) { }
};
await b(); // -- or remove this and it compiles
} catch (error) { }
}
示例5: formatSourceFile
function formatSourceFile(path, contents, callback) {
return withTempFile(path, contents).then((tempFilePath) => {
const req = {
typehint: "FormatOneSourceReq",
file: {
file: path,
contentsIn: tempFilePath
}
}
return client.post(req);
});
}
示例6: typecheckBuffer
function typecheckBuffer(path: string, text: string) {
withTempFile(path, text).then((tempFilePath) => {
const msg = {
typehint: "TypecheckFileReq",
fileInfo: {
file: path,
contentsIn: tempFilePath
}
}
return client.post(msg);
});
}
示例7: getCompletions
function getCompletions(filePath: string, bufferText, offset, noOfAutocompleteSuggestions) {
return withTempFile(filePath, bufferText).then((tempFile) => {
const msg = {
typehint: "CompletionsReq",
fileInfo: {
file: filePath,
contentsIn: tempFile
},
point: offset,
maxResults: noOfAutocompleteSuggestions,
caseSens: false,
reload: true
}
return client.post(msg);
});
}
示例8: putStatusToStream
.catch((error) => {
console.log(error);
putStatusToStream(makeFailurePutRequest(emailDataList, error))
})