UNPKG

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