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


TypeScript json-hammerhead.stringify函数代码示例

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


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

示例1: setFormInfo

export function setFormInfo (input, info) {
    if (input.form) {
        const hiddenInput = getInput(input.form);

        nativeMethods.inputValueSetter.call(hiddenInput, JSON.stringify(info));
    }
}
开发者ID:DevExpress,项目名称:testcafe-hammerhead,代码行数:7,代码来源:hidden-info.ts

示例2: function

        const sendMsg = (forced?: boolean) => {
            this.activeServiceMessagesCounter++;

            const isAsyncRequest = !forced;
            const transport      = this;
            let request          = XhrSandbox.createNativeXHR();

            const msgCallback = function () {
                // NOTE: The 500 status code is returned by server when an error occurred into service message handler
                if (nativeMethods.xhrStatusGetter.call(this) === 500 && this.responseText) {
                    msg.disableResending = true;
                    errorHandler.call(this); // eslint-disable-line no-use-before-define
                    return;
                }

                transport.activeServiceMessagesCounter--;

                const response = this.responseText && parseJSON(this.responseText);

                request = null;
                callback(null, response);
            };

            const errorHandler = function () {
                if (msg.disableResending) {
                    transport.activeServiceMessagesCounter--;

                    let errorMsg = `XHR request failed with ${request.status} status code.`;

                    if (this.responseText)
                        errorMsg += `\nError message: ${this.responseText}`;

                    callback(new Error(errorMsg));

                    return;
                }

                if (isWebKit || isFirefox) {
                    Transport._storeMessage(msg);
                    msgCallback.call(this);
                }
                else
                    sendMsg(true);
            };

            XhrSandbox.openNativeXhr(request, settings.get().serviceMsgUrl, isAsyncRequest);

            if (forced) {
                request.addEventListener('readystatechange', function () {
                    if (this.readyState !== 4)
                        return;

                    msgCallback.call(this);
                });
            }
            else {
                request.addEventListener('load', msgCallback);
                request.addEventListener('abort', errorHandler);
                request.addEventListener('error', errorHandler);
                request.addEventListener('timeout', errorHandler);
            }

            request.send(stringifyJSON(msg));
        };
开发者ID:DevExpress,项目名称:testcafe-hammerhead,代码行数:64,代码来源:transport.ts

示例3: _removeMessageFromStore

    static _removeMessageFromStore (cmd): void {
        const messages = Transport._getStoredMessages();

        for (let i = 0; i < messages.length; i++) {
            if (messages[i].cmd === cmd) {
                messages.splice(i, 1);

                break;
            }
        }

        nativeMethods.winLocalStorageGetter.call(window).setItem(settings.get().sessionId, stringifyJSON(messages));
    }
开发者ID:DevExpress,项目名称:testcafe-hammerhead,代码行数:13,代码来源:transport.ts

示例4: _storeMessage

    static _storeMessage (msg): void {
        const storedMessages = Transport._getStoredMessages();

        storedMessages.push(msg);

        nativeMethods.winLocalStorageGetter.call(window).setItem(settings.get().sessionId, stringifyJSON(storedMessages));
    }
开发者ID:DevExpress,项目名称:testcafe-hammerhead,代码行数:7,代码来源:transport.ts

示例5: backup

 backup () {
     return {
         localStorage:   JSON.stringify(this.localStorageWrapper.getCurrentState()),
         sessionStorage: JSON.stringify(this.sessionStorageWrapper.getCurrentState())
     };
 }
开发者ID:DevExpress,项目名称:testcafe-hammerhead,代码行数:6,代码来源:index.ts


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