case-anything
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -12,3 +12,3 @@ 'use strict'; | ||
function getParts(string) { | ||
return string.match(/^[a-z]+|[0-9]+|[A-Z][a-z]+|[A-Z]+|[a-z]+/g); | ||
return string.match(/^[a-z]+|[A-Z][a-z]+|[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g); | ||
} | ||
@@ -15,0 +15,0 @@ /** |
@@ -8,3 +8,3 @@ /** | ||
function getParts(string) { | ||
return string.match(/^[a-z]+|[0-9]+|[A-Z][a-z]+|[A-Z]+|[a-z]+/g); | ||
return string.match(/^[a-z]+|[A-Z][a-z]+|[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g); | ||
} | ||
@@ -11,0 +11,0 @@ /** |
{ | ||
"name": "case-anything", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"sideEffects": false, | ||
"description": "camelCase, kebab-case, PascalCase... a simple integration with nano package size. (SMALL footprint!)", | ||
@@ -9,11 +10,18 @@ "main": "dist/index.cjs.js", | ||
"scripts": { | ||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx", | ||
"test": "ava", | ||
"rollup": "rollup -c build/rollup.js", | ||
"build": "npm run rollup && npm run test" | ||
"build": "npm run lint && npm run rollup && npm run test" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^2.17.0", | ||
"@typescript-eslint/parser": "^2.17.0", | ||
"ava": "^2.4.0", | ||
"rollup-plugin-typescript2": "^0.24.3", | ||
"typescript": "^3.7.2" | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.9.0", | ||
"eslint-plugin-tree-shaking": "^1.8.0", | ||
"rollup": "^1.29.1", | ||
"rollup-plugin-typescript2": "^0.25.3", | ||
"typescript": "^3.7.5" | ||
}, | ||
@@ -20,0 +28,0 @@ "repository": { |
@@ -1,2 +0,1 @@ | ||
/** | ||
@@ -9,3 +8,3 @@ * A string.match function that will return an array of "string parts" | ||
export function getParts (string: string): any[] { | ||
return string.match(/^[a-z]+|[0-9]+|[A-Z][a-z]+|[A-Z]+|[a-z]+/g) | ||
return string.match(/^[a-z]+|[A-Z][a-z]+|[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g) | ||
} | ||
@@ -12,0 +11,0 @@ |
@@ -24,4 +24,4 @@ import test from 'ava' | ||
] | ||
const testSentence = "I'm a M.O.F.O 101 OK?" | ||
// 1 | ||
test('spaceCase', t => { | ||
@@ -37,3 +37,2 @@ t.deepEqual(tests.map(spaceCase), [ | ||
]) | ||
t.is(spaceCase(testSentence), 'I m a M O F O 101 OK') | ||
}) | ||
@@ -51,62 +50,65 @@ | ||
]) | ||
t.is(pathCase(testSentence), 'I/m/a/M/O/F/O/101/OK') | ||
}) | ||
test('capitalCase', t => { | ||
tests.forEach(w => { | ||
t.is(capitalCase(w), 'Ponyta Vaporeon Poliwrath Butterfree A') | ||
}) | ||
t.is(capitalCase(testSentence), 'I M A M O F O 101 Ok') | ||
t.is(capitalCase(testSentence, s => s.split(' ')), 'I\'m A M.o.f.o 101 Ok?') | ||
tests.forEach(w => { t.is(capitalCase(w), 'Ponyta Vaporeon Poliwrath Butterfree A') }) // prettier-ignore | ||
}) | ||
test('upperCase', t => { | ||
tests.forEach(w => { | ||
t.is(upperCase(w), 'PONYTA VAPOREON POLIWRATH BUTTERFREE A') | ||
}) | ||
t.is(upperCase(testSentence), 'I M A M O F O 101 OK') | ||
tests.forEach(w => { t.is(upperCase(w), 'PONYTA VAPOREON POLIWRATH BUTTERFREE A') }) // prettier-ignore | ||
}) | ||
test('lowerCase', t => { | ||
tests.forEach(w => { | ||
t.is(lowerCase(w), 'ponyta vaporeon poliwrath butterfree a') | ||
}) | ||
t.is(lowerCase(testSentence), 'i m a m o f o 101 ok') | ||
tests.forEach(w => { t.is(lowerCase(w), 'ponyta vaporeon poliwrath butterfree a') }) // prettier-ignore | ||
}) | ||
test('pascalCase', t => { | ||
tests.forEach(w => { | ||
t.is(pascalCase(w), 'PonytaVaporeonPoliwrathButterfreeA') | ||
}) | ||
t.is(pascalCase(testSentence), 'IMAMOFO101Ok') | ||
t.is(pascalCase(testSentence, s => s.split(' ')), 'I\'mAM.o.f.o101Ok?') | ||
tests.forEach(w => { t.is(pascalCase(w), 'PonytaVaporeonPoliwrathButterfreeA') }) // prettier-ignore | ||
}) | ||
test('camelCase', t => { | ||
tests.forEach(w => { | ||
t.is(camelCase(w), 'ponytaVaporeonPoliwrathButterfreeA') | ||
}) | ||
t.is(camelCase(testSentence), 'iMAMOFO101Ok') | ||
t.is(camelCase(testSentence, s => s.split(' ')), 'i\'mAM.o.f.o101Ok?') | ||
tests.forEach(w => { t.is(camelCase(w), 'ponytaVaporeonPoliwrathButterfreeA') }) // prettier-ignore | ||
}) | ||
test('kebabCase', t => { | ||
tests.forEach(w => { | ||
t.is(kebabCase(w), 'ponyta-vaporeon-poliwrath-butterfree-a') | ||
}) | ||
t.is(kebabCase(testSentence), 'i-m-a-m-o-f-o-101-ok') | ||
tests.forEach(w => { t.is(kebabCase(w), 'ponyta-vaporeon-poliwrath-butterfree-a') }) // prettier-ignore | ||
}) | ||
test('snakeCase', t => { | ||
tests.forEach(w => { | ||
t.is(snakeCase(w), 'ponyta_vaporeon_poliwrath_butterfree_a') | ||
}) | ||
t.is(snakeCase(testSentence), 'i_m_a_m_o_f_o_101_ok') | ||
tests.forEach(w => { t.is(snakeCase(w), 'ponyta_vaporeon_poliwrath_butterfree_a') }) // prettier-ignore | ||
}) | ||
test('constantCase', t => { | ||
tests.forEach(w => { | ||
t.is(constantCase(w), 'PONYTA_VAPOREON_POLIWRATH_BUTTERFREE_A') | ||
}) | ||
t.is(constantCase(testSentence), 'I_M_A_M_O_F_O_101_OK') | ||
tests.forEach(w => { t.is(constantCase(w), 'PONYTA_VAPOREON_POLIWRATH_BUTTERFREE_A') }) // prettier-ignore | ||
}) | ||
// 2 | ||
const QTableA = 'QTableA' | ||
test('spaceCase - QTableA', t => { t.is(spaceCase(QTableA), 'Q Table A') }) // prettier-ignore | ||
test('pathCase - QTableA', t => { t.is(pathCase(QTableA), 'Q/Table/A') }) // prettier-ignore | ||
test('capitalCase - QTableA', t => { t.is(capitalCase(QTableA), 'Q Table A') }) // prettier-ignore | ||
test('upperCase - QTableA', t => { t.is(upperCase(QTableA), 'Q TABLE A') }) // prettier-ignore | ||
test('lowerCase - QTableA', t => { t.is(lowerCase(QTableA), 'q table a') }) // prettier-ignore | ||
test('pascalCase - QTableA', t => { t.is(pascalCase(QTableA), 'QTableA') }) // prettier-ignore | ||
test('camelCase - QTableA', t => { t.is(camelCase(QTableA), 'qTableA') }) // prettier-ignore | ||
test('kebabCase - QTableA', t => { t.is(kebabCase(QTableA), 'q-table-a') }) // prettier-ignore | ||
test('snakeCase - QTableA', t => { t.is(snakeCase(QTableA), 'q_table_a') }) // prettier-ignore | ||
test('constantCase - QTableA', t => { t.is(constantCase(QTableA), 'Q_TABLE_A') }) // prettier-ignore | ||
// 3 | ||
const ImaMIB101OK = "I'm a M.I.B. 101 OK?" | ||
test('spaceCase I\'m a M.I.B. 101 OK?', t => { t.is(spaceCase(ImaMIB101OK), 'I m a M I B 101 OK') }) // prettier-ignore | ||
test('pathCase I\'m a M.I.B. 101 OK?', t => { t.is(pathCase(ImaMIB101OK), 'I/m/a/M/I/B/101/OK') }) // prettier-ignore | ||
test('capitalCase I\'m a M.I.B. 101 OK?', t => { t.is(capitalCase(ImaMIB101OK), 'I M A M I B 101 Ok') }) // prettier-ignore | ||
test('upperCase I\'m a M.I.B. 101 OK?', t => { t.is(upperCase(ImaMIB101OK), 'I M A M I B 101 OK') }) // prettier-ignore | ||
test('lowerCase I\'m a M.I.B. 101 OK?', t => { t.is(lowerCase(ImaMIB101OK), 'i m a m i b 101 ok') }) // prettier-ignore | ||
test('pascalCase I\'m a M.I.B. 101 OK?', t => { t.is(pascalCase(ImaMIB101OK), 'IMAMIB101Ok') }) // prettier-ignore | ||
test('camelCase I\'m a M.I.B. 101 OK?', t => { t.is(camelCase(ImaMIB101OK), 'iMAMIB101Ok') }) // prettier-ignore | ||
test('kebabCase I\'m a M.I.B. 101 OK?', t => { t.is(kebabCase(ImaMIB101OK), 'i-m-a-m-i-b-101-ok') }) // prettier-ignore | ||
test('snakeCase I\'m a M.I.B. 101 OK?', t => { t.is(snakeCase(ImaMIB101OK), 'i_m_a_m_i_b_101_ok') }) // prettier-ignore | ||
test('constantCase I\'m a M.I.B. 101 OK?', t => { t.is(constantCase(ImaMIB101OK), 'I_M_A_M_I_B_101_OK') }) // prettier-ignore | ||
test('capitalCase -_-', t => { | ||
t.is(capitalCase(ImaMIB101OK, s => s.split(' ')), "I'm A M.i.b. 101 Ok?") // prettier-ignore | ||
}) | ||
test('pascalCase -_-', t => { | ||
t.is(pascalCase(ImaMIB101OK, s => s.split(' ')), "I'mAM.i.b.101Ok?") // prettier-ignore | ||
}) | ||
test('camelCase -_-', t => { | ||
t.is(camelCase(ImaMIB101OK, s => s.split(' ')), "i'mAM.i.b.101Ok?") // prettier-ignore | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29969
18
732
9