当前位置: 首页>>代码示例>>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;未经允许,请勿转载。