當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript marshalling.parse函數代碼示例

本文整理匯總了TypeScript中vs/base/common/marshalling.parse函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript parse函數的具體用法?TypeScript parse怎麽用?TypeScript parse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了parse函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

	const _uriMassage = function (part: string): string {
		let data: any;
		try {
			data = parse(decodeURIComponent(part));
		} catch (e) {
			// ignore
		}
		if (!data) {
			return part;
		}
		data = cloneAndChange(data, value => {
			if (markdown.uris && markdown.uris[value]) {
				return URI.revive(markdown.uris[value]);
			} else {
				return undefined;
			}
		});
		return encodeURIComponent(JSON.stringify(data));
	};
開發者ID:donaldpipowitch,項目名稱:vscode,代碼行數:19,代碼來源:htmlContentRenderer.ts

示例2: test

	test('Bug 16793:# in folder name => mirror models get out of sync', () => {
		var uri1 = URI.file('C:\\C#\\file.txt');
		assert.equal(parse(stringify(uri1)).toString(), uri1.toString());
	});
開發者ID:CPoirot3,項目名稱:vscode,代碼行數:4,代碼來源:uri.test.ts

示例3: _receiveOneMessage

	private _receiveOneMessage(rawmsg: string): void {
		if (this._isDisposed) {
			console.warn('Received message after being shutdown: ', rawmsg);
			return;
		}
		let msg = marshalling.parse(rawmsg);

		if (msg.seq) {
			if (!this._pendingRPCReplies.hasOwnProperty(msg.seq)) {
				console.warn('Got reply to unknown seq');
				return;
			}
			let reply = this._pendingRPCReplies[msg.seq];
			delete this._pendingRPCReplies[msg.seq];

			if (msg.err) {
				let err = msg.err;
				if (msg.err.$isError) {
					err = new Error();
					err.name = msg.err.name;
					err.message = msg.err.message;
					err.stack = msg.err.stack;
				}
				reply.resolveErr(err);
				return;
			}

			reply.resolveOk(msg.res);
			return;
		}

		if (msg.cancel) {
			if (this._invokedHandlers[msg.cancel]) {
				this._invokedHandlers[msg.cancel].cancel();
			}
			return;
		}

		if (msg.err) {
			console.error(msg.err);
			return;
		}

		let rpcId = msg.rpcId;

		if (!this._bigHandler) {
			throw new Error('got message before big handler attached!');
		}

		let req = msg.req;

		this._invokedHandlers[req] = this._invokeHandler(rpcId, msg.method, msg.args);

		this._invokedHandlers[req].then((r) => {
			delete this._invokedHandlers[req];
			this._multiplexor.send(MessageFactory.replyOK(req, r));
		}, (err) => {
			delete this._invokedHandlers[req];
			this._multiplexor.send(MessageFactory.replyErr(req, err));
		});
	}
開發者ID:SeanKilleen,項目名稱:vscode,代碼行數:61,代碼來源:rpcProtocol.ts


注:本文中的vs/base/common/marshalling.parse函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。