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

TypeScript util.join函数代码示例

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

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



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

示例1: function

    return new Promise<any>((resolve, reject) => {
        let respondedTimeout = opts.timeoutSecs! * 1000;
        const respondedTick = 5000;
        const callbackName = "jsonp_callback_" + Math.round(Math.random() * 999999);
        (window as any)[callbackName] = function (response: any) {
            respondedTimeout = 0;
            doCallback();
            resolve(responseType === "json" && typeof response === "string" ? deserializeResponse(response) : response);
        };
        const script = document.createElement("script");
        let url = join(opts.baseUrl, action);
        url += url.indexOf("?") >= 0 ? "&" : "?";
        script.src = url + "jsonp=" + callbackName + "&" + serializeRequest(request);
        document.body.appendChild(script);
        const progress = setInterval(function () {
            if (respondedTimeout <= 0) {
                clearInterval(progress);
            } else {
                respondedTimeout -= respondedTick;
                if (respondedTimeout <= 0) {
                    clearInterval(progress);
                    logger.error("Request timeout:  " + script.src);
                    doCallback();
                    reject(Error("Request timeout:  " + script.src));
                } else {
                    logger.debug("Request pending (" + respondedTimeout / 1000 + " sec):  " + script.src);
                }
            }
        }, respondedTick);

        function doCallback() {
            delete (window as any)[callbackName];
            document.body.removeChild(script);
        }
    });
开发者ID:GordonSmith,项目名称:Visualization,代码行数:35,代码来源:connection.ts


示例2: fetch

 .catch(e => {
     //  Try again with the opposite credentials mode  ---
     requestInit.credentials = !_omitMap[opts.baseUrl] ? "omit" : "include";
     return fetch(join(opts.baseUrl, action), requestInit)
         .then(handleResponse)
         .then(responseBody => {
             _omitMap[opts.baseUrl] = !_omitMap[opts.baseUrl];  // The "opposite" credentials mode is known to work  ---
             return responseBody;
         });
 })
开发者ID:GordonSmith,项目名称:Visualization,代码行数:10,代码来源:connection.ts


示例3: it

 it("join", function () {
     expect(join("aaa", "bbb", "ccc")).to.equal("aaa/bbb/ccc");
     expect(join()).to.equal("");
     expect(join("aaa")).to.equal("aaa");
     expect(join("/aaa")).to.equal("/aaa");
     expect(join("/aaa", "bbb", "ccc")).to.equal("/aaa/bbb/ccc");
     expect(join("/aaa/", "/bbb/", "/ccc/")).to.equal("/aaa/bbb/ccc");
     expect(join("aaa/", "/bbb/", "/ccc/")).to.equal("aaa/bbb/ccc");
 });
开发者ID:GordonSmith,项目名称:Visualization,代码行数:9,代码来源:url.spec.ts


示例4: Promise

 return new Promise((resolve, reject) => {
     const options: any = {
         method: verb,
         uri: join(this._opts.baseUrl, action),
         auth: {
             user: this._opts.userID,
             pass: this._opts.password,
             sendImmediately: true
         },
         username: this._opts.userID,
         password: this._opts.password
     };
     switch (verb) {
         case "GET":
             options.uri += "?" + this.serialize(request);
             break;
         case "POST":
             options.headers = {
                 "X-Requested-With": "XMLHttpRequest",
                 "Content-Type": "application/x-www-form-urlencoded"
             };
             options.rejectUnauthorized = this._opts.rejectUnauthorized;
             options.body = this.serialize(request);
             break;
         default:
     }
     const xhr = _d3Request(options.uri)
         .timeout(this._opts.timeoutSecs! * 1000)
         ;
     if (verb === "POST") {
         xhr
             .header("X-Requested-With", "XMLHttpRequest")
             .header("Content-Type", "application/x-www-form-urlencoded")
             .header("Origin", null)
             ;
     }
     xhr
         .send(verb, options.body, (err: any, resp: any) => {
             if (err) {
                 reject(new Error(err));
             } else if (resp && resp.status === 200) {
                 resolve(responseType === ResponseType.JSON ? this.deserialize(resp.responseText) : resp.responseText);
             } else {
                 reject(new Error(resp.responseText));
             }
         });
 });
开发者ID:jchambers-ln,项目名称:Visualization,代码行数:47,代码来源:connection.ts


示例5: join

 return new Promise<any>((resolve, reject) => {
     const options: any = {
         method: verb,
         uri: join(this._opts.baseUrl, action),
         auth: {
             user: this._opts.userID,
             pass: this._opts.password,
             sendImmediately: true
         },
         username: this._opts.userID,
         password: this._opts.password,
         timeout: this._opts.timeoutSecs! * 1000
     };
     //  Older ESP versions were not case insensitive  ---
     const oldESPAuth = `Basic ${btoa(this._opts.userID + ":" + this._opts.password)}`;
     switch (verb) {
         case "GET":
             options.headers = {
                 Authorization: oldESPAuth
             };
             options.uri += "?" + this.serialize(request);
             break;
         case "POST":
             options.headers = {
                 "X-Requested-With": "XMLHttpRequest",
                 "Content-Type": "application/x-www-form-urlencoded",
                 "Authorization": oldESPAuth
             };
             options.rejectUnauthorized = this._opts.rejectUnauthorized;
             options.body = this.serialize(request);
             break;
         default:
     }
     _nodeRequest(options, (err: any, resp: any, body: any) => {
         if (err) {
             reject(new Error(err));
         } else if (resp && resp.statusCode === 200) {
             resolve(responseType === ResponseType.JSON ? this.deserialize(body) : body);
         } else {
             reject(new Error(body));
         }
     });
 });
开发者ID:jchambers-ln,项目名称:Visualization,代码行数:43,代码来源:connection.ts


示例6: doFetch

function doFetch(opts: IOptions, action: string, requestInit: RequestInit, headersInit: HeadersInit, responseType: string) {
    headersInit = {
        ...authHeader(opts),
        ...headersInit
    };

    requestInit = {
        credentials: _omitMap[opts.baseUrl] ? "omit" : "include",
        ...requestInit,
        headers: headersInit
    };

    if (opts.rejectUnauthorized === false && fetch["__agent"] && opts.baseUrl.indexOf("https:") === 0) {
        //  NodeJS / node-fetch only  ---
        requestInit["agent"] = fetch["__agent"];
    }

    function handleResponse(response: Response): Promise<any> {
        if (response.ok) {
            return responseType === "json" ? response.json() : response.text();
        }
        throw new Error(response.statusText);
    }

    return promiseTimeout(opts.timeoutSecs! * 1000, fetch(join(opts.baseUrl, action), requestInit)
        .then(handleResponse)
        .catch(e => {
            //  Try again with the opposite credentials mode  ---
            requestInit.credentials = !_omitMap[opts.baseUrl] ? "omit" : "include";
            return fetch(join(opts.baseUrl, action), requestInit)
                .then(handleResponse)
                .then(responseBody => {
                    _omitMap[opts.baseUrl] = !_omitMap[opts.baseUrl];  // The "opposite" credentials mode is known to work  ---
                    return responseBody;
                });
        })
    );
}
开发者ID:GordonSmith,项目名称:Visualization,代码行数:38,代码来源:connection.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript util.scopedLogger函数代码示例发布时间:2022-05-28
下一篇:
TypeScript util.hashSum函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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