source: trip-planner-front/node_modules/@angular-devkit/core/src/utils/literals.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.2 KB
RevLine 
[6a3a178]1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.trimNewlines = exports.stripIndents = exports.stripIndent = exports.indentBy = exports.oneLine = void 0;
11// eslint-disable-next-line @typescript-eslint/no-explicit-any
12function oneLine(strings, ...values) {
13 const endResult = String.raw(strings, ...values);
14 return endResult.replace(/(?:\r?\n(?:\s*))+/gm, ' ').trim();
15}
16exports.oneLine = oneLine;
17function indentBy(indentations) {
18 let i = '';
19 while (indentations--) {
20 i += ' ';
21 }
22 return (strings, ...values) => {
23 return i + stripIndent(strings, ...values).replace(/\n/g, '\n' + i);
24 };
25}
26exports.indentBy = indentBy;
27// eslint-disable-next-line @typescript-eslint/no-explicit-any
28function stripIndent(strings, ...values) {
29 const endResult = String.raw(strings, ...values);
30 // remove the shortest leading indentation from each line
31 const match = endResult.match(/^[ \t]*(?=\S)/gm);
32 // return early if there's nothing to strip
33 if (match === null) {
34 return endResult;
35 }
36 const indent = Math.min(...match.map((el) => el.length));
37 const regexp = new RegExp('^[ \\t]{' + indent + '}', 'gm');
38 return (indent > 0 ? endResult.replace(regexp, '') : endResult).trim();
39}
40exports.stripIndent = stripIndent;
41// eslint-disable-next-line @typescript-eslint/no-explicit-any
42function stripIndents(strings, ...values) {
43 return String.raw(strings, ...values)
44 .split('\n')
45 .map((line) => line.trim())
46 .join('\n')
47 .trim();
48}
49exports.stripIndents = stripIndents;
50// eslint-disable-next-line @typescript-eslint/no-explicit-any
51function trimNewlines(strings, ...values) {
52 const endResult = String.raw(strings, ...values);
53 return (endResult
54 // Remove the newline at the start.
55 .replace(/^(?:\r?\n)+/, '')
56 // Remove the newline at the end and following whitespace.
57 .replace(/(?:\r?\n(?:\s*))$/, ''));
58}
59exports.trimNewlines = trimNewlines;
Note: See TracBrowser for help on using the repository browser.