├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── lib └── recase.dart ├── pubspec.lock ├── pubspec.yaml ├── test └── recase_test.dart └── tool └── perf.test.dart /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .packages 3 | .dart_tool 4 | .pub 5 | .atom 6 | .vscode 7 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 4.1.0 2 | 3 | * Updates default param value syntax -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2017 Keith Elliott 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## ReCase ## 2 | 3 | Changes the case of the input text to the desire case convention. 4 | 5 | import 'package:recase/recase.dart'; 6 | 7 | void main() { 8 | ReCase rc = new ReCase('Just_someSample-text'); 9 | 10 | print(rc.camelCase); // Prints 'justSomeSampleText' 11 | print(rc.constantCase); // Prints 'JUST_SOME_SAMPLE_TEXT' 12 | } 13 | 14 | String extensions are also available. 15 | 16 | import 'package:recase/recase.dart'; 17 | 18 | void main() { 19 | String sample = 'Just_someSample-text'; 20 | 21 | print(sample.camelCase); // Prints 'justSomeSampleText' 22 | print(sample.constantCase); // Prints 'JUST_SOME_SAMPLE_TEXT' 23 | } 24 | _This feature is available in version 3.0.0, and requires at least Dart 2.6_ 25 | 26 | 27 | Supports: 28 | * snake_case 29 | * dot.case 30 | * path/case 31 | * param-case 32 | * PascalCase 33 | * Header-Case 34 | * Title Case 35 | * camelCase 36 | * Sentence case 37 | * CONSTANT_CASE 38 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # Lint rules and documentation, see http://dart-lang.github.io/linter/lints 2 | linter: 3 | rules: 4 | - prefer_equal_for_default_values 5 | 6 | -------------------------------------------------------------------------------- /lib/recase.dart: -------------------------------------------------------------------------------- 1 | /// An instance of text to be re-cased. 2 | class ReCase { 3 | final RegExp _upperAlphaRegex = RegExp(r'[A-Z]'); 4 | 5 | final symbolSet = {' ', '.', '/', '_', '\\', '-'}; 6 | 7 | late String originalText; 8 | late List _words; 9 | 10 | ReCase(String text) { 11 | this.originalText = text; 12 | this._words = _groupIntoWords(text); 13 | } 14 | 15 | List _groupIntoWords(String text) { 16 | StringBuffer sb = StringBuffer(); 17 | List words = []; 18 | bool isAllCaps = text.toUpperCase() == text; 19 | 20 | for (int i = 0; i < text.length; i++) { 21 | String char = text[i]; 22 | String? nextChar = i + 1 == text.length ? null : text[i + 1]; 23 | 24 | if (symbolSet.contains(char)) { 25 | continue; 26 | } 27 | 28 | sb.write(char); 29 | 30 | bool isEndOfWord = nextChar == null || 31 | (_upperAlphaRegex.hasMatch(nextChar) && !isAllCaps) || 32 | symbolSet.contains(nextChar); 33 | 34 | if (isEndOfWord) { 35 | words.add(sb.toString()); 36 | sb.clear(); 37 | } 38 | } 39 | 40 | return words; 41 | } 42 | 43 | /// camelCase 44 | String get camelCase => _getCamelCase(); 45 | 46 | /// CONSTANT_CASE 47 | String get constantCase => _getConstantCase(); 48 | 49 | /// Sentence case 50 | String get sentenceCase => _getSentenceCase(); 51 | 52 | /// snake_case 53 | String get snakeCase => _getSnakeCase(); 54 | 55 | /// dot.case 56 | String get dotCase => _getSnakeCase(separator: '.'); 57 | 58 | /// param-case 59 | String get paramCase => _getSnakeCase(separator: '-'); 60 | 61 | /// path/case 62 | String get pathCase => _getSnakeCase(separator: '/'); 63 | 64 | /// PascalCase 65 | String get pascalCase => _getPascalCase(); 66 | 67 | /// Header-Case 68 | String get headerCase => _getPascalCase(separator: '-'); 69 | 70 | /// Title Case 71 | String get titleCase => _getPascalCase(separator: ' '); 72 | 73 | String _getCamelCase({String separator = ''}) { 74 | List words = this._words.map(_upperCaseFirstLetter).toList(); 75 | if (_words.isNotEmpty) { 76 | words[0] = words[0].toLowerCase(); 77 | } 78 | 79 | return words.join(separator); 80 | } 81 | 82 | String _getConstantCase({String separator = '_'}) { 83 | List words = this._words.map((word) => word.toUpperCase()).toList(); 84 | 85 | return words.join(separator); 86 | } 87 | 88 | String _getPascalCase({String separator = ''}) { 89 | List words = this._words.map(_upperCaseFirstLetter).toList(); 90 | 91 | return words.join(separator); 92 | } 93 | 94 | String _getSentenceCase({String separator = ' '}) { 95 | List words = this._words.map((word) => word.toLowerCase()).toList(); 96 | if (_words.isNotEmpty) { 97 | words[0] = _upperCaseFirstLetter(words[0]); 98 | } 99 | 100 | return words.join(separator); 101 | } 102 | 103 | String _getSnakeCase({String separator = '_'}) { 104 | List words = this._words.map((word) => word.toLowerCase()).toList(); 105 | 106 | return words.join(separator); 107 | } 108 | 109 | String _upperCaseFirstLetter(String word) { 110 | return '${word.substring(0, 1).toUpperCase()}${word.substring(1).toLowerCase()}'; 111 | } 112 | } 113 | 114 | extension StringReCase on String { 115 | String get camelCase => ReCase(this).camelCase; 116 | 117 | String get constantCase => ReCase(this).constantCase; 118 | 119 | String get sentenceCase => ReCase(this).sentenceCase; 120 | 121 | String get snakeCase => ReCase(this).snakeCase; 122 | 123 | String get dotCase => ReCase(this).dotCase; 124 | 125 | String get paramCase => ReCase(this).paramCase; 126 | 127 | String get pathCase => ReCase(this).pathCase; 128 | 129 | String get pascalCase => ReCase(this).pascalCase; 130 | 131 | String get headerCase => ReCase(this).headerCase; 132 | 133 | String get titleCase => ReCase(this).titleCase; 134 | } 135 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | _fe_analyzer_shared: 5 | dependency: transitive 6 | description: 7 | name: _fe_analyzer_shared 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "18.0.0" 11 | analyzer: 12 | dependency: transitive 13 | description: 14 | name: analyzer 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "1.2.0" 18 | args: 19 | dependency: transitive 20 | description: 21 | name: args 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "2.0.0" 25 | async: 26 | dependency: transitive 27 | description: 28 | name: async 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "2.5.0" 32 | boolean_selector: 33 | dependency: transitive 34 | description: 35 | name: boolean_selector 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "2.1.0" 39 | charcode: 40 | dependency: transitive 41 | description: 42 | name: charcode 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.2.0" 46 | cli_util: 47 | dependency: transitive 48 | description: 49 | name: cli_util 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "0.3.0" 53 | collection: 54 | dependency: transitive 55 | description: 56 | name: collection 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "1.15.0" 60 | convert: 61 | dependency: transitive 62 | description: 63 | name: convert 64 | url: "https://pub.dartlang.org" 65 | source: hosted 66 | version: "3.0.0" 67 | coverage: 68 | dependency: transitive 69 | description: 70 | name: coverage 71 | url: "https://pub.dartlang.org" 72 | source: hosted 73 | version: "1.0.2" 74 | crypto: 75 | dependency: transitive 76 | description: 77 | name: crypto 78 | url: "https://pub.dartlang.org" 79 | source: hosted 80 | version: "3.0.0" 81 | file: 82 | dependency: transitive 83 | description: 84 | name: file 85 | url: "https://pub.dartlang.org" 86 | source: hosted 87 | version: "6.1.0" 88 | glob: 89 | dependency: transitive 90 | description: 91 | name: glob 92 | url: "https://pub.dartlang.org" 93 | source: hosted 94 | version: "2.0.0" 95 | http_multi_server: 96 | dependency: transitive 97 | description: 98 | name: http_multi_server 99 | url: "https://pub.dartlang.org" 100 | source: hosted 101 | version: "3.0.0" 102 | http_parser: 103 | dependency: transitive 104 | description: 105 | name: http_parser 106 | url: "https://pub.dartlang.org" 107 | source: hosted 108 | version: "4.0.0" 109 | io: 110 | dependency: transitive 111 | description: 112 | name: io 113 | url: "https://pub.dartlang.org" 114 | source: hosted 115 | version: "1.0.0" 116 | js: 117 | dependency: transitive 118 | description: 119 | name: js 120 | url: "https://pub.dartlang.org" 121 | source: hosted 122 | version: "0.6.3" 123 | logging: 124 | dependency: transitive 125 | description: 126 | name: logging 127 | url: "https://pub.dartlang.org" 128 | source: hosted 129 | version: "1.0.0" 130 | matcher: 131 | dependency: transitive 132 | description: 133 | name: matcher 134 | url: "https://pub.dartlang.org" 135 | source: hosted 136 | version: "0.12.10" 137 | meta: 138 | dependency: transitive 139 | description: 140 | name: meta 141 | url: "https://pub.dartlang.org" 142 | source: hosted 143 | version: "1.3.0" 144 | mime: 145 | dependency: transitive 146 | description: 147 | name: mime 148 | url: "https://pub.dartlang.org" 149 | source: hosted 150 | version: "1.0.0" 151 | node_preamble: 152 | dependency: transitive 153 | description: 154 | name: node_preamble 155 | url: "https://pub.dartlang.org" 156 | source: hosted 157 | version: "2.0.0" 158 | package_config: 159 | dependency: transitive 160 | description: 161 | name: package_config 162 | url: "https://pub.dartlang.org" 163 | source: hosted 164 | version: "2.0.0" 165 | path: 166 | dependency: transitive 167 | description: 168 | name: path 169 | url: "https://pub.dartlang.org" 170 | source: hosted 171 | version: "1.8.0" 172 | pedantic: 173 | dependency: transitive 174 | description: 175 | name: pedantic 176 | url: "https://pub.dartlang.org" 177 | source: hosted 178 | version: "1.11.0" 179 | pool: 180 | dependency: transitive 181 | description: 182 | name: pool 183 | url: "https://pub.dartlang.org" 184 | source: hosted 185 | version: "1.5.0" 186 | pub_semver: 187 | dependency: transitive 188 | description: 189 | name: pub_semver 190 | url: "https://pub.dartlang.org" 191 | source: hosted 192 | version: "2.0.0" 193 | shelf: 194 | dependency: transitive 195 | description: 196 | name: shelf 197 | url: "https://pub.dartlang.org" 198 | source: hosted 199 | version: "1.1.0" 200 | shelf_packages_handler: 201 | dependency: transitive 202 | description: 203 | name: shelf_packages_handler 204 | url: "https://pub.dartlang.org" 205 | source: hosted 206 | version: "3.0.0" 207 | shelf_static: 208 | dependency: transitive 209 | description: 210 | name: shelf_static 211 | url: "https://pub.dartlang.org" 212 | source: hosted 213 | version: "1.0.0" 214 | shelf_web_socket: 215 | dependency: transitive 216 | description: 217 | name: shelf_web_socket 218 | url: "https://pub.dartlang.org" 219 | source: hosted 220 | version: "1.0.1" 221 | source_map_stack_trace: 222 | dependency: transitive 223 | description: 224 | name: source_map_stack_trace 225 | url: "https://pub.dartlang.org" 226 | source: hosted 227 | version: "2.1.0" 228 | source_maps: 229 | dependency: transitive 230 | description: 231 | name: source_maps 232 | url: "https://pub.dartlang.org" 233 | source: hosted 234 | version: "0.10.10" 235 | source_span: 236 | dependency: transitive 237 | description: 238 | name: source_span 239 | url: "https://pub.dartlang.org" 240 | source: hosted 241 | version: "1.8.1" 242 | stack_trace: 243 | dependency: transitive 244 | description: 245 | name: stack_trace 246 | url: "https://pub.dartlang.org" 247 | source: hosted 248 | version: "1.10.0" 249 | stream_channel: 250 | dependency: transitive 251 | description: 252 | name: stream_channel 253 | url: "https://pub.dartlang.org" 254 | source: hosted 255 | version: "2.1.0" 256 | string_scanner: 257 | dependency: transitive 258 | description: 259 | name: string_scanner 260 | url: "https://pub.dartlang.org" 261 | source: hosted 262 | version: "1.1.0" 263 | term_glyph: 264 | dependency: transitive 265 | description: 266 | name: term_glyph 267 | url: "https://pub.dartlang.org" 268 | source: hosted 269 | version: "1.2.0" 270 | test: 271 | dependency: "direct dev" 272 | description: 273 | name: test 274 | url: "https://pub.dartlang.org" 275 | source: hosted 276 | version: "1.16.8" 277 | test_api: 278 | dependency: transitive 279 | description: 280 | name: test_api 281 | url: "https://pub.dartlang.org" 282 | source: hosted 283 | version: "0.3.0" 284 | test_core: 285 | dependency: transitive 286 | description: 287 | name: test_core 288 | url: "https://pub.dartlang.org" 289 | source: hosted 290 | version: "0.3.19" 291 | typed_data: 292 | dependency: transitive 293 | description: 294 | name: typed_data 295 | url: "https://pub.dartlang.org" 296 | source: hosted 297 | version: "1.3.0" 298 | vm_service: 299 | dependency: transitive 300 | description: 301 | name: vm_service 302 | url: "https://pub.dartlang.org" 303 | source: hosted 304 | version: "6.1.0+1" 305 | watcher: 306 | dependency: transitive 307 | description: 308 | name: watcher 309 | url: "https://pub.dartlang.org" 310 | source: hosted 311 | version: "1.0.0" 312 | web_socket_channel: 313 | dependency: transitive 314 | description: 315 | name: web_socket_channel 316 | url: "https://pub.dartlang.org" 317 | source: hosted 318 | version: "2.0.0" 319 | webkit_inspection_protocol: 320 | dependency: transitive 321 | description: 322 | name: webkit_inspection_protocol 323 | url: "https://pub.dartlang.org" 324 | source: hosted 325 | version: "1.0.0" 326 | yaml: 327 | dependency: transitive 328 | description: 329 | name: yaml 330 | url: "https://pub.dartlang.org" 331 | source: hosted 332 | version: "3.1.0" 333 | sdks: 334 | dart: ">=2.12.0 <3.0.0" 335 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: recase 2 | version: 4.1.0 3 | description: Changes the case of the input text to the desire case convention. 4 | homepage: https://github.com/techniboogie-dart/recase 5 | environment: 6 | sdk: '>=2.12.0 <3.0.0' 7 | dev_dependencies: 8 | test: '^1.16.8' 9 | -------------------------------------------------------------------------------- /test/recase_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:test/test.dart'; 2 | 3 | import 'package:recase/recase.dart'; 4 | 5 | void main() { 6 | String mockText = 'This is-Some_sampleText. YouDig?'; 7 | ReCase rcInput = ReCase(mockText); 8 | ReCase allCapsInput = ReCase('FOO_BAR'); 9 | 10 | group('snake_case', () { 11 | test('from empty string.', () { 12 | expect(''.snakeCase, equals('')); 13 | }); 14 | 15 | test('from "${rcInput.originalText}".', () { 16 | expect(rcInput.snakeCase, equals('this_is_some_sample_text_you_dig?')); 17 | }); 18 | 19 | test('from "${allCapsInput.originalText}".', () { 20 | expect(allCapsInput.snakeCase, equals('foo_bar')); 21 | }); 22 | 23 | test('from "${mockText}", using String extension.', () { 24 | expect(mockText.snakeCase, equals('this_is_some_sample_text_you_dig?')); 25 | }); 26 | }); 27 | 28 | group('dot.case', () { 29 | test('from empty string.', () { 30 | expect(''.dotCase, equals('')); 31 | }); 32 | 33 | test('from "${rcInput.originalText}".', () { 34 | expect(rcInput.dotCase, equals('this.is.some.sample.text.you.dig?')); 35 | }); 36 | 37 | test('from "${allCapsInput.originalText}".', () { 38 | expect(allCapsInput.dotCase, equals('foo.bar')); 39 | }); 40 | 41 | test('from "${mockText}", using String extension.', () { 42 | expect(mockText.dotCase, equals('this.is.some.sample.text.you.dig?')); 43 | }); 44 | }); 45 | 46 | group('path/case', () { 47 | test('from empty string.', () { 48 | expect(''.pathCase, equals('')); 49 | }); 50 | 51 | test('from "${rcInput.originalText}".', () { 52 | expect(rcInput.pathCase, equals('this/is/some/sample/text/you/dig?')); 53 | }); 54 | 55 | test('from "${allCapsInput.originalText}".', () { 56 | expect(allCapsInput.pathCase, equals('foo/bar')); 57 | }); 58 | 59 | test('from "${mockText}", using String extension.', () { 60 | expect(mockText.pathCase, equals('this/is/some/sample/text/you/dig?')); 61 | }); 62 | }); 63 | 64 | group('param-case', () { 65 | test('from empty string.', () { 66 | expect(''.paramCase, equals('')); 67 | }); 68 | 69 | test('from "${rcInput.originalText}".', () { 70 | expect(rcInput.paramCase, equals('this-is-some-sample-text-you-dig?')); 71 | }); 72 | 73 | test('from "${allCapsInput.originalText}".', () { 74 | expect(allCapsInput.paramCase, equals('foo-bar')); 75 | }); 76 | 77 | test('from "${mockText}", using String extension.', () { 78 | expect(mockText.paramCase, equals('this-is-some-sample-text-you-dig?')); 79 | }); 80 | }); 81 | 82 | group('PascalCase', () { 83 | test('from empty string.', () { 84 | expect(''.pascalCase, equals('')); 85 | }); 86 | 87 | test('from "${rcInput.originalText}".', () { 88 | expect(rcInput.pascalCase, equals('ThisIsSomeSampleTextYouDig?')); 89 | }); 90 | 91 | test('from "${allCapsInput.originalText}".', () { 92 | expect(allCapsInput.pascalCase, equals('FooBar')); 93 | }); 94 | 95 | test('from "${mockText}", using String extension.', () { 96 | expect(mockText.pascalCase, equals('ThisIsSomeSampleTextYouDig?')); 97 | }); 98 | }); 99 | 100 | group('Header-Case', () { 101 | test('from empty string.', () { 102 | expect(''.headerCase, equals('')); 103 | }); 104 | 105 | test('from "${rcInput.originalText}".', () { 106 | expect(rcInput.headerCase, equals('This-Is-Some-Sample-Text-You-Dig?')); 107 | }); 108 | 109 | test('from "${allCapsInput.originalText}".', () { 110 | expect(allCapsInput.headerCase, equals('Foo-Bar')); 111 | }); 112 | 113 | test('from "${mockText}", using String extension.', () { 114 | expect(mockText.headerCase, equals('This-Is-Some-Sample-Text-You-Dig?')); 115 | }); 116 | }); 117 | 118 | group('Title Case', () { 119 | test('from empty string.', () { 120 | expect(''.titleCase, equals('')); 121 | }); 122 | 123 | test('from "${rcInput.originalText}".', () { 124 | expect(rcInput.titleCase, equals('This Is Some Sample Text You Dig?')); 125 | }); 126 | 127 | test('from "${allCapsInput.originalText}".', () { 128 | expect(allCapsInput.titleCase, equals('Foo Bar')); 129 | }); 130 | 131 | test('from "${mockText}", using String extension.', () { 132 | expect(mockText.titleCase, equals('This Is Some Sample Text You Dig?')); 133 | }); 134 | }); 135 | 136 | group('camelCase', () { 137 | test('from empty string.', () { 138 | expect(''.camelCase, equals('')); 139 | }); 140 | 141 | test('from "${rcInput.originalText}".', () { 142 | expect(rcInput.camelCase, equals('thisIsSomeSampleTextYouDig?')); 143 | }); 144 | 145 | test('from "${allCapsInput.originalText}".', () { 146 | expect(allCapsInput.camelCase, equals('fooBar')); 147 | }); 148 | 149 | test('from "${mockText}", using String extension.', () { 150 | expect(mockText.camelCase, equals('thisIsSomeSampleTextYouDig?')); 151 | }); 152 | }); 153 | 154 | group('Sentence case', () { 155 | test('from empty string.', () { 156 | expect(''.sentenceCase, equals('')); 157 | }); 158 | 159 | test('from "${rcInput.originalText}".', () { 160 | expect(rcInput.sentenceCase, equals('This is some sample text you dig?')); 161 | }); 162 | 163 | test('from "${allCapsInput.originalText}".', () { 164 | expect(allCapsInput.sentenceCase, equals('Foo bar')); 165 | }); 166 | 167 | test('from "${mockText}", using String extension.', () { 168 | expect( 169 | mockText.sentenceCase, equals('This is some sample text you dig?')); 170 | }); 171 | }); 172 | 173 | group('CONSTANT_CASE', () { 174 | test('from empty string.', () { 175 | expect(''.constantCase, equals('')); 176 | }); 177 | 178 | test('from "${rcInput.originalText}".', () { 179 | expect(rcInput.constantCase, equals('THIS_IS_SOME_SAMPLE_TEXT_YOU_DIG?')); 180 | }); 181 | 182 | test('from "${allCapsInput.originalText}".', () { 183 | expect(allCapsInput.constantCase, equals('FOO_BAR')); 184 | }); 185 | 186 | test('from "${mockText}", using String extension.', () { 187 | expect( 188 | mockText.constantCase, equals('THIS_IS_SOME_SAMPLE_TEXT_YOU_DIG?')); 189 | }); 190 | }); 191 | } 192 | -------------------------------------------------------------------------------- /tool/perf.test.dart: -------------------------------------------------------------------------------- 1 | import 'package:recase/recase.dart'; 2 | 3 | void main() { 4 | final sw = Stopwatch()..start(); 5 | String? result = null; 6 | const N = 10000; 7 | for (var i = 0; i < N; i++) { 8 | result = ReCase('This is-Some_sampleText. YouDig?').titleCase; 9 | } 10 | print( 11 | 'done in ${sw.elapsedMilliseconds} (${sw.elapsedMilliseconds / N} ms. per iteration)'); 12 | print('$result'); 13 | } 14 | --------------------------------------------------------------------------------