本文整理汇总了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;
});
}
示例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);
});
});
示例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"')
}
});
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例8:
static getValidValue<T>(field: T, value: T): T {
if (isNullOrUndefined(field)) {
return value;
} else {
return field;
}
}
示例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;
}
示例10: FormMetadata
return metadataArray.map(item => {
if (isNullOrUndefined(entity)) {
return new FormMetadata(item);
} else {
return new FormMetadata(item, entity);
}
});
示例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];
}
}
}
示例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);
}
示例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;
}
示例14: init
init() {
this.activePage = null;
this.docked = false;
this.state = 'collapsed';
if (isNullOrUndefined(this.height)) {
this.height = 60;
}
}
示例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);
}
}