@cdk8s/projen-common 0.0.237 → 0.0.239

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/.jsii +166 -70
  2. package/.projenrc.ts +17 -0
  3. package/API.md +6745 -54
  4. package/git-hooks/prepare-commit-msg +0 -0
  5. package/git-hooks/setup.sh +0 -0
  6. package/lib/index.d.ts +1 -37
  7. package/lib/index.js +12 -86
  8. package/lib/projects/index.d.ts +2 -0
  9. package/lib/projects/index.js +7 -0
  10. package/lib/projects/jsii.d.ts +48 -0
  11. package/lib/projects/jsii.js +71 -0
  12. package/lib/projects/typescript.d.ts +34 -0
  13. package/lib/projects/typescript.js +89 -0
  14. package/node_modules/codemaker/LICENSE +202 -0
  15. package/node_modules/codemaker/NOTICE +2 -0
  16. package/node_modules/codemaker/README.md +120 -0
  17. package/node_modules/codemaker/jest.config.mjs +3 -0
  18. package/node_modules/codemaker/lib/case-utils.d.ts +4 -0
  19. package/node_modules/codemaker/lib/case-utils.js +29 -0
  20. package/node_modules/codemaker/lib/codemaker.d.ts +107 -0
  21. package/node_modules/codemaker/lib/codemaker.js +164 -0
  22. package/node_modules/codemaker/lib/filebuff.d.ts +11 -0
  23. package/node_modules/codemaker/lib/filebuff.js +26 -0
  24. package/node_modules/codemaker/lib/index.d.ts +3 -0
  25. package/node_modules/codemaker/lib/index.js +19 -0
  26. package/node_modules/codemaker/node_modules/camelcase/index.d.ts +103 -0
  27. package/node_modules/codemaker/node_modules/camelcase/index.js +113 -0
  28. package/node_modules/codemaker/node_modules/camelcase/license +9 -0
  29. package/node_modules/codemaker/node_modules/camelcase/package.json +44 -0
  30. package/node_modules/codemaker/node_modules/camelcase/readme.md +144 -0
  31. package/node_modules/codemaker/package.json +41 -0
  32. package/node_modules/decamelize/index.d.ts +59 -0
  33. package/node_modules/decamelize/index.js +65 -0
  34. package/node_modules/decamelize/license +9 -0
  35. package/node_modules/decamelize/package.json +40 -0
  36. package/node_modules/decamelize/readme.md +92 -0
  37. package/node_modules/fs-extra/LICENSE +15 -0
  38. package/node_modules/fs-extra/README.md +262 -0
  39. package/node_modules/fs-extra/lib/copy/copy-sync.js +169 -0
  40. package/node_modules/fs-extra/lib/copy/copy.js +235 -0
  41. package/node_modules/fs-extra/lib/copy/index.js +7 -0
  42. package/node_modules/fs-extra/lib/empty/index.js +39 -0
  43. package/node_modules/fs-extra/lib/ensure/file.js +69 -0
  44. package/node_modules/fs-extra/lib/ensure/index.js +23 -0
  45. package/node_modules/fs-extra/lib/ensure/link.js +64 -0
  46. package/node_modules/fs-extra/lib/ensure/symlink-paths.js +99 -0
  47. package/node_modules/fs-extra/lib/ensure/symlink-type.js +31 -0
  48. package/node_modules/fs-extra/lib/ensure/symlink.js +82 -0
  49. package/node_modules/fs-extra/lib/fs/index.js +128 -0
  50. package/node_modules/fs-extra/lib/index.js +16 -0
  51. package/node_modules/fs-extra/lib/json/index.js +16 -0
  52. package/node_modules/fs-extra/lib/json/jsonfile.js +11 -0
  53. package/node_modules/fs-extra/lib/json/output-json-sync.js +12 -0
  54. package/node_modules/fs-extra/lib/json/output-json.js +12 -0
  55. package/node_modules/fs-extra/lib/mkdirs/index.js +14 -0
  56. package/node_modules/fs-extra/lib/mkdirs/make-dir.js +27 -0
  57. package/node_modules/fs-extra/lib/mkdirs/utils.js +21 -0
  58. package/node_modules/fs-extra/lib/move/index.js +7 -0
  59. package/node_modules/fs-extra/lib/move/move-sync.js +54 -0
  60. package/node_modules/fs-extra/lib/move/move.js +75 -0
  61. package/node_modules/fs-extra/lib/output-file/index.js +40 -0
  62. package/node_modules/fs-extra/lib/path-exists/index.js +12 -0
  63. package/node_modules/fs-extra/lib/remove/index.js +22 -0
  64. package/node_modules/fs-extra/lib/remove/rimraf.js +302 -0
  65. package/node_modules/fs-extra/lib/util/stat.js +154 -0
  66. package/node_modules/fs-extra/lib/util/utimes.js +26 -0
  67. package/node_modules/fs-extra/package.json +67 -0
  68. package/node_modules/graceful-fs/LICENSE +15 -0
  69. package/node_modules/graceful-fs/README.md +143 -0
  70. package/node_modules/graceful-fs/clone.js +23 -0
  71. package/node_modules/graceful-fs/graceful-fs.js +448 -0
  72. package/node_modules/graceful-fs/legacy-streams.js +118 -0
  73. package/node_modules/graceful-fs/package.json +50 -0
  74. package/node_modules/graceful-fs/polyfills.js +355 -0
  75. package/node_modules/jsonfile/CHANGELOG.md +171 -0
  76. package/node_modules/jsonfile/LICENSE +15 -0
  77. package/node_modules/jsonfile/README.md +230 -0
  78. package/node_modules/jsonfile/index.js +88 -0
  79. package/node_modules/jsonfile/package.json +40 -0
  80. package/node_modules/jsonfile/utils.js +14 -0
  81. package/node_modules/universalify/LICENSE +20 -0
  82. package/node_modules/universalify/README.md +76 -0
  83. package/node_modules/universalify/index.js +24 -0
  84. package/node_modules/universalify/package.json +34 -0
  85. package/package.json +17 -9
@@ -0,0 +1,113 @@
1
+ 'use strict';
2
+
3
+ const UPPERCASE = /[\p{Lu}]/u;
4
+ const LOWERCASE = /[\p{Ll}]/u;
5
+ const LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
6
+ const IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
7
+ const SEPARATORS = /[_.\- ]+/;
8
+
9
+ const LEADING_SEPARATORS = new RegExp('^' + SEPARATORS.source);
10
+ const SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, 'gu');
11
+ const NUMBERS_AND_IDENTIFIER = new RegExp('\\d+' + IDENTIFIER.source, 'gu');
12
+
13
+ const preserveCamelCase = (string, toLowerCase, toUpperCase) => {
14
+ let isLastCharLower = false;
15
+ let isLastCharUpper = false;
16
+ let isLastLastCharUpper = false;
17
+
18
+ for (let i = 0; i < string.length; i++) {
19
+ const character = string[i];
20
+
21
+ if (isLastCharLower && UPPERCASE.test(character)) {
22
+ string = string.slice(0, i) + '-' + string.slice(i);
23
+ isLastCharLower = false;
24
+ isLastLastCharUpper = isLastCharUpper;
25
+ isLastCharUpper = true;
26
+ i++;
27
+ } else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character)) {
28
+ string = string.slice(0, i - 1) + '-' + string.slice(i - 1);
29
+ isLastLastCharUpper = isLastCharUpper;
30
+ isLastCharUpper = false;
31
+ isLastCharLower = true;
32
+ } else {
33
+ isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
34
+ isLastLastCharUpper = isLastCharUpper;
35
+ isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
36
+ }
37
+ }
38
+
39
+ return string;
40
+ };
41
+
42
+ const preserveConsecutiveUppercase = (input, toLowerCase) => {
43
+ LEADING_CAPITAL.lastIndex = 0;
44
+
45
+ return input.replace(LEADING_CAPITAL, m1 => toLowerCase(m1));
46
+ };
47
+
48
+ const postProcess = (input, toUpperCase) => {
49
+ SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
50
+ NUMBERS_AND_IDENTIFIER.lastIndex = 0;
51
+
52
+ return input.replace(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier))
53
+ .replace(NUMBERS_AND_IDENTIFIER, m => toUpperCase(m));
54
+ };
55
+
56
+ const camelCase = (input, options) => {
57
+ if (!(typeof input === 'string' || Array.isArray(input))) {
58
+ throw new TypeError('Expected the input to be `string | string[]`');
59
+ }
60
+
61
+ options = {
62
+ pascalCase: false,
63
+ preserveConsecutiveUppercase: false,
64
+ ...options
65
+ };
66
+
67
+ if (Array.isArray(input)) {
68
+ input = input.map(x => x.trim())
69
+ .filter(x => x.length)
70
+ .join('-');
71
+ } else {
72
+ input = input.trim();
73
+ }
74
+
75
+ if (input.length === 0) {
76
+ return '';
77
+ }
78
+
79
+ const toLowerCase = options.locale === false ?
80
+ string => string.toLowerCase() :
81
+ string => string.toLocaleLowerCase(options.locale);
82
+ const toUpperCase = options.locale === false ?
83
+ string => string.toUpperCase() :
84
+ string => string.toLocaleUpperCase(options.locale);
85
+
86
+ if (input.length === 1) {
87
+ return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
88
+ }
89
+
90
+ const hasUpperCase = input !== toLowerCase(input);
91
+
92
+ if (hasUpperCase) {
93
+ input = preserveCamelCase(input, toLowerCase, toUpperCase);
94
+ }
95
+
96
+ input = input.replace(LEADING_SEPARATORS, '');
97
+
98
+ if (options.preserveConsecutiveUppercase) {
99
+ input = preserveConsecutiveUppercase(input, toLowerCase);
100
+ } else {
101
+ input = toLowerCase(input);
102
+ }
103
+
104
+ if (options.pascalCase) {
105
+ input = toUpperCase(input.charAt(0)) + input.slice(1);
106
+ }
107
+
108
+ return postProcess(input, toUpperCase);
109
+ };
110
+
111
+ module.exports = camelCase;
112
+ // TODO: Remove this for the next major release
113
+ module.exports.default = camelCase;
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "camelcase",
3
+ "version": "6.3.0",
4
+ "description": "Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/camelcase",
7
+ "funding": "https://github.com/sponsors/sindresorhus",
8
+ "author": {
9
+ "name": "Sindre Sorhus",
10
+ "email": "sindresorhus@gmail.com",
11
+ "url": "https://sindresorhus.com"
12
+ },
13
+ "engines": {
14
+ "node": ">=10"
15
+ },
16
+ "scripts": {
17
+ "test": "xo && ava && tsd"
18
+ },
19
+ "files": [
20
+ "index.js",
21
+ "index.d.ts"
22
+ ],
23
+ "keywords": [
24
+ "camelcase",
25
+ "camel-case",
26
+ "camel",
27
+ "case",
28
+ "dash",
29
+ "hyphen",
30
+ "dot",
31
+ "underscore",
32
+ "separator",
33
+ "string",
34
+ "text",
35
+ "convert",
36
+ "pascalcase",
37
+ "pascal-case"
38
+ ],
39
+ "devDependencies": {
40
+ "ava": "^1.4.1",
41
+ "tsd": "^0.11.0",
42
+ "xo": "^0.28.3"
43
+ }
44
+ }
@@ -0,0 +1,144 @@
1
+ # camelcase
2
+
3
+ > Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`
4
+
5
+ Correctly handles Unicode strings.
6
+
7
+ If you use this on untrusted user input, don't forget to limit the length to something reasonable.
8
+
9
+ ## Install
10
+
11
+ ```
12
+ $ npm install camelcase
13
+ ```
14
+
15
+ *If you need to support Firefox < 78, stay on version 5 as version 6 uses regex features not available in Firefox < 78.*
16
+
17
+ ## Usage
18
+
19
+ ```js
20
+ const camelCase = require('camelcase');
21
+
22
+ camelCase('foo-bar');
23
+ //=> 'fooBar'
24
+
25
+ camelCase('foo_bar');
26
+ //=> 'fooBar'
27
+
28
+ camelCase('Foo-Bar');
29
+ //=> 'fooBar'
30
+
31
+ camelCase('розовый_пушистый_единорог');
32
+ //=> 'розовыйПушистыйЕдинорог'
33
+
34
+ camelCase('Foo-Bar', {pascalCase: true});
35
+ //=> 'FooBar'
36
+
37
+ camelCase('--foo.bar', {pascalCase: false});
38
+ //=> 'fooBar'
39
+
40
+ camelCase('Foo-BAR', {preserveConsecutiveUppercase: true});
41
+ //=> 'fooBAR'
42
+
43
+ camelCase('fooBAR', {pascalCase: true, preserveConsecutiveUppercase: true}));
44
+ //=> 'FooBAR'
45
+
46
+ camelCase('foo bar');
47
+ //=> 'fooBar'
48
+
49
+ console.log(process.argv[3]);
50
+ //=> '--foo-bar'
51
+ camelCase(process.argv[3]);
52
+ //=> 'fooBar'
53
+
54
+ camelCase(['foo', 'bar']);
55
+ //=> 'fooBar'
56
+
57
+ camelCase(['__foo__', '--bar'], {pascalCase: true});
58
+ //=> 'FooBar'
59
+
60
+ camelCase(['foo', 'BAR'], {pascalCase: true, preserveConsecutiveUppercase: true})
61
+ //=> 'FooBAR'
62
+
63
+ camelCase('lorem-ipsum', {locale: 'en-US'});
64
+ //=> 'loremIpsum'
65
+ ```
66
+
67
+ ## API
68
+
69
+ ### camelCase(input, options?)
70
+
71
+ #### input
72
+
73
+ Type: `string | string[]`
74
+
75
+ String to convert to camel case.
76
+
77
+ #### options
78
+
79
+ Type: `object`
80
+
81
+ ##### pascalCase
82
+
83
+ Type: `boolean`\
84
+ Default: `false`
85
+
86
+ Uppercase the first character: `foo-bar` → `FooBar`
87
+
88
+ ##### preserveConsecutiveUppercase
89
+
90
+ Type: `boolean`\
91
+ Default: `false`
92
+
93
+ Preserve the consecutive uppercase characters: `foo-BAR` → `FooBAR`.
94
+
95
+ ##### locale
96
+
97
+ Type: `false | string | string[]`\
98
+ Default: The host environment’s current locale.
99
+
100
+ The locale parameter indicates the locale to be used to convert to upper/lower case according to any locale-specific case mappings. If multiple locales are given in an array, the best available locale is used.
101
+
102
+ ```js
103
+ const camelCase = require('camelcase');
104
+
105
+ camelCase('lorem-ipsum', {locale: 'en-US'});
106
+ //=> 'loremIpsum'
107
+
108
+ camelCase('lorem-ipsum', {locale: 'tr-TR'});
109
+ //=> 'loremİpsum'
110
+
111
+ camelCase('lorem-ipsum', {locale: ['en-US', 'en-GB']});
112
+ //=> 'loremIpsum'
113
+
114
+ camelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']});
115
+ //=> 'loremİpsum'
116
+ ```
117
+
118
+ Setting `locale: false` ignores the platform locale and uses the [Unicode Default Case Conversion](https://unicode-org.github.io/icu/userguide/transforms/casemappings.html#simple-single-character-case-mapping) algorithm:
119
+
120
+ ```js
121
+ const camelCase = require('camelcase');
122
+
123
+ // On a platform with 'tr-TR'
124
+
125
+ camelCase('lorem-ipsum');
126
+ //=> 'loremİpsum'
127
+
128
+ camelCase('lorem-ipsum', {locale: false});
129
+ //=> 'loremIpsum'
130
+ ```
131
+
132
+ ## camelcase for enterprise
133
+
134
+ Available as part of the Tidelift Subscription.
135
+
136
+ The maintainers of camelcase and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-camelcase?utm_source=npm-camelcase&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
137
+
138
+ ## Related
139
+
140
+ - [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module
141
+ - [uppercamelcase](https://github.com/SamVerschueren/uppercamelcase) - Like this module, but to PascalCase instead of camelCase
142
+ - [titleize](https://github.com/sindresorhus/titleize) - Capitalize every word in string
143
+ - [humanize-string](https://github.com/sindresorhus/humanize-string) - Convert a camelized/dasherized/underscored string into a humanized one
144
+ - [camelcase-keys](https://github.com/sindresorhus/camelcase-keys) - Convert object keys to camel case
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "codemaker",
3
+ "version": "1.74.0",
4
+ "description": "A tiny utility for generating source code",
5
+ "license": "Apache-2.0",
6
+ "author": {
7
+ "name": "Amazon Web Services",
8
+ "url": "https://aws.amazon.com"
9
+ },
10
+ "homepage": "https://github.com/aws/jsii",
11
+ "bugs": {
12
+ "url": "https://github.com/aws/jsii/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/aws/jsii.git",
17
+ "directory": "packages/codemaker"
18
+ },
19
+ "engines": {
20
+ "node": ">= 14.6.0"
21
+ },
22
+ "main": "lib/index.js",
23
+ "types": "lib/index.d.ts",
24
+ "scripts": {
25
+ "build": "tsc --build && npm run lint",
26
+ "watch": "tsc --build -w",
27
+ "lint": "eslint . --ext .js,.ts --ignore-path=.gitignore",
28
+ "lint:fix": "yarn lint --fix",
29
+ "test": "jest",
30
+ "test:update": "jest -u",
31
+ "package": "rm -fr dist/js && mkdir -p dist/js && mv $(npm pack) dist/js"
32
+ },
33
+ "dependencies": {
34
+ "camelcase": "^6.3.0",
35
+ "decamelize": "^5.0.1",
36
+ "fs-extra": "^10.1.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/fs-extra": "^9.0.13"
40
+ }
41
+ }
@@ -0,0 +1,59 @@
1
+ declare namespace decamelize {
2
+ interface Options {
3
+ /**
4
+ Character or string inserted to separate words in `string`.
5
+
6
+ @default '_'
7
+
8
+ @example
9
+ ```
10
+ import decamelize = require('decamelize');
11
+
12
+ decamelize('unicornRainbow');
13
+ //=> 'unicorn_rainbow'
14
+
15
+ decamelize('unicornRainbow', {separator: '-'});
16
+ //=> 'unicorn-rainbow'
17
+ ```
18
+ */
19
+ readonly separator?: string;
20
+
21
+ /**
22
+ Preserve sequences of uppercase characters.
23
+
24
+ @default false
25
+
26
+ @example
27
+ ```
28
+ import decamelize = require('decamelize');
29
+
30
+ decamelize('testGUILabel');
31
+ //=> 'test_gui_label'
32
+
33
+ decamelize('testGUILabel', {preserveConsecutiveUppercase: true});
34
+ //=> 'test_GUI_label'
35
+ ```
36
+ */
37
+ readonly preserveConsecutiveUppercase?: boolean;
38
+ }
39
+ }
40
+
41
+ /**
42
+ Convert a camelized string into a lowercased one with a custom separator: `unicornRainbow` → `unicorn_rainbow`.
43
+
44
+ @param string - The camelcase string to decamelize.
45
+
46
+ @example
47
+ ```
48
+ import decamelize = require('decamelize');
49
+
50
+ decamelize('unicornRainbow');
51
+ //=> 'unicorn_rainbow'
52
+
53
+ decamelize('unicornRainbow', {separator: '-'});
54
+ //=> 'unicorn-rainbow'
55
+ ```
56
+ */
57
+ declare function decamelize(string: string, options?: decamelize.Options): string;
58
+
59
+ export = decamelize;
@@ -0,0 +1,65 @@
1
+ 'use strict';
2
+
3
+ const handlePreserveConsecutiveUppercase = (decamelized, separator) => {
4
+ // Lowercase all single uppercase characters. As we
5
+ // want to preserve uppercase sequences, we cannot
6
+ // simply lowercase the separated string at the end.
7
+ // `data_For_USACounties` → `data_for_USACounties`
8
+ decamelized = decamelized.replace(
9
+ /((?<![\p{Uppercase_Letter}\d])[\p{Uppercase_Letter}\d](?![\p{Uppercase_Letter}\d]))/gu,
10
+ $0 => {
11
+ return $0.toLowerCase();
12
+ }
13
+ );
14
+
15
+ // Remaining uppercase sequences will be separated from lowercase sequences.
16
+ // `data_For_USACounties` → `data_for_USA_counties`
17
+ return decamelized.replace(
18
+ /(\p{Uppercase_Letter}+)(\p{Uppercase_Letter}\p{Lowercase_Letter}+)/gu,
19
+ (_, $1, $2) => {
20
+ return $1 + separator + $2.toLowerCase();
21
+ }
22
+ );
23
+ };
24
+
25
+ module.exports = (
26
+ text,
27
+ {
28
+ separator = '_',
29
+ preserveConsecutiveUppercase = false
30
+ } = {}
31
+ ) => {
32
+ if (!(typeof text === 'string' && typeof separator === 'string')) {
33
+ throw new TypeError(
34
+ 'The `text` and `separator` arguments should be of type `string`'
35
+ );
36
+ }
37
+
38
+ // Checking the second character is done later on. Therefore process shorter strings here.
39
+ if (text.length < 2) {
40
+ return preserveConsecutiveUppercase ? text : text.toLowerCase();
41
+ }
42
+
43
+ const replacement = `$1${separator}$2`;
44
+
45
+ // Split lowercase sequences followed by uppercase character.
46
+ // `dataForUSACounties` → `data_For_USACounties`
47
+ // `myURLstring → `my_URLstring`
48
+ const decamelized = text.replace(
49
+ /([\p{Lowercase_Letter}\d])(\p{Uppercase_Letter})/gu,
50
+ replacement
51
+ );
52
+
53
+ if (preserveConsecutiveUppercase) {
54
+ return handlePreserveConsecutiveUppercase(decamelized, separator);
55
+ }
56
+
57
+ // Split multiple uppercase characters followed by one or more lowercase characters.
58
+ // `my_URLstring` → `my_url_string`
59
+ return decamelized
60
+ .replace(
61
+ /(\p{Uppercase_Letter})(\p{Uppercase_Letter}\p{Lowercase_Letter}+)/gu,
62
+ replacement
63
+ )
64
+ .toLowerCase();
65
+ };
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "decamelize",
3
+ "version": "5.0.1",
4
+ "description": "Convert a camelized string into a lowercased one with a custom separator: unicornRainbow → unicorn_rainbow",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/decamelize",
7
+ "funding": "https://github.com/sponsors/sindresorhus",
8
+ "author": {
9
+ "name": "Sindre Sorhus",
10
+ "email": "sindresorhus@gmail.com",
11
+ "url": "https://sindresorhus.com"
12
+ },
13
+ "engines": {
14
+ "node": ">=10"
15
+ },
16
+ "scripts": {
17
+ "test": "xo && ava && tsd"
18
+ },
19
+ "files": [
20
+ "index.js",
21
+ "index.d.ts"
22
+ ],
23
+ "keywords": [
24
+ "decamelize",
25
+ "decamelcase",
26
+ "camelcase",
27
+ "lowercase",
28
+ "case",
29
+ "dash",
30
+ "hyphen",
31
+ "string",
32
+ "text",
33
+ "convert"
34
+ ],
35
+ "devDependencies": {
36
+ "ava": "^2.4.0",
37
+ "tsd": "^0.11.0",
38
+ "xo": "^0.24.0"
39
+ }
40
+ }
@@ -0,0 +1,92 @@
1
+ # decamelize
2
+
3
+ > Convert a camelized string into a lowercased one with a custom separator\
4
+ > Example: `unicornRainbow` → `unicorn_rainbow`
5
+
6
+ If you use this on untrusted user input, don't forget to limit the length to something reasonable.
7
+
8
+ ## Install
9
+
10
+ ```
11
+ $ npm install decamelize
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```js
17
+ const decamelize = require('decamelize');
18
+
19
+ decamelize('unicornRainbow');
20
+ //=> 'unicorn_rainbow'
21
+
22
+ decamelize('unicornRainbow', {separator: '-'});
23
+ //=> 'unicorn-rainbow'
24
+
25
+ decamelize('testGUILabel', {preserveConsecutiveUppercase: true});
26
+ //=> 'test_GUI_label'
27
+
28
+ decamelize('testGUILabel', {preserveConsecutiveUppercase: false});
29
+ //=> 'test_gui_label'
30
+ ```
31
+
32
+ ## API
33
+
34
+ ### decamelize(input, options?)
35
+
36
+ #### input
37
+
38
+ Type: `string`
39
+
40
+ #### options
41
+
42
+ Type: `object`
43
+
44
+ ##### separator
45
+
46
+ Type: `string`\
47
+ Default: `'_'`
48
+
49
+ Character or string inserted to separate words in `string`.
50
+
51
+ ```js
52
+ cosnt decamelize = require('decamelize');
53
+
54
+ decamelize('unicornRainbow');
55
+ //=> 'unicorn_rainbow'
56
+
57
+ decamelize('unicornRainbow', {separator: '-'});
58
+ //=> 'unicorn-rainbow'
59
+ ```
60
+
61
+ ##### preserveConsecutiveUppercase
62
+
63
+ Type: `boolean`\
64
+ Default: `false`
65
+
66
+ Preserve sequences of uppercase characters.
67
+
68
+ ```js
69
+ const decamelize = require('decamelize');
70
+
71
+ decamelize('testGUILabel');
72
+ //=> 'test_gui_label'
73
+
74
+ decamelize('testGUILabel', {preserveConsecutiveUppercase: true});
75
+ //=> 'test_GUI_label'
76
+ ```
77
+
78
+ ## Related
79
+
80
+ See [`camelcase`](https://github.com/sindresorhus/camelcase) for the inverse.
81
+
82
+ ---
83
+
84
+ <div align="center">
85
+ <b>
86
+ <a href="https://tidelift.com/subscription/pkg/npm-decamelize?utm_source=npm-decamelize&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
87
+ </b>
88
+ <br>
89
+ <sub>
90
+ Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
91
+ </sub>
92
+ </div>
@@ -0,0 +1,15 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2011-2017 JP Richardson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
6
+ (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
7
+ merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
14
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
15
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.