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


TypeScript util.isNullOrUndefined函數代碼示例

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


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

示例1: getSearchCountDataSets

  /* searchText 제거
  public getSearchCountDataSets(datasetId: string, searchWord: string, count: number) {
    let popupService = this.popupService;
    return this.get(this.API_URL + `preparationdatasets/${datasetId}/transform?searchWord=` + encodeURIComponent(searchWord) + '&targetLines=' + count)
  */
  public getSearchCountDataSets(datasetId: string, ruleIdx?: number, pageNum?: number, count?: number) {
    let popupService = this.popupService;
    let url = this.API_URL + `preparationdatasets/${datasetId}/transform`;

    const params: string[] = [];

    if (isNullOrUndefined(ruleIdx)) {
      (params.push(`ruleIdx=`));
    } else {
      (params.push(`ruleIdx=${ruleIdx}`));
    }
    (isNullOrUndefined(pageNum)) || (params.push(`offset=${pageNum}`));
    (isNullOrUndefined(count)) || (params.push(`count=${count}`));
    (0 < params.length) && (url = url + '?' + params.join('&'));

    return this.get(url)
      .catch((error) => {
        if (true !== isUndefined(error.code) && error.code === 'PR5102') {
          Loading.hide();
          PreparationAlert.success(this.translateService.instant(error.details));
          popupService.notiPopup({ name: 'update-dataflow', data: null });
          return Promise.reject(null);
        }
        throw error;
      });
  }
開發者ID:bchin22,項目名稱:metatron-discovery,代碼行數:31,代碼來源:dataflow.service.ts

示例2: createStory

 .then((res: any) => {
   return createStory(state.configuration.token, {
     name: res.title,
     description: res.description,
     owner_ids: isNullOrUndefined(res.owner) ? null : [res.owner],
     project_id: parseInt(res.project, 10),
     epic_id: res.epic,
     labels: isNullOrUndefined(res.labels) ? null : [res.labels],
     story_type: res.storyType,
   } as IStory)
     .then((story: IStory) => {
       const id = story.id;
       const storySlug = slug(story.name).toLowerCase();
       const gitCmd = `git checkout -b ${story.story_type}/ch${id}/${storySlug}`;
       console.info(Chalk.green(`Successfully created a story with id ${id}`));
       console.info("You can view your story at " + link(`https://app.clubhouse.io/story/${id}`));
       console.info("To start working on this story (copied to clipboard): " + Chalk.bold(gitCmd));
       writeSync(gitCmd);
       return story;
     })
     .catch((err: any) => {
       console.error(Chalk.red("There was an error processing your request"));
       console.error(err.body);
     });
 });
開發者ID:tyrchen,項目名稱:clubhouse-cli,代碼行數:25,代碼來源:index.ts

示例3:

 Edges.forEach(function(Edge: edge) {
     if(!(Util.isNullOrUndefined(Edge.to) || Util.isNullOrUndefined(Edge.from) || Util.isNullOrUndefined(Edge.rule)))
     {
         Ninja.edge(Edge.to).from(Edge.from).using(Edge.rule);
     }
     else
     {
         console.log('Invalid edge ', Edge, ' requires "to", "from" and "rule"')
     }
 });
開發者ID:HatiEth,項目名稱:ethsset,代碼行數:10,代碼來源:ethsset.ts

示例4: isHttpUrl

  /**
   * Validator that checks if the control value is a http url.
   *
   * @param control
   * @returns {{isUri: boolean}}
   */
  static isHttpUrl(control: AbstractControl): ValidationErrors | null {
    const value = control.value;
    let match = isNullOrUndefined(value) ? null : parseUri(value);

    return (isNullOrUndefined(match)
      || match[1].indexOf('http') !== 0 // check for protocol http(s)
      || match[2] !== '//'              // check for both // after protocol
      || match[4].trim().length === 0    // check that host is given
    ) ?
      {'isHttpUrl': true} : null;
  }
開發者ID:ZGIS,項目名稱:smart-portal-webgui,代碼行數:17,代碼來源:validators.sac.ts

示例5: appendAuthenticationToken

 private appendAuthenticationToken(options?: RequestOptionsArgs) {
     if (isNullOrUndefined(options)) {
         options = new RequestOptions();
     }
     if (isNullOrUndefined(options.headers)) {
         options.headers = new Headers();
     }
     options.headers.append('Accept', 'application/json');
     if (localStorage.getItem('oauth')) {
         options.withCredentials = true;
         options.headers.append('Authorization', 'Bearer ' + this.getToken());
     }
     return options;
 }
開發者ID:k20human,項目名稱:jarvis,代碼行數:14,代碼來源:secure-http.service.ts

示例6: setGoEnvironmentVariables

function setGoEnvironmentVariables(goRoot: string) {
    tl.setVariable('GOROOT', goRoot);

    let goPath: string = tl.getInput("goPath", false);
    let goBin: string = tl.getInput("goBin", false);

    // set GOPATH and GOBIN as user value
    if (!util.isNullOrUndefined(goPath)) {
        tl.setVariable("GOPATH", goPath);
    }
    if (!util.isNullOrUndefined(goBin)) {
        tl.setVariable("GOBIN", goBin);
    }
}
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:14,代碼來源:gotool.ts

示例7: getLicense

    /**
     * getLicense returns License instance with licenser.license setting.
     * @param typ License type specified in settings.json.
     */
    private getLicense(typ: string): License {
        let licenserSetting = vscode.workspace.getConfiguration("licenser");
        let projectName = licenserSetting.get<string>("projectName", undefined);
        console.log("Project Name from settings: " + projectName);
        if (projectName !== undefined && projectName === "") {
            let root = vscode.workspace.rootPath;
            projectName = path.basename(root);
        }
        console.log("Project Name used: " + projectName);
        const licenseKey = typ.toUpperCase();

        if (licenseKey === "CUSTOM") {
            let customTermsAndConditions = licenserSetting.get<string>("customTermsAndConditions");
            let customHeader = licenserSetting.get<string>("customHeader");
            let fileName = vscode.window.activeTextEditor.document.fileName;
            return new Custom(this.author, projectName, customTermsAndConditions, customHeader, fileName);
        }

        let info = availableLicenses.get(licenseKey);
        if (isNullOrUndefined(info)) {
            info = availableLicenses.get(defaultLicenseType);
        }

        return info.creatorFn(this.author, projectName);
    }
開發者ID:ymotongpoo,項目名稱:vsc-licenser,代碼行數:29,代碼來源:extension.ts

示例8:

 static getValidValue<T>(field: T, value: T): T {
   if (isNullOrUndefined(field)) {
     return value;
   } else {
     return field;
   }
 }
開發者ID:tellxp,項目名稱:avengers,代碼行數:7,代碼來源:widget.ts

示例9: constructor

 constructor(graph: Remath, initialState: ISymbolState) {
    super(graph, initialState);
    this._symbol = null;
    if (!initialState || isNullOrUndefined(initialState.symbol)) throw Error('must provide a symbol when creating a cell');
    this.updateSymbol(initialState.symbol);
    this._tempInvalidSymbol = null;
 }
開發者ID:trevorhanus,項目名稱:reMath,代碼行數:7,代碼來源:Symbol.ts

示例10: FormMetadata

 return metadataArray.map(item => {
   if (isNullOrUndefined(entity)) {
     return new FormMetadata(item);
   } else {
     return new FormMetadata(item, entity);
   }
 });
開發者ID:michalzeman,項目名稱:angular2-training,代碼行數:7,代碼來源:form-metadata.ts

示例11: constructor

 constructor(public metadata: DomainMetadata,
             value?: any | ValueObject) {
   // if (value && value[metadata.key]) {
   //   this.defValue = value[metadata.key];
   // }
   if (!isNullOrUndefined(value)) {
     if (value instanceof ValueObject) {
       if (!isNullOrUndefined(value.value)) {
         this.defValue = value.value[metadata.key];
       }
       this.list = value.list;
     } else {
       this.defValue = value[metadata.key];
     }
   }
 }
開發者ID:michalzeman,項目名稱:angular2-training,代碼行數:16,代碼來源:form-metadata.ts

示例12: getDatasetWrangledData

  } // function - transformAction


  // Wrangled 데이터셋 조회 (조인과 유니온에서 사용)
  public getDatasetWrangledData(datasetId: string, count?: number, pageNum?: number, ruleIdx?: number): Promise<any> {

    // TODO : temp value
    count = 1000;
    pageNum = 0;

    let url = this.API_URL + `preparationdatasets/${datasetId}/transform`;

    const params: string[] = [];
    (params.push(`ruleIdx=`));
    (isNullOrUndefined(pageNum)) || (params.push(`offset=${pageNum}`));
    (isNullOrUndefined(count)) || (params.push(`count=${count}`));
    (0 < params.length) && (url = url + '?' + params.join('&'));

    return this.get(url);
  }
開發者ID:bchin22,項目名稱:metatron-discovery,代碼行數:20,代碼來源:dataflow.service.ts

示例13: buildAndInsertMediumByFilePathAsync

  private async buildAndInsertMediumByFilePathAsync(
    mediumFilePath: string,
    index: number
  ): Promise<IMediumModel> {
    const normalizedMediumFilePath = this.fileExplorerService.normalizePathForCurrentOs(mediumFilePath);

    let model = await MediumModel.buildFromFilePathAsync(
      this.mediaService,
      this.mediaRepository,
      () => this.index,
      normalizedMediumFilePath
    );
    const medium = await this.mediaRepository.addMediumAsync(model.toEntity());
    model.setFromEntity(medium);

    if (isNullOrUndefined(index)) { // We'll append medium
      const media = await this.media.valueAsync;
      media.push(model);
    } else {
      const media = await this.media.valueAsync;
      media.splice(index, 0, model);
    }

    return model;
  }
開發者ID:sebthieti,項目名稱:jogplayer-online,代碼行數:25,代碼來源:playlist.model.ts

示例14: init

 init() {
   this.activePage = null;
   this.docked = false;
   this.state = 'collapsed';
   if (isNullOrUndefined(this.height)) {
     this.height = 60;
   }
 }
開發者ID:tellxp,項目名稱:avengers,代碼行數:8,代碼來源:tabstrip-panel.component.ts

示例15: getAutoCompleteChoices

function getAutoCompleteChoices(input: string, data: ChoiceOption[]) {
  if (isNullOrUndefined(input)) {
    return Promise.resolve(data);
  } else {
    const filtered = data
      .filter((item: ChoiceOption) => item.name.toLowerCase().includes(input.toLowerCase()));
    return Promise.resolve(filtered);
  }
}
開發者ID:tyrchen,項目名稱:clubhouse-cli,代碼行數:9,代碼來源:index.ts


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