UNPKG

3.62 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2018 Palantir Technologies, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17/// <reference types="node" />
18import * as ts from "typescript";
19/**
20 * Enforces the invariant that the input is an array.
21 */
22export declare function arrayify<T>(arg?: T | T[]): T[];
23/**
24 * @deprecated (no longer used)
25 * Enforces the invariant that the input is an object.
26 */
27export declare function objectify(arg: any): any;
28export declare function hasOwnProperty(arg: {}, key: string): boolean;
29/**
30 * Replace hyphens in a rule name by upper-casing the letter after them.
31 * E.g. "foo-bar" -> "fooBar"
32 */
33export declare function camelize(stringWithHyphens: string): string;
34export declare function isUpperCase(str: string): boolean;
35export declare function isLowerCase(str: string): boolean;
36/**
37 * Removes leading indents from a template string without removing all leading whitespace
38 */
39export declare function dedent(strings: TemplateStringsArray, ...values: any[]): string;
40/**
41 * Strip comments from file content.
42 */
43export declare function stripComments(content: string): string;
44/**
45 * Escapes all special characters in RegExp pattern to avoid broken regular expressions and ensure proper matches
46 */
47export declare function escapeRegExp(re: string): string;
48/** Return true if both parameters are equal. */
49export declare type Equal<T> = (a: T, b: T) => boolean;
50export declare function arraysAreEqual<T>(a: ReadonlyArray<T> | undefined, b: ReadonlyArray<T> | undefined, eq: Equal<T>): boolean;
51/** Returns the first non-`undefined` result. */
52export declare function find<T, U>(inputs: T[], getResult: (t: T) => U | undefined): U | undefined;
53/** Returns an array that is the concatenation of all output arrays. */
54export declare function flatMap<T, U>(inputs: ReadonlyArray<T>, getOutputs: (input: T, index: number) => ReadonlyArray<U>): U[];
55/** Returns an array of all outputs that are not `undefined`. */
56export declare function mapDefined<T, U>(inputs: ReadonlyArray<T>, getOutput: (input: T) => U | undefined): U[];
57export declare function readBufferWithDetectedEncoding(buffer: Buffer): string;
58export declare type Encoding = "utf8" | "utf8-bom" | "utf16le" | "utf16be";
59export declare function detectBufferEncoding(buffer: Buffer, length?: number): Encoding;
60export declare function denormalizeWinPath(path: string): string;
61export declare function isPascalCased(name: string): boolean;
62export declare function isCamelCased(name: string): boolean;
63export declare function isKebabCased(name: string): boolean;
64export declare function isSnakeCased(name: string): boolean;
65/**
66 * Tries to resolve a package by name, optionally relative to a file path. If the
67 * file path is under a symlink, it tries to resolve the package under both the real path and under
68 * the symlink path.
69 */
70export declare function tryResolvePackage(packageName: string, relativeTo?: string): string | undefined;
71/**
72 * @deprecated Copied from tsutils 2.27.2. This will be removed once TSLint requires tsutils > 3.0.
73 */
74export declare function isFunctionScopeBoundary(node: ts.Node): boolean;