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


TypeScript bluebird.try函数代码示例

本文整理汇总了TypeScript中bluebird.try函数的典型用法代码示例。如果您正苦于以下问题:TypeScript try函数的具体用法?TypeScript try怎么用?TypeScript try使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了try函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

	sendNewChat: function (receiver, message, images) {
		return Bluebird.try(function () {
			if (receiver.length === 1) {
				return messageService.sendMessageToUserChatIfExists(receiver[0], message, { images, files: [], voicemails: [] });
			}

			return false;
		}).then(function (chat) {
			if (chat) {
				return chat.getID();
			}

			return Chunk.createData(receiver, message, images).then(function (chunkData) {
				return socket.emit("chat.create", {
					initialChunk: chunkData.chunk,
					firstMessage: chunkData.message,
					receiverKeys: chunkData.receiverKeys,
					keys: chunkData.keys
				});
			}).then(function (response) {
				return ChatLoader.load(response.chat);
			}).then(function (chat) {
				return chat.getID();
			});
		});
	},
开发者ID:whispeer,项目名称:whispeerSite,代码行数:26,代码来源:messageService.ts

示例2: getCacheDirectory

	moveFileToBlob: (currentDirectory, currentFilename, blobID) => {
		return Bluebird.try(async () => {
			if (clearing) throw new Error('Cannot get blob, currently clearing cache.')
			const path = await getCacheDirectory()
			const filename = idToFileName(blobID)
			return FILE.moveFile(currentDirectory, currentFilename, path, filename)
		})
	},
开发者ID:whispeer,项目名称:app,代码行数:8,代码来源:blobCache.ts

示例3: it

		it('instanceof', () => {
			expect(
				Promise.try(() => {
					throw new MyError();
				})
					.return(false)
					.catch(MyError, () => true)
					.catch(() => false),
			).to.eventually.equal(true);
		});
开发者ID:resin-io,项目名称:typed-error,代码行数:10,代码来源:typescript.ts

示例4: function

	getMultipleFormatted: function (identifiers, cb) {
		return Bluebird.try(function () {
			return userService.getMultiple(identifiers)
		}).map(function (user: any) {
			return user.loadBasicData().thenReturn(user)
		}).then(function (users) {
			return users.map(function (user) {
				return user.data
			})
		}).nodeify(cb)
	},
开发者ID:whispeer,项目名称:whispeerSite,代码行数:11,代码来源:userService.ts

示例5: noPendingStorageOperations

	clear: () => {
		return Bluebird.try(async () => {
			clearing = true
			await noPendingStorageOperations()
			await FILE.removeRecursively(FILE.cacheDirectory, BLOB_CACHE_DIR)
				.catch(error => {
					// There really is little we can do here, but logouts, e.g., should not
					// fail because we failed to clear.
					console.warn('Cannot remove cache, resolving promise anyway.')
					return true
				})
		}).finally(() => clearing = false)
	},
开发者ID:whispeer,项目名称:app,代码行数:13,代码来源:blobCache.ts

示例6: Error

	getBlobUrl: (blobID) => {
		return Bluebird.try(async () => {
			if (clearing) throw new Error('Cannot get blob URL, currently clearing cache.')
			const path = await getCacheDirectory()
			const filename = idToFileName(blobID)
			const exists = await existsFile(path, filename)

			if (!exists) {
				throw new Error(`cannot get blob url, blob does not exist: ${filename}`)
			}

			return `${path}${filename}`
		})
	},
开发者ID:whispeer,项目名称:app,代码行数:14,代码来源:blobCache.ts


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