$
This commit is contained in:
10
node_modules/no-case/dist/index.d.ts
generated
vendored
Normal file
10
node_modules/no-case/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export interface Options {
|
||||
splitRegexp?: RegExp | RegExp[];
|
||||
stripRegexp?: RegExp | RegExp[];
|
||||
delimiter?: string;
|
||||
transform?: (part: string, index: number, parts: string[]) => string;
|
||||
}
|
||||
/**
|
||||
* Normalize the string into something other libraries can manipulate easier.
|
||||
*/
|
||||
export declare function noCase(input: string, options?: Options): string;
|
35
node_modules/no-case/dist/index.js
generated
vendored
Normal file
35
node_modules/no-case/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.noCase = void 0;
|
||||
var lower_case_1 = require("lower-case");
|
||||
// Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
|
||||
var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
|
||||
// Remove all non-word characters.
|
||||
var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
|
||||
/**
|
||||
* Normalize the string into something other libraries can manipulate easier.
|
||||
*/
|
||||
function noCase(input, options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
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;
|
||||
var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
|
||||
var start = 0;
|
||||
var end = result.length;
|
||||
// Trim the delimiter from around the output string.
|
||||
while (result.charAt(start) === "\0")
|
||||
start++;
|
||||
while (result.charAt(end - 1) === "\0")
|
||||
end--;
|
||||
// Transform each token independently.
|
||||
return result.slice(start, end).split("\0").map(transform).join(delimiter);
|
||||
}
|
||||
exports.noCase = noCase;
|
||||
/**
|
||||
* Replace `re` in the input string with the replacement value.
|
||||
*/
|
||||
function replace(input, re, value) {
|
||||
if (re instanceof RegExp)
|
||||
return input.replace(re, value);
|
||||
return re.reduce(function (input, re) { return input.replace(re, value); }, input);
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/no-case/dist/index.js.map
generated
vendored
Normal file
1
node_modules/no-case/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/no-case/dist/index.spec.d.ts
generated
vendored
Normal file
1
node_modules/no-case/dist/index.spec.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
59
node_modules/no-case/dist/index.spec.js
generated
vendored
Normal file
59
node_modules/no-case/dist/index.spec.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var _1 = require(".");
|
||||
var TEST_CASES = [
|
||||
// Single words.
|
||||
["test", "test"],
|
||||
["TEST", "test"],
|
||||
// Camel case.
|
||||
["testString", "test string"],
|
||||
["testString123", "test string123"],
|
||||
["testString_1_2_3", "test string 1 2 3"],
|
||||
["x_256", "x 256"],
|
||||
["anHTMLTag", "an html tag"],
|
||||
["ID123String", "id123 string"],
|
||||
["Id123String", "id123 string"],
|
||||
["foo bar123", "foo bar123"],
|
||||
["a1bStar", "a1b star"],
|
||||
// Constant case.
|
||||
["CONSTANT_CASE ", "constant case"],
|
||||
["CONST123_FOO", "const123 foo"],
|
||||
// Random cases.
|
||||
["FOO_bar", "foo bar"],
|
||||
["XMLHttpRequest", "xml http request"],
|
||||
["IQueryAArgs", "i query a args"],
|
||||
// Non-alphanumeric separators.
|
||||
["dot.case", "dot case"],
|
||||
["path/case", "path case"],
|
||||
["snake_case", "snake case"],
|
||||
["snake_case123", "snake case123"],
|
||||
["snake_case_123", "snake case 123"],
|
||||
// Punctuation.
|
||||
['"quotes"', "quotes"],
|
||||
// Space between number parts.
|
||||
["version 0.45.0", "version 0 45 0"],
|
||||
["version 0..78..9", "version 0 78 9"],
|
||||
["version 4_99/4", "version 4 99 4"],
|
||||
// Whitespace.
|
||||
[" test ", "test"],
|
||||
// Number string input.
|
||||
["something_2014_other", "something 2014 other"],
|
||||
// https://github.com/blakeembrey/change-case/issues/21
|
||||
["amazon s3 data", "amazon s3 data"],
|
||||
["foo_13_bar", "foo 13 bar"],
|
||||
// Customization.
|
||||
["camel2019", "camel 2019", { splitRegexp: /([a-z])([A-Z0-9])/g }],
|
||||
["minifyURLs", "minify urls", { splitRegexp: /([a-z])([A-Z0-9])/g }],
|
||||
];
|
||||
describe("no case", function () {
|
||||
var _loop_1 = function (input, result, options) {
|
||||
it(input + " -> " + result, function () {
|
||||
expect(_1.noCase(input, options)).toEqual(result);
|
||||
});
|
||||
};
|
||||
for (var _i = 0, TEST_CASES_1 = TEST_CASES; _i < TEST_CASES_1.length; _i++) {
|
||||
var _a = TEST_CASES_1[_i], input = _a[0], result = _a[1], options = _a[2];
|
||||
_loop_1(input, result, options);
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=index.spec.js.map
|
1
node_modules/no-case/dist/index.spec.js.map
generated
vendored
Normal file
1
node_modules/no-case/dist/index.spec.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user