source: imaps-frontend/node_modules/no-case/dist/index.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.6 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.noCase = void 0;
4var lower_case_1 = require("lower-case");
5// Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
6var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
7// Remove all non-word characters.
8var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
9/**
10 * Normalize the string into something other libraries can manipulate easier.
11 */
12function noCase(input, options) {
13 if (options === void 0) { options = {}; }
14 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lower_case_1.lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
15 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
16 var start = 0;
17 var end = result.length;
18 // Trim the delimiter from around the output string.
19 while (result.charAt(start) === "\0")
20 start++;
21 while (result.charAt(end - 1) === "\0")
22 end--;
23 // Transform each token independently.
24 return result.slice(start, end).split("\0").map(transform).join(delimiter);
25}
26exports.noCase = noCase;
27/**
28 * Replace `re` in the input string with the replacement value.
29 */
30function replace(input, re, value) {
31 if (re instanceof RegExp)
32 return input.replace(re, value);
33 return re.reduce(function (input, re) { return input.replace(re, value); }, input);
34}
35//# sourceMappingURL=index.js.map
Note: See TracBrowser for help on using the repository browser.