diff --git a/.gitignore b/.gitignore index 62c9c5f..707754e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.log .vscode/ +.idea/ dist/ node_modules/ diff --git a/benchmark.js b/benchmark.js index 78ff4bc..a6d8c2d 100644 --- a/benchmark.js +++ b/benchmark.js @@ -2,6 +2,9 @@ const Benchmark = require('benchmark') const humps = require('humps') const xcase = require('xcase') +const tsCaseConvert = require('ts-case-convert') + + const fastCase = require('.') const objectBare = { @@ -799,6 +802,9 @@ new Benchmark.Suite() .add('humps#camelize', function () { humps.camelize(getStringForCamelize()) }) + .add('ts-case-convert#camelize', function () { + tsCaseConvert.toCamel(getStringForCamelize()) + }) .on('cycle', onCycle) .on('complete', onComplete) .run() @@ -827,6 +833,9 @@ new Benchmark.Suite() .add('humps#pascalize', function () { humps.pascalize(getStringForPascalize()) }) + .add('ts-case-convert#pascalize', function () { + tsCaseConvert.toPascal(getStringForPascalize()) + }) .on('cycle', onCycle) .on('complete', onComplete) .run() @@ -855,6 +864,9 @@ new Benchmark.Suite() .add('humps#camelizeKeys', function () { humps.camelizeKeys(smallObject) }) + .add('ts-case-convert#camelizeKeys', function () { + tsCaseConvert.objectToCamel(smallObject) + }) .on('cycle', onCycle) .on('complete', onComplete) .run() @@ -894,6 +906,9 @@ new Benchmark.Suite() .add('humps#camelizeKeys (large object)', function () { humps.camelizeKeys(objectPool.pop()) }) + .add('ts-case-convert#camelizeKeys (large object)', function () { + tsCaseConvert.objectToCamel(objectPool.pop()) + }) .on('cycle', onCycle) .on('complete', onComplete) .run() @@ -920,6 +935,9 @@ new Benchmark.Suite() .add('humps#pascalizeKeys (large object)', function () { humps.pascalizeKeys(camelizedObject) }) + .add('ts-case-convert#pascalizeKeys (large object)', function () { + tsCaseConvert.objectToPascal(camelizedObject) + }) .on('cycle', onCycle) .on('complete', onComplete) .run() diff --git a/package.json b/package.json index ae27703..d2c0543 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "microbundle": "^0.15.0", "prettier": "^2.0.5", "typescript": "^4.0.2", - "xcase": "^2.0.1" + "xcase": "^2.0.1", + "ts-case-convert": "^2.0.7" } } diff --git a/yarn.lock b/yarn.lock index 0d13977..1566c64 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4225,6 +4225,11 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" +ts-case-convert@^2.0.7: + version "2.0.7" + resolved "https://registry.yarnpkg.com/ts-case-convert/-/ts-case-convert-2.0.7.tgz#a92b9fb17aadde088f34329f6841cf5640c24f23" + integrity sha512-Kqj8wrkuduWsKUOUNRczrkdHCDt4ZNNd6HKjVw42EnMIGHQUABS4pqfy0acETVLwUTppc1fzo/yi11+uMTaqzw== + tslib@^2.0.3, tslib@^2.4.0: version "2.4.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3"