source: trip-planner-front/node_modules/lodash/trimEnd.js@ eed0bf8

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

initial commit

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[6a3a178]1var baseToString = require('./_baseToString'),
2 castSlice = require('./_castSlice'),
3 charsEndIndex = require('./_charsEndIndex'),
4 stringToArray = require('./_stringToArray'),
5 toString = require('./toString'),
6 trimmedEndIndex = require('./_trimmedEndIndex');
7
8/**
9 * Removes trailing whitespace or specified characters from `string`.
10 *
11 * @static
12 * @memberOf _
13 * @since 4.0.0
14 * @category String
15 * @param {string} [string=''] The string to trim.
16 * @param {string} [chars=whitespace] The characters to trim.
17 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
18 * @returns {string} Returns the trimmed string.
19 * @example
20 *
21 * _.trimEnd(' abc ');
22 * // => ' abc'
23 *
24 * _.trimEnd('-_-abc-_-', '_-');
25 * // => '-_-abc'
26 */
27function trimEnd(string, chars, guard) {
28 string = toString(string);
29 if (string && (guard || chars === undefined)) {
30 return string.slice(0, trimmedEndIndex(string) + 1);
31 }
32 if (!string || !(chars = baseToString(chars))) {
33 return string;
34 }
35 var strSymbols = stringToArray(string),
36 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
37
38 return castSlice(strSymbols, 0, end).join('');
39}
40
41module.exports = trimEnd;
Note: See TracBrowser for help on using the repository browser.