Socket
Socket
Sign inDemoInstall

title-case

Package Overview
Dependencies
1
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.1 to 3.0.2

18

dist.es2015/index.js

@@ -1,12 +0,12 @@

const SMALL_WORDS = /\b(?:an?d?|a[st]|because|but|by|en|for|i[fn]|neither|nor|o[fnr]|only|over|per|so|some|tha[tn]|the|to|up|upon|vs?\.?|versus|via|when|with|without|yet)\b/i;
const TOKENS = /[^\s:–—-]+|./g;
const WHITESPACE = /\s/;
const IS_MANUAL_CASE = /.(?=[A-Z]|\..)/;
const ALPHANUMERIC_PATTERN = /[A-Za-z0-9\u00C0-\u00FF]/;
var SMALL_WORDS = /\b(?:an?d?|a[st]|because|but|by|en|for|i[fn]|neither|nor|o[fnr]|only|over|per|so|some|tha[tn]|the|to|up|upon|vs?\.?|versus|via|when|with|without|yet)\b/i;
var TOKENS = /[^\s:–—-]+|./g;
var WHITESPACE = /\s/;
var IS_MANUAL_CASE = /.(?=[A-Z]|\..)/;
var ALPHANUMERIC_PATTERN = /[A-Za-z0-9\u00C0-\u00FF]/;
export function titleCase(input) {
let result = "";
let m;
var result = "";
var m;
// tslint:disable-next-line
while ((m = TOKENS.exec(input)) !== null) {
const { 0: token, index } = m;
var token = m[0], index = m.index;
if (

@@ -23,3 +23,3 @@ // Ignore already capitalized words.

// Find and uppercase first word character, skips over *modifiers*.
result += token.replace(ALPHANUMERIC_PATTERN, m => m.toUpperCase());
result += token.replace(ALPHANUMERIC_PATTERN, function (m) { return m.toUpperCase(); });
continue;

@@ -26,0 +26,0 @@ }

@@ -6,3 +6,3 @@ import { inspect } from "util";

*/
const TEST_CASES = [
var TEST_CASES = [
["", ""],

@@ -63,9 +63,13 @@ ["2019", "2019"],

];
describe("swap case", () => {
for (const [input, result] of TEST_CASES) {
it(`${inspect(input)} -> ${inspect(result)}`, () => {
describe("swap case", function () {
var _loop_1 = function (input, result) {
it(inspect(input) + " -> " + inspect(result), function () {
expect(titleCase(input)).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];
_loop_1(input, result);
}
});
//# sourceMappingURL=index.spec.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const SMALL_WORDS = /\b(?:an?d?|a[st]|because|but|by|en|for|i[fn]|neither|nor|o[fnr]|only|over|per|so|some|tha[tn]|the|to|up|upon|vs?\.?|versus|via|when|with|without|yet)\b/i;
const TOKENS = /[^\s:–—-]+|./g;
const WHITESPACE = /\s/;
const IS_MANUAL_CASE = /.(?=[A-Z]|\..)/;
const ALPHANUMERIC_PATTERN = /[A-Za-z0-9\u00C0-\u00FF]/;
var SMALL_WORDS = /\b(?:an?d?|a[st]|because|but|by|en|for|i[fn]|neither|nor|o[fnr]|only|over|per|so|some|tha[tn]|the|to|up|upon|vs?\.?|versus|via|when|with|without|yet)\b/i;
var TOKENS = /[^\s:–—-]+|./g;
var WHITESPACE = /\s/;
var IS_MANUAL_CASE = /.(?=[A-Z]|\..)/;
var ALPHANUMERIC_PATTERN = /[A-Za-z0-9\u00C0-\u00FF]/;
function titleCase(input) {
let result = "";
let m;
var result = "";
var m;
// tslint:disable-next-line
while ((m = TOKENS.exec(input)) !== null) {
const { 0: token, index } = m;
var token = m[0], index = m.index;
if (

@@ -25,3 +25,3 @@ // Ignore already capitalized words.

// Find and uppercase first word character, skips over *modifiers*.
result += token.replace(ALPHANUMERIC_PATTERN, m => m.toUpperCase());
result += token.replace(ALPHANUMERIC_PATTERN, function (m) { return m.toUpperCase(); });
continue;

@@ -28,0 +28,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("util");
const _1 = require(".");
var util_1 = require("util");
var _1 = require(".");
/**
* Based on https://github.com/gouch/to-title-case/blob/master/test/tests.json.
*/
const TEST_CASES = [
var TEST_CASES = [
["", ""],

@@ -64,9 +64,13 @@ ["2019", "2019"],

];
describe("swap case", () => {
for (const [input, result] of TEST_CASES) {
it(`${util_1.inspect(input)} -> ${util_1.inspect(result)}`, () => {
describe("swap case", function () {
var _loop_1 = function (input, result) {
it(util_1.inspect(input) + " -> " + util_1.inspect(result), function () {
expect(_1.titleCase(input)).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];
_loop_1(input, result);
}
});
//# sourceMappingURL=index.spec.js.map
{
"name": "title-case",
"version": "3.0.1",
"version": "3.0.2",
"description": "Transform a string into title case following English rules",

@@ -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",

@@ -85,3 +85,6 @@ "prepare": "npm run build"

},
"gitHead": "a3df3a43bfd3d8e3386d0fb09b69454b91516d18"
"dependencies": {
"tslib": "^1.10.0"
},
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc