123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. */
  21. export 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. */
  26. export declare function objectify(arg: any): any;
  27. export 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. */
  32. export declare function camelize(stringWithHyphens: string): string;
  33. export declare function isUpperCase(str: string): boolean;
  34. export declare function isLowerCase(str: string): boolean;
  35. /**
  36. * Removes leading indents from a template string without removing all leading whitespace
  37. */
  38. export declare function dedent(strings: TemplateStringsArray, ...values: any[]): string;
  39. /**
  40. * Strip comments from file content.
  41. */
  42. export 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. */
  46. export declare function escapeRegExp(re: string): string;
  47. /** Return true if both parameters are equal. */
  48. export declare type Equal<T> = (a: T, b: T) => boolean;
  49. export declare function arraysAreEqual<T>(a: ReadonlyArray<T> | undefined, b: ReadonlyArray<T> | undefined, eq: Equal<T>): boolean;
  50. /** Returns the first non-`undefined` result. */
  51. export 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. */
  53. export 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`. */
  55. export declare function mapDefined<T, U>(inputs: ReadonlyArray<T>, getOutput: (input: T) => U | undefined): U[];
  56. export declare function readBufferWithDetectedEncoding(buffer: Buffer): string;
  57. export declare type Encoding = "utf8" | "utf8-bom" | "utf16le" | "utf16be";
  58. export declare function detectBufferEncoding(buffer: Buffer, length?: number): Encoding;
  59. export declare function denormalizeWinPath(path: string): string;