Skip to content

Commit

Permalink
Remove camelcase module to reduce dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
kination committed Dec 10, 2018
1 parent 142869e commit b09948d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "tucson",
"version": "0.3.0",
"version": "0.3.1",
"description": "Convert JSON key/values to make it fit on your project",
"main": "lib/index.js",
"scripts": {
"test": "mocha",
"lint": "tslint -p ./",
"build": "yarn run lint && tsc",
"prepublishOnly": "yarn run build && yarn run test"
"build": "tsc",
"prepublishOnly": "yarn run build && yarn run lint && yarn run test"
},
"keywords": [
"tucson",
Expand All @@ -24,9 +24,7 @@
"typescript": "^3.0.3"
},
"dependencies": {
"@types/camelcase": "^4.1.0",
"@types/moment": "^2.13.0",
"camelcase": "^5.0.0",
"moment": "^2.22.2",
"ws": "^6.0.0"
}
Expand Down
14 changes: 14 additions & 0 deletions src/camelCase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default function camelCase (target: string): string {
const wordSeparators = /[\s\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]+/
const seperated = target.split(wordSeparators)
let converted = ''
for (const text of seperated) {
if (seperated.indexOf(text) !== 0) {
converted += text.charAt(0).toUpperCase() + text.slice(1)
} else {
converted += text
}
}

return converted
}
2 changes: 1 addition & 1 deletion src/tucson.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as camelCase from 'camelcase'
import * as moment from 'moment'

import camelCase from './camelCase'
import { Config } from './config'
import { IJsonOption } from './jsonOption'
import snakeCase from './snakeCase'
Expand Down

0 comments on commit b09948d

Please sign in to comment.