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


TypeScript Q.reject函數代碼示例

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


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

示例1: addCodeCoverageNodes

    protected addCodeCoverageNodes(buildJsonContent: any): Q.Promise<any> {
        let _this = this;

        if (!buildJsonContent.project.target) {
            tl.debug("Build tag is not present");
            return Q.reject(tl.loc("InvalidBuildFile"));
        }

        if (!buildJsonContent.project.target || typeof buildJsonContent.project.target === "string") {
            buildJsonContent.project.target = {};
        }

        if (buildJsonContent.project.target instanceof Array) {
            buildJsonContent.project.target.forEach(element => {
                _this.enableForking(element);
            });
        } else {
            _this.enableForking(buildJsonContent.project.target);
        }

        return Q.resolve(buildJsonContent);
    }
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:22,代碼來源:jacoco.ant.ccenabler.ts

示例2: updateSettings

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

    var clusterManagers = this.clusterManagers;
    this.appSettings = newSettings.attachExecutors((dataSource) => {
      if (dataSource.engine === 'native') {
        return null; // ToDo: fix this.
      } else {
        for (var clusterManager of clusterManagers) {
          if (clusterManager.cluster.name === dataSource.engine) {
            var external = clusterManager.getExternalByName(dataSource.name);
            if (!external) return null;
            return basicExecutorFactory({
              datasets: { main: external }
            });
          }
        }
      }
      return null;
    });

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

示例3: download

    /**
     *
     * @param url
     * @param folder
     * @returns {any}
     */
    public download(url, folder, filename = null, onProgress:any = null) {
        if (!this.platform.is('cordova')) {
            return $q.reject('Unable to download in browser');
        }

        const fileTransfer = new Transfer();

        if (!filename) {
            filename = this.getFilenameFromUrl(url);
        }

        if (folder != '') {
            folder = folder + '/';
        }

        let targetPath = cordova.file.externalApplicationStorageDirectory + folder + filename;

        if (onProgress) {
            fileTransfer.onProgress(onProgress);
        }

        return fileTransfer.download(url, targetPath);
    }
開發者ID:HugoHeneault,項目名稱:LaBas,代碼行數:29,代碼來源:file.service.ts

示例4: if

 }, (error: HttpError) => {
   // offline login response
   if (!error.statusCode && loginOptions.offlineCapable) {
     // ajax timeout -> offline login attempt
     diag.debug.assert(() => !serverObj.sessionUserUuid,
       'no physical login, as otherwise logonCallback would be executed');
     return offline.fetchOfflineLogin(credentials, currentOptions).then((loginResponse) => {
       if (!loginResponse) {
         // when there is no persistent data available, aka. this is the initial login attempt,
         // keep saying the server is offline...
         return Q.reject<LoginResponse>(error);
       }
       return loginResponse;
     }, (offlineError) => {
       // most likely the password entered was incorrect,
       // make sure the offlineError indicates the server is unavailable as well
       diag.debug.assert(() => !offlineError.statusCode);
       diag.debug.assert(() => !offlineError.requestUrl);
       offlineError.requestUrl = error.requestUrl;
       diag.debug.assert(() => !offlineError.cause);
       offlineError.cause = error;
       // we rethrow the annotated error of decoding the stored response,
       // because the network error just indicates we are offline and does
       // not mention the credentials being incorrect as this one does...
       return Q.reject<LoginResponse>(offlineError);
     });
   } else if (error.statusCode && wasOfflineLogin) {
     // server side rejection, clear login data so that subsequent offline logins fail as well
     return offline.clearOfflineLogin(credentials, currentOptions).catch((offlineError) => {
       // this is bad but we can not do much about it
       diag.debug.warn('failed erasing offline login data', offlineError);
       return Q.reject<LoginResponse>(error);
     });
   }
   return Q.reject<LoginResponse>(error);
 }).then((response) => {
開發者ID:relution-io,項目名稱:relution-sdk,代碼行數:36,代碼來源:http.ts

示例5: return

 return (option: any) => {
     return ok ? Q.resolve({data}) : Q.reject(new Error(data));
 };
開發者ID:GauSim,項目名稱:angular1-rx-text,代碼行數:3,代碼來源:StoreDispatchers.Sepc.ts

示例6: test

        test("findPlistFile should correctly find the NSUserDefaults plist file for the simulator", function() {
            const projectRoot = path.join("/", "tmp", "myProject");

            const bundleId = "com.contoso.app";

            const findSimulatorHomeCommand = "xcrun simctl getenv booted HOME";
            // The emulator's home folder is /simulator/home
            const findSimulatorHomeResult = path.join("/", "Users", "theUser", "Library", "Developer", "CoreSimulaotr", "Devices", "FA511653-BA51-479F-A218-1DBD1910D5E5/data");

            const prefix = path.join("Containers", "Data", "Application");
            const suffix = path.join("Library", "Preferences");

            // The emulator has 3 apps
            const appIds = ["17F3AED1-5B1D-4F97-B419-D1F079D9DE2D",
                "957660FD-3417-474E-B2AC-8AA0A05AD9A0",
                "18319C8B-0583-4967-8023-15859A0BF0F3"];

            // readdir finds appIds
            const mockReadDir = sinon.stub();
            mockReadDir.withArgs(path.join(findSimulatorHomeResult, prefix)).returns(Q.resolve(appIds));
            mockReadDir.throws();

            // Only the second app has a plist file with thus bundle name
            const existingPlistFile = path.join(findSimulatorHomeResult, prefix, "957660FD-3417-474E-B2AC-8AA0A05AD9A0", suffix, `${bundleId}.plist`);

            // existsSync only finds existingPlistFile to exist
            const mockExistsSync = sinon.stub();
            mockExistsSync.withArgs(existingPlistFile).returns(true);
            mockExistsSync.returns(false);

            const mockFS: any = {
                existsSync: mockExistsSync,
                readDir: mockReadDir
            };

            // getBundleId returns bundleId
            const bundleIdStub = sinon.stub();
            bundleIdStub.withArgs(projectRoot).returns(Q.resolve(bundleId));
            bundleIdStub.returns(Q.reject("Incorrect project root"));

            const mockPlistBuddy: any = {
                getBundleId: bundleIdStub
            };

            // exec-ing the correct command returns the simulator home
            const execStub = sinon.stub();
            execStub.withArgs(findSimulatorHomeCommand).returns({ outcome: Q.resolve(findSimulatorHomeResult) });
            execStub.throws();
            const mockChildProcess: any = {
                exec: execStub
            };

            const simulatorPlist = new SimulatorPlist(projectRoot, {
                nodeFileSystem: mockFS,
                plistBuddy: mockPlistBuddy,
                nodeChildProcess: mockChildProcess
            });

            return simulatorPlist.findPlistFile().then((plistFile) => {
                assert(plistFile === existingPlistFile, "Returned incorrect value");
            });
        });
開發者ID:KeithLee208,項目名稱:vscode-react-native,代碼行數:62,代碼來源:simulatorPlist.test.ts

示例7:

   }, (error2: HttpError) => {
     return Q.reject<void>(error2.statusCode === 422 ? error : error2);
 });
開發者ID:relution-io,項目名稱:relution-sdk,代碼行數:3,代碼來源:http.ts

示例8:

 .catch((reason) => {
     return Q.reject<string>(ErrorHelper.getNestedError(reason, InternalErrorCode.WorkspaceNotFound, `Error while looking at workspace for file: ${file}.`));
 });
開發者ID:CarlosVV,項目名稱:vscode-react-native,代碼行數:3,代碼來源:openFileAtLocation.ts


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