• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ts-promise.Promise类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1:

			(abortError: Error) => {
				// Abort pending read, if necessary
				if (this._resumer) {
					this._resumer(Promise.reject(abortError));
					this._resumer = undefined;
				}
			}
开发者ID:BuddyPlatform,项目名称:ts-stream,代码行数:7,代码来源:node.ts


示例2:

			(enderError: Error) => {
				// ender callback failed, but in order to let final stream fail,
				// we need to pass 'something' on, and to wait for that to come
				// back.
				// Finally, make sure to return the enderError.
				return Promise.resolve(defaultEnder(error || enderError)).then(
					() => Promise.reject(enderError),
					() => Promise.reject(enderError)
				);
			}
开发者ID:BuddyPlatform,项目名称:ts-stream,代码行数:10,代码来源:Transform.ts


示例3: filterer

		(v: T): void|Promise<void> => {
			var b = filterer(v);
			if (!b) {
				return;
			} else if (b === true) { // note: not just `if (b)`!
				return writable.write(v);
			} else { // more complex return type, probably a Thenable
				return Promise.resolve(b).then((resolvedB) => {
					if (resolvedB) {
						return writable.write(v);
					}
				});
			}
		},
开发者ID:BuddyPlatform,项目名称:ts-stream,代码行数:14,代码来源:Transform.ts


示例4: return

	return (error?: Error) => {
		// TODO: an error returned from ender is currently passed on to next
		// stream, if stream was not ended with an error yet.
		// It'd maybe be better to not have the next stream be ended when an
		// error occurred in this ender, but there's no way to send another
		// end(), so we have to close it somehow...
		return Promise.resolve(error).then(ender).then(
			() => defaultEnder(error),
			(enderError: Error) => {
				// ender callback failed, but in order to let final stream fail,
				// we need to pass 'something' on, and to wait for that to come
				// back.
				// Finally, make sure to return the enderError.
				return Promise.resolve(defaultEnder(error || enderError)).then(
					() => Promise.reject(enderError),
					() => Promise.reject(enderError)
				);
			}
		);
	};
开发者ID:BuddyPlatform,项目名称:ts-stream,代码行数:20,代码来源:Transform.ts


示例5: Error

 .catch(function(){
     console.log("error");
     return Promise.reject(new Error("Error login"));
 })
开发者ID:tsonevn,项目名称:Angular2-Sample-Project,代码行数:4,代码来源:app.component.ts


示例6:

export const resolveGlobs = (globs: string[]) : Promise<string[]> => {
    return Promise.all(globs.map(pglob)).then(x=> flatten<string>(x));
};
开发者ID:OctopusDeploy,项目名称:OctoTFS,代码行数:3,代码来源:inputs.ts


示例7: Promise

"use strict";

import { Promise } from "ts-promise";


var prom = new Promise((resolve, reject) => {
    setTimeout(() => {
        resolve(42);
        // or e.g.: reject(new Error("boom"));
    }, 100);
});



/// Hello world
Promise.resolve("test").then((v) => {
	console.log(v);
});

var p = Promise.resolve();

/*
Promise.setLongTraces(true);
var p = Promise.resolve();
p.then(() => {
	//return Promise.reject(new Error("my error"));
}).catch((e) => {
	console.error(e.stack);
});
*/
开发者ID:duffman,项目名称:packman,代码行数:30,代码来源:promise.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ts-simple-ast.Node类代码示例发布时间:2022-05-25
下一篇:
TypeScript ts-optchain.oc函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap