本文整理匯總了TypeScript中vs/base/common/types.isNumber函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isNumber函數的具體用法?TypeScript isNumber怎麽用?TypeScript isNumber使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了isNumber函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: toPath
function toPath(p: IPathWithLineAndColumn): string {
const segments = [p.path];
if (types.isNumber(p.line)) {
segments.push(String(p.line));
}
if (types.isNumber(p.column)) {
segments.push(String(p.column));
}
return segments.join(':');
}
示例2: toLineAndColumnPath
function toLineAndColumnPath(parsedPath: IParsedPath): string {
const segments = [parsedPath.path];
if (types.isNumber(parsedPath.line)) {
segments.push(String(parsedPath.line));
}
if (types.isNumber(parsedPath.column)) {
segments.push(String(parsedPath.column));
}
return segments.join(':');
}
示例3: doSetWorked
private doSetWorked(value: number): ProgressBar {
assert.ok(isNumber(this.totalWork), 'Total work not set');
const totalWork = this.totalWork!;
this.workedVal = value;
this.workedVal = Math.min(totalWork, this.workedVal);
if (hasClass(this.element, css_infinite)) {
removeClass(this.element, css_infinite);
}
if (hasClass(this.element, css_done)) {
removeClass(this.element, css_done);
}
if (!hasClass(this.element, css_active)) {
addClass(this.element, css_active);
}
if (!hasClass(this.element, css_discrete)) {
addClass(this.element, css_discrete);
}
this.bit.style.width = 100 * (this.workedVal / (totalWork)) + '%';
return this;
}
示例4: if
validation: (value: string) => {
if (!value && option.isRequired) {
return { type: MessageType.ERROR, content: option.displayName + missingErrorMessage };
} else if (!types.isNumber(Number(value))) {
return { type: MessageType.ERROR, content: invalidInputMessage };
} else {
return null;
}
}
示例5: Number
segments.forEach(segment => {
const segmentAsNumber = Number(segment);
if (!types.isNumber(segmentAsNumber)) {
path = !!path ? [path, segment].join(':') : segment; // a colon can well be part of a path (e.g. C:\...)
} else if (line === null) {
line = segmentAsNumber;
} else if (column === null) {
column = segmentAsNumber;
}
});
示例6: clb
this.statLinkIfNeeded(currentAbsolutePath, lstat, (error, stat) => {
if (error || this.isCanceled || this.isLimitHit) {
return clb(null);
}
// Directory: Follow directories
if (stat.isDirectory()) {
this.directoriesWalked++;
// to really prevent loops with links we need to resolve the real path of them
return this.realPathIfNeeded(currentAbsolutePath, lstat, (error, realpath) => {
if (error || this.isCanceled || this.isLimitHit) {
return clb(null);
}
realpath = realpath || '';
if (this.walkedPaths[realpath]) {
return clb(null); // escape when there are cycles (can happen with symlinks)
}
this.walkedPaths[realpath] = true; // remember as walked
// Continue walking
return readdir(currentAbsolutePath).then(children => {
if (this.isCanceled || this.isLimitHit) {
return clb(null);
}
this.doWalk(folderQuery, currentRelativePath, children, onResult, err => clb(err || null));
}, error => {
clb(null);
});
});
}
// File: Check for match on file pattern and include pattern
else {
this.filesWalked++;
if (currentRelativePath === this.filePattern) {
return clb(null, undefined); // ignore file if its path matches with the file pattern because checkFilePatternRelativeMatch() takes care of those
}
if (this.maxFilesize && types.isNumber(stat.size) && stat.size > this.maxFilesize) {
return clb(null, undefined); // ignore file if max file size is hit
}
this.matchFile(onResult, { base: rootFolder.fsPath, relativePath: currentRelativePath, basename: file, size: stat.size });
}
// Unwind
return clb(null, undefined);
});
示例7: getNumericValue
function getNumericValue(value: string, defaultValue: number, fallback: number = void 0) {
const numericValue = parseInt(value);
if (types.isNumber(numericValue)) {
return numericValue;
}
if (value) {
return defaultValue;
}
return fallback;
}
示例8: rawRequest
req = rawRequest(opts, (res: http.IncomingMessage) => {
const followRedirects: number = isNumber(options.followRedirects) ? options.followRedirects : 3;
if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && followRedirects > 0 && res.headers['location']) {
request(assign({}, options, {
url: res.headers['location'],
followRedirects: followRedirects - 1
}), token).then(c, e);
} else {
let stream: Stream = res;
if (res.headers['content-encoding'] === 'gzip') {
stream = stream.pipe(createGunzip());
}
c({ res, stream } as IRequestContext);
}
});
示例9: rawRequest
req = rawRequest(opts, (res: http.ClientResponse) => {
const followRedirects = isNumber(options.followRedirects) ? options.followRedirects : 3;
if (res.statusCode >= 300 && res.statusCode < 400 && followRedirects > 0 && res.headers['location']) {
request(assign({}, options, {
url: res.headers['location'],
followRedirects: followRedirects - 1
})).done(c, e);
} else {
let stream: Stream = res;
if (res.headers['content-encoding'] === 'gzip') {
stream = stream.pipe(createGunzip());
}
c({ res, stream });
}
});
示例10: test
test('isNumber', () => {
assert(!types.isNumber(undefined));
assert(!types.isNumber(null));
assert(!types.isNumber('foo'));
assert(!types.isNumber([]));
assert(!types.isNumber([1, 2, '3']));
assert(!types.isNumber(true));
assert(!types.isNumber({}));
assert(!types.isNumber(/test/));
assert(!types.isNumber(new RegExp('')));
assert(!types.isNumber(new Date()));
assert(!types.isNumber(assert));
assert(!types.isNumber(function foo() { /**/ }));
assert(!types.isNumber({ foo: 'bar' }));
assert(!types.isNumber(parseInt('A', 10)));
assert(types.isNumber(5));
});