no-case
Advanced tools
Comparing version 3.0.1 to 3.0.2
import { lowerCase } from "lower-case"; | ||
// Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case"). | ||
const DEFAULT_SPLIT_REGEXP = /([a-z0-9])([A-Z])|([A-Z])([A-Z][a-z])/g; | ||
var DEFAULT_SPLIT_REGEXP = /([a-z0-9])([A-Z])|([A-Z])([A-Z][a-z])/g; | ||
// Remove all non-word characters. | ||
const DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; | ||
var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; | ||
/** | ||
* Normalize the string into something other libraries can manipulate easier. | ||
*/ | ||
export function noCase(input, options = {}) { | ||
const { splitRegexp = DEFAULT_SPLIT_REGEXP, stripRegexp = DEFAULT_STRIP_REGEXP, transform = lowerCase, delimiter = " " } = options; | ||
let result = input | ||
.replace(splitRegexp, (...args) => { | ||
export 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 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d; | ||
var result = input | ||
.replace(splitRegexp, function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
return args | ||
.slice(1, -2) | ||
.filter(x => x !== undefined) | ||
.filter(function (x) { return x !== undefined; }) | ||
.join("\0"); | ||
}) | ||
.replace(stripRegexp, "\0"); | ||
let start = 0; | ||
let end = result.length; | ||
var start = 0; | ||
var end = result.length; | ||
// Trim the delimiter from around the output string. | ||
@@ -22,0 +27,0 @@ while (result.charAt(start) === "\0") |
import { noCase } from "."; | ||
const TEST_CASES = [ | ||
var TEST_CASES = [ | ||
// Single words. | ||
@@ -45,9 +45,13 @@ ["test", "test"], | ||
]; | ||
describe("no case", () => { | ||
for (const [input, result, options] of TEST_CASES) { | ||
it(`${input} -> ${result}`, () => { | ||
describe("no case", function () { | ||
var _loop_1 = function (input, result, options) { | ||
it(input + " -> " + result, function () { | ||
expect(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 |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const lower_case_1 = require("lower-case"); | ||
var lower_case_1 = require("lower-case"); | ||
// Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case"). | ||
const DEFAULT_SPLIT_REGEXP = /([a-z0-9])([A-Z])|([A-Z])([A-Z][a-z])/g; | ||
var DEFAULT_SPLIT_REGEXP = /([a-z0-9])([A-Z])|([A-Z])([A-Z][a-z])/g; | ||
// Remove all non-word characters. | ||
const DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; | ||
var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; | ||
/** | ||
* Normalize the string into something other libraries can manipulate easier. | ||
*/ | ||
function noCase(input, options = {}) { | ||
const { splitRegexp = DEFAULT_SPLIT_REGEXP, stripRegexp = DEFAULT_STRIP_REGEXP, transform = lower_case_1.lowerCase, delimiter = " " } = options; | ||
let result = input | ||
.replace(splitRegexp, (...args) => { | ||
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 = input | ||
.replace(splitRegexp, function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
return args | ||
.slice(1, -2) | ||
.filter(x => x !== undefined) | ||
.filter(function (x) { return x !== undefined; }) | ||
.join("\0"); | ||
}) | ||
.replace(stripRegexp, "\0"); | ||
let start = 0; | ||
let end = result.length; | ||
var start = 0; | ||
var end = result.length; | ||
// Trim the delimiter from around the output string. | ||
@@ -24,0 +29,0 @@ while (result.charAt(start) === "\0") |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const _1 = require("."); | ||
const TEST_CASES = [ | ||
var _1 = require("."); | ||
var TEST_CASES = [ | ||
// Single words. | ||
@@ -47,9 +47,13 @@ ["test", "test"], | ||
]; | ||
describe("no case", () => { | ||
for (const [input, result, options] of TEST_CASES) { | ||
it(`${input} -> ${result}`, () => { | ||
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 |
{ | ||
"name": "no-case", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Transform into a lower cased string with spaces between words", | ||
@@ -19,3 +19,3 @@ "main": "dist/index.js", | ||
"specs": "jest --coverage", | ||
"test": "npm run build && npm run lint && npm run specs && npm run size", | ||
"test": "npm run build && npm run lint && npm run specs", | ||
"size": "size-limit", | ||
@@ -49,3 +49,3 @@ "prepare": "npm run build" | ||
"path": "dist/index.js", | ||
"limit": "500 B" | ||
"limit": "550 B" | ||
} | ||
@@ -71,3 +71,4 @@ ], | ||
"dependencies": { | ||
"lower-case": "^2.0.0" | ||
"lower-case": "^2.0.1", | ||
"tslib": "^1.10.0" | ||
}, | ||
@@ -86,3 +87,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "a3df3a43bfd3d8e3386d0fb09b69454b91516d18" | ||
"gitHead": "07b68e1a696a1a34090d4f1fc136b1bd467aaa3f" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
24150
212
2
+ Addedtslib@^1.10.0
+ Addedtslib@1.14.1(transitive)
Updatedlower-case@^2.0.1