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


TypeScript q類代碼示例

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


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

示例1: test

        test("should successfully send a message", function(done: MochaDone) {
            const port: string = HostPlatform.getExtensionPipePath();
            let receivedMessage: ExtensionMessage;

            mockServer = net.createServer(function(client: net.Socket): void {
                mockServer.close();
                client.on("data", function(data: Buffer) {
                    const messageData: any = JSON.parse(data.toString("utf8"));
                    client.end();

                    receivedMessage = messageData.message;
                });
            });

            mockServer.on("error", done);
            mockServer.listen(port);

            const sender = new ExtensionMessageSender();

            Q({})
                .then(function() {
                    return sender.sendMessage(ExtensionMessage.START_PACKAGER);
                })
                .then(function() {
                    assert.equal(receivedMessage, ExtensionMessage.START_PACKAGER);
                }).done(() => done(), done);
        });
開發者ID:Mokto,項目名稱:vscode-react-native,代碼行數:27,代碼來源:extensionMessaging.test.ts

示例2: test

        test("should successfully send a message", function(done: MochaDone) {
            let receivedMessage: ExtensionMessage;

            mockServer = net.createServer(function(client: net.Socket): void {
                mockServer.close();
                client.on("data", function(data: Buffer) {
                    const messageData: any = JSON.parse(data.toString("utf8"));
                    client.end();

                    receivedMessage = messageData.message;
                });
            });

            mockServer.on("error", done);
            mockServer.listen(port);

            const sender = RemoteExtension.atProjectRootPath(projectRootPath);

            Q({})
                .then(function() {
                    return sender.startPackager();
                })
                .then(function() {
                    assert.equal(receivedMessage, ExtensionMessage.START_PACKAGER);
                }).done(() => done(), done);
        });
開發者ID:CarlosVV,項目名稱:vscode-react-native,代碼行數:26,代碼來源:extensionMessaging.test.ts

示例3: Q

 .then((model: OntoUmlModel | OntoObjectModel): Q.Promise<OntoObjectModel> => {
     if (frontEnd.returnsOntoObjectModel) {
         return Q(model as OntoObjectModel);
     }
     const objectMapper = new OntoUmlToOntoObjectModelMapper();
     const objectModel = objectMapper.mapToOntoObjectModel(model as OntoUmlModel);
     return Q(objectModel);
 })
開發者ID:CCMi-FIT,項目名稱:ontouml-code-generator,代碼行數:8,代碼來源:app.ts

示例4: basicExecutorFactory

  updateSettings(newSettings: AppSettings): Q.Promise<any> {
    if (this.settingsLocation.readOnly) return Q.reject(new Error('must be writable'));

    this.appSettings = newSettings.attachExecutors((dataCube) => {
      if (dataCube.clusterName === 'native') {
        var fileManager = this.getFileManagerFor(dataCube.source);
        if (fileManager) {
          var dataset = fileManager.dataset;
          if (!dataset) return null;
          return basicExecutorFactory({
            datasets: { main: dataset }
          });
        }

      } else {
        var clusterManager = this.getClusterManagerFor(dataCube.clusterName);
        if (clusterManager) {
          var external = clusterManager.getExternalByName(dataCube.name);
          if (!external) return null;
          return basicExecutorFactory({
            datasets: { main: external }
          });
        }

      }
      return null;
    });

    return Q(null); // ToDo: actually save settings
  }
開發者ID:djfwan,項目名稱:pivot,代碼行數:30,代碼來源:settings-manager.ts

示例5: RangeError

 return TelemetryHelper.generate("launch", (generator) => {
     const resolver = new PlatformResolver();
     const runOptions = this.parseRunOptions();
     const mobilePlatform = resolver.resolveMobilePlatform(runOptions.platform);
     if (!mobilePlatform) {
         throw new RangeError("The target platform could not be read. Did you forget to add it to the launch.json configuration arguments?");
     } else {
         const sourcesStoragePath = path.join(this.projectRootPath, ".vscode", ".react");
         const packager = new Packager(this.projectRootPath, sourcesStoragePath);
         return Q({})
             .then(() => {
                 generator.step("startPackager");
                 return packager.start();
             })
             // We've seen that if we don't prewarm the bundle cache, the app fails on the first attempt to connect to the debugger logic
             // and the user needs to Reload JS manually. We prewarm it to prevent that issue
             .then(() => {
                 generator.step("prewarmBundleCache");
                 return packager.prewarmBundleCache(runOptions.platform);
             })
             .then(() => {
                 generator.step("mobilePlatform.runApp");
                 return mobilePlatform.runApp(runOptions);
             })
             .then(() => {
                 generator.step("Starting App Worker");
                 return new MultipleLifetimesAppWorker(sourcesStoragePath, runOptions.debugAdapterPort).start();
             }) // Start the app worker
             .then(() => {
                 generator.step("mobilePlatform.enableJSDebuggingMode");
                 return mobilePlatform.enableJSDebuggingMode(runOptions);
             }).then(() =>
                 Log.logMessage("Debugging session started succesfuly."));
     }
 });
開發者ID:ajwhite,項目名稱:vscode-react-native,代碼行數:35,代碼來源:launcher.ts

示例6: introspectDataSource

    }).then((ds: string[]) => {
      if (!Array.isArray(ds)) throw new Error('invalid result from data source list');

      var unknownDataSourceNames: string[] = [];
      var nonQueryableDataSources: DataSource[] = [];
      ds.forEach((d: string) => {
        var existingDataSources = myDataSources.filter((dataSource) => {
          return dataSource.engine === 'druid' && dataSource.source === d;
        });

        if (existingDataSources.length === 0) {
          unknownDataSourceNames.push(d);
        } else {
          nonQueryableDataSources = nonQueryableDataSources.concat(existingDataSources.filter((dataSource) => {
            return !dataSource.isQueryable();
          }));
        }
      });

      nonQueryableDataSources = nonQueryableDataSources.concat(unknownDataSourceNames.map((name) => {
        var newDataSource = dataSourceStubFactory(name);
        log(`Adding Druid data source: '${name}'`);
        addOrUpdateDataSource(newDataSource);
        return newDataSource;
      }));

      // Nothing to do
      if (!nonQueryableDataSources.length) return Q(null);

      return Q.allSettled(nonQueryableDataSources.map((dataSource) => {
        return introspectDataSource(dataSource);
      }));
    }).catch((e: Error) => {
開發者ID:fortressll87,項目名稱:implydata-pivot,代碼行數:33,代碼來源:data-source-manager.ts

示例7: Q

 .then((isRunning: boolean) => {
     if (isRunning) {
         /* close the server old instance */
         return Q({})
         .then(()=> simulate.stopSimulate());
     }
 }).then(() => {
開發者ID:fjsnogueira,項目名稱:vscode-cordova,代碼行數:7,代碼來源:simulate.ts


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