@trenskow/caseit 1.1.2 → 1.2.0

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 (2) hide show
  1. package/index.js +11 -3
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -7,15 +7,17 @@ const separators = {
7
7
  'domain': '.',
8
8
  'kebab': '-',
9
9
  'title': ' ',
10
- 'http': '-'
10
+ 'http': '-',
11
+ 'lower': '',
12
+ 'upper': ''
11
13
  };
12
14
 
13
- const supported = Object.keys(separators);
15
+ const supported = Object.keys(separators).sort();
14
16
 
15
17
  module.exports = exports = function(input, type = 'camel') {
16
18
 
17
19
  if (!supported.includes(type)) {
18
- throw new TypeError('Type must either be `camel`, `pascal`, `snake`, `domain`, `kebab`, `title`, `http`.');
20
+ throw new TypeError(`Type must either be ${supported.slice(0, -1).join(', ')} or ${supported.slice(-1)[0]}.`);
19
21
  }
20
22
 
21
23
  const words = exports.words(input)
@@ -35,8 +37,12 @@ module.exports = exports = function(input, type = 'camel') {
35
37
  // fallthrough
36
38
  case 'kebab':
37
39
  // fallthrough
40
+ case 'lower':
41
+ // fallthrough
38
42
  case 'snake':
39
43
  return key.toLowerCase();
44
+ case 'upper':
45
+ return key.toUpperCase();
40
46
  }
41
47
  });
42
48
 
@@ -53,3 +59,5 @@ exports.detect = function(input) {
53
59
  return supported
54
60
  .filter((type) => exports(input, type) === input);
55
61
  };
62
+
63
+ exports.supported = supported;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trenskow/caseit",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "Small library for converting between different casing.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,6 +22,6 @@
22
22
  },
23
23
  "homepage": "https://github.com/trenskow/caseit#readme",
24
24
  "devDependencies": {
25
- "eslint": "^8.2.0"
25
+ "eslint": "^8.13.0"
26
26
  }
27
27
  }