Socket
Socket
Sign inDemoInstall

luthier

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.2 to 0.1.0

dist/flip-characters.d.ts

31

dist/index.d.ts

@@ -1,8 +0,23 @@

declare function lowerCaseFirst(str: string): string;
declare function lowerCaseWords(str: string): string;
declare function reverse(str: string): string;
declare function shuffle(str: string): string;
declare function startCase(str: string): string;
declare function upperCaseFirst(str: string): string;
declare function upperCaseWords(str: string): string;
export { lowerCaseFirst, lowerCaseWords, reverse, shuffle, startCase, upperCaseFirst, upperCaseWords, };
declare const camelCase: (str: string) => string;
declare const constantCase: (str: string) => string;
declare const countLines: (str: string) => number;
declare const countWords: (str: string) => number;
declare const dotCase: (str: string) => string;
declare const flip: (str: string) => string;
declare const initials: (str: string) => string;
declare const kebabCase: (str: string) => string;
declare const lowerCaseFirst: (str: string) => string;
declare const lowerCaseWords: (str: string) => string;
declare const numeronym: (str: string) => string;
declare const pascalCase: (str: string) => string;
declare const random: (length: number) => string;
declare const reverse: (str: string) => string;
declare const rot13: (str: string) => string;
declare const shuffle: (str: string) => string;
declare const snakeCase: (str: string) => string;
declare const startCase: (str: string) => string;
declare const stripTags: (str: string) => string;
declare const studlyCaps: (str: string) => string;
declare const upperCaseFirst: (str: string) => string;
declare const upperCaseWords: (str: string) => string;
export { camelCase, constantCase, countLines, countWords, dotCase, flip, initials, kebabCase, lowerCaseFirst, lowerCaseWords, numeronym, pascalCase, random, reverse, rot13, shuffle, snakeCase, startCase, stripTags, studlyCaps, upperCaseFirst, upperCaseWords, };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function lowerCaseFirst(str) {
var flip_characters_1 = require("./flip-characters");
var camelCase = function (str) {
return lowerCaseFirst(pascalCase(str));
};
exports.camelCase = camelCase;
var constantCase = function (str) {
return str.toUpperCase().replace(/[^A-Z ]/g, '').trim().replace(/ +/g, '_');
};
exports.constantCase = constantCase;
var countLines = function (str) {
return str.split(/\r\n|\r|\n/).length;
};
exports.countLines = countLines;
var countWords = function (str) {
return str.trim().split(/\s+/).length;
};
exports.countWords = countWords;
var dotCase = function (str) {
return str.toLowerCase().replace(/[^a-z ]/g, '').trim().replace(/ +/g, '.');
};
exports.dotCase = dotCase;
var flip = function (str) {
return str.split('').reverse().map(function (chr) {
return flip_characters_1.flipCharacters[chr] || chr;
}).join('');
};
exports.flip = flip;
var initials = function (str) {
return str.trim().split(/\s+/).reduce(function (result, word) { return result + word[0].toUpperCase(); }, '');
};
exports.initials = initials;
var kebabCase = function (str) {
return str.toLowerCase().replace(/[^a-z ]/g, '').trim().replace(/ +/g, '-');
};
exports.kebabCase = kebabCase;
var lowerCaseFirst = function (str) {
return str.replace(/^\w/, function (c) { return c.toLowerCase(); });
}
};
exports.lowerCaseFirst = lowerCaseFirst;
function lowerCaseWords(str) {
var lowerCaseWords = function (str) {
return str.replace(/\w\S*/g, function (w) { return lowerCaseFirst(w); });
}
};
exports.lowerCaseWords = lowerCaseWords;
function reverse(str) {
var numeronym = function (str) {
var trimmed = str.trim().replace(/\s+/, '').split('');
if (trimmed.length === 1) {
return trimmed[0];
}
if (trimmed.length === 2) {
return trimmed[0] + (trimmed.length - 1);
}
return trimmed[0] + (trimmed.length - 2) + trimmed.slice(-1);
};
exports.numeronym = numeronym;
var pascalCase = function (str) {
return upperCaseWords(str.toLowerCase().replace(/[^a-z ]/g, '')).replace(/ /g, '');
};
exports.pascalCase = pascalCase;
var random = function (length) {
var randomInt = function (min, max) { return (Math.random() * (max - min) + min); };
var str = '';
for (var i = 0; i < length; i++) {
str += String.fromCharCode(randomInt(32, 126));
}
return str;
};
exports.random = random;
var reverse = function (str) {
return str.split('').reverse().join('');
}
};
exports.reverse = reverse;
function shuffle(str) {
var rot13 = function (str) {
return str.replace(/[a-z]/gi, function (c) { return (String.fromCharCode(c.charCodeAt(0) + (c.toUpperCase() <= 'M' ? 13 : -13))); });
};
exports.rot13 = rot13;
var shuffle = function (str) {
var _a;

@@ -23,15 +86,42 @@ var arr = str.split('');

return arr.join('');
}
};
exports.shuffle = shuffle;
function startCase(str) {
var snakeCase = function (str) {
return str.toLowerCase().replace(/[^a-z ]/g, '').trim().replace(/ +/g, '_');
};
exports.snakeCase = snakeCase;
var startCase = function (str) {
return upperCaseWords(str.toLowerCase());
}
};
exports.startCase = startCase;
function upperCaseFirst(str) {
var stripTags = function (str) {
return str.replace(/<[^>]*>/g, '');
};
exports.stripTags = stripTags;
var studlyCaps = function (str) {
return str.split('').reduce(function (result, chr) {
if (/[a-z]/i.test(chr)) {
if (result.upper) {
result.string += chr.toUpperCase();
result.upper = false;
}
else {
result.string += chr.toLowerCase();
result.upper = true;
}
}
else {
result.string += chr;
}
return result;
}, { string: '', upper: true }).string;
};
exports.studlyCaps = studlyCaps;
var upperCaseFirst = function (str) {
return str.replace(/^\w/, function (c) { return c.toUpperCase(); });
}
};
exports.upperCaseFirst = upperCaseFirst;
function upperCaseWords(str) {
var upperCaseWords = function (str) {
return str.replace(/\w\S*/g, function (w) { return upperCaseFirst(w); });
}
};
exports.upperCaseWords = upperCaseWords;
{
"name": "luthier",
"version": "0.0.2",
"version": "0.1.0",
"description": "Luthier handles all of your stringed needs.",

@@ -36,3 +36,3 @@ "main": "dist/index.js",

"build": "tsc",
"publish": "npm build && npm publish",
"publish": "tsc && npm publish",
"test": "jest",

@@ -39,0 +39,0 @@ "test:coverage": "jest --coverage --coverageReporters=text-lcov | coveralls"

import * as luthier from '../src/index';
describe('lower case first', () => {
describe('camelCase', () => {
it('should convert to camel case', () => {
expect(luthier.camelCase('TESTING')).toBe('testing');
expect(luthier.camelCase('testing Testing')).toBe('testingTesting');
expect(luthier.camelCase('- TESTING - testing -')).toBe('testingTesting');
});
});
// TODO
// describe('chunk', () => {
// it('should chunk a string', () => {
// });
// });
describe('constantCase', () => {
it('should convert to constant case', () => {
expect(luthier.constantCase('TESTING')).toBe('TESTING');
expect(luthier.constantCase('testing Testing')).toBe('TESTING_TESTING');
expect(luthier.constantCase('- TESTING - testing -')).toBe('TESTING_TESTING');
});
});
describe('countLines', () => {
it('should count the lines in a string', () => {
expect(luthier.countLines('testing')).toBe(1);
expect(luthier.countLines('testing\r\ntesting')).toBe(2);
expect(luthier.countLines('testing\rtesting')).toBe(2);
expect(luthier.countLines('testing\ntesting')).toBe(2);
expect(luthier.countLines('te\rs\nt\r\ning')).toBe(4);
});
});
describe('countWords', () => {
it('should count the words in a string', () => {
expect(luthier.countWords('testing')).toBe(1);
expect(luthier.countWords('testing testing')).toBe(2);
});
});
describe('dotCase', () => {
it('should convert to dot case', () => {
expect(luthier.dotCase('TESTING')).toBe('testing');
expect(luthier.dotCase('testing Testing')).toBe('testing.testing');
expect(luthier.dotCase('- TESTING - testing -')).toBe('testing.testing');
});
});
describe('flip', () => {
it('should flip upside down', () => {
expect(luthier.flip(' testing, testing, 1234!')).toBe("¡߈Ɛᘔ⇂ 'ɓuᴉʇsǝʇ 'ɓuᴉʇsǝʇ ");
expect(luthier.flip("¡߈Ɛᘔ⇂ 'ɓuᴉʇsǝʇ 'ɓuᴉʇsǝʇ ")).toBe(' testing, testing, 1234!');
});
});
describe('initials', () => {
it('should reduce to initials', () => {
expect(luthier.initials(' testing testing')).toBe('TT');
expect(luthier.initials('Joshua John Sherman')).toBe('JJS');
});
});
describe('kebabCase', () => {
it('should convert to kebab case', () => {
expect(luthier.kebabCase('TESTING')).toBe('testing');
expect(luthier.kebabCase('testing Testing')).toBe('testing-testing');
expect(luthier.kebabCase('- TESTING - testing -')).toBe('testing-testing');
});
});
// TODO
// describe('leet', () => {
// it('should convert to leet', () => {
// expect(luthier.leet(' TESTING testing')).toBe(' 73571ng 73571ng');
// });
// });
describe('lowerCaseFirst', () => {
it('should lowercase the first letter', () => {

@@ -9,3 +85,3 @@ expect(luthier.lowerCaseFirst('TESTING')).toBe('tESTING');

describe('lower case words', () => {
describe('lowerCaseWords', () => {
it('should lowercase the first letter of words', () => {

@@ -16,4 +92,44 @@ expect(luthier.lowerCaseWords('TESTING TESTING')).toBe('tESTING tESTING');

describe('numeronym', () => {
it('should convert to numeronym', () => {
expect(luthier.numeronym('a')).toBe('a');
expect(luthier.numeronym('ab')).toBe('a1');
expect(luthier.numeronym('abc')).toBe('a1c');
expect(luthier.numeronym('accessibility')).toBe('a11y');
expect(luthier.numeronym('INTERNATIONALIZATION')).toBe('I18N');
expect(luthier.numeronym(' TESTING testing')).toBe('T12g');
});
});
describe('pascalCase', () => {
it('should convert to pascal case', () => {
expect(luthier.pascalCase('TESTING')).toBe('Testing');
expect(luthier.pascalCase('testing Testing')).toBe('TestingTesting');
expect(luthier.pascalCase('- TESTING - testing -')).toBe('TestingTesting');
});
});
// TODO
// describe('plural', () => {
// it('should convert singler to plural', () => {
// expect(luthier.plural('test')).toBe('tests');
// expect(luthier.plural('fly')).toBe('flies');
// });
// });
// TODO
// describe('possessive', () => {
// it('should convert to possesive tense', () => {
// });
// });
describe('random', () => {
it('should generate random characters', () => {
expect(luthier.random(10)).toHaveLength(10);
expect(luthier.random(100)).toHaveLength(100);
});
});
describe('reverse', () => {
it('should reverse a string', () => {
it('should reverse characters', () => {
expect(luthier.reverse('testing')).toBe('gnitset');

@@ -23,9 +139,34 @@ });

describe('rot13', () => {
it('should encode by rotating 13 places', () => {
expect(luthier.rot13('testing')).toBe('grfgvat');
expect(luthier.rot13('TESTING')).toBe('GRFGVAT');
});
});
describe('shuffle', () => {
it('should shuffle a string', () => {
expect(luthier.shuffle('testing')).not.toBe('testing');
it('should shuffle characters', () => {
const shuffled = luthier.shuffle('testing')
expect(shuffled).not.toBe('testing');
expect(shuffled).toHaveLength(7);
});
});
describe('start case', () => {
// describe('singular', () => {
// it('should convert to plural to singular', () => {
// expect(luthier.singular('tests')).toBe('test');
// expect(luthier.singular('flies')).toBe('fly');
// expect(luthier.singular('calves')).toBe('calf');
// });
// });
describe('snakeCase', () => {
it('should convert to snake case', () => {
expect(luthier.snakeCase('TESTING')).toBe('testing');
expect(luthier.snakeCase('testing Testing')).toBe('testing_testing');
expect(luthier.snakeCase('- TESTING - testing -')).toBe('testing_testing');
});
});
describe('startCase', () => {
it('should capitalize every word', () => {

@@ -36,3 +177,17 @@ expect(luthier.shuffle('test TEST test')).not.toBe('Test Test Test');

describe('upper case first', () => {
describe('stripTags', () => {
it('should strip tags', () => {
expect(luthier.stripTags('<div>Testing</div>')).toBe('Testing');
expect(luthier.stripTags('<div>Test</div><div>ing</div>')).toBe('Testing');
});
});
describe('studlyCaps', () => {
it('should convert to studly caps', () => {
expect(luthier.studlyCaps('TESTING')).toBe('TeStInG');
expect(luthier.studlyCaps('testing Testing')).toBe('TeStInG tEsTiNg');
});
});
describe('upperCaseFirst', () => {
it('should capitalize the first letter', () => {

@@ -43,6 +198,13 @@ expect(luthier.upperCaseFirst('testing')).toBe('Testing');

describe('upper case words', () => {
describe('upperCaseWords', () => {
it('should capitalize the first letter of words', () => {
expect(luthier.upperCaseWords('testing testing')).toBe('Testing Testing');
expect(luthier.upperCaseWords(' testing testing')).toBe(' Testing Testing');
});
});
describe('wordWrap', () => {
it('should wrap words', () => {
// TODO
});
});
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc