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(':'); }
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(':'); }
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; }
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; } }
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; } });
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); });
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; }
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); } });
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 }); } });
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)); });