當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。