@clerc/utils 0.25.1 → 0.27.1

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.
package/dist/index.js CHANGED
@@ -1,32 +1 @@
1
- const toArray = (a) => Array.isArray(a) ? a : [a];
2
- const camelCase = (s) => s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
3
- const kebabCase = (s) => s.replace(/([A-Z])/g, (_, c) => `-${c.toLowerCase()}`);
4
- const gracefulFlagName = (n) => n.length <= 1 ? `-${n}` : `--${kebabCase(n)}`;
5
- const gracefulVersion = (v) => v.length === 0 ? "" : v.startsWith("v") ? v : `v${v}`;
6
- const arrayEquals = (arr1, arr2) => {
7
- if (arr2.length !== arr1.length) {
8
- return false;
9
- }
10
- return arr1.every((item, i) => item === arr2[i]);
11
- };
12
- const arrayStartsWith = (arr, start) => {
13
- if (start.length > arr.length) {
14
- return false;
15
- }
16
- return arrayEquals(arr.slice(0, start.length), start);
17
- };
18
- const generateCommandRecordFromCommandArray = (commands) => {
19
- const record = {};
20
- for (const command of commands) {
21
- record[command.name] = command;
22
- }
23
- return record;
24
- };
25
- const semanticArray = (arr) => {
26
- if (arr.length <= 1) {
27
- return arr[0];
28
- }
29
- return `${arr.slice(0, -1).join(", ")} and ${arr[arr.length - 1]}`;
30
- };
31
-
32
- export { arrayEquals, arrayStartsWith, camelCase, generateCommandRecordFromCommandArray, gracefulFlagName, gracefulVersion, kebabCase, semanticArray, toArray };
1
+ const a=e=>Array.isArray(e)?e:[e],c=e=>e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase()),r=e=>e.replace(/([A-Z])/g,(t,n)=>`-${n.toLowerCase()}`),l=e=>e.length<=1?`-${e}`:`--${r(e)}`,g=e=>e.length===0?"":e.startsWith("v")?e:`v${e}`,o=(e,t)=>t.length!==e.length?!1:e.every((n,s)=>n===t[s]),h=(e,t)=>t.length>e.length?!1:o(e.slice(0,t.length),t),i=e=>{const t={};for(const n of e)t[n.name]=n;return t},m=e=>e.length<=1?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;export{o as arrayEquals,h as arrayStartsWith,c as camelCase,i as generateCommandRecordFromCommandArray,l as gracefulFlagName,g as gracefulVersion,r as kebabCase,m as semanticArray,a as toArray};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clerc/utils",
3
- "version": "0.25.1",
3
+ "version": "0.27.1",
4
4
  "author": "Ray <nn_201312@163.com> (https://github.com/so1ve)",
5
5
  "description": "Clerc utils",
6
6
  "keywords": [
@@ -29,11 +29,11 @@
29
29
  "exports": {
30
30
  ".": {
31
31
  "types": "./dist/index.d.ts",
32
- "import": "./dist/index.mjs"
32
+ "import": "./dist/index.js"
33
33
  }
34
34
  },
35
35
  "main": "dist/index.js",
36
- "module": "dist/index.mjs",
36
+ "module": "dist/index.js",
37
37
  "types": "dist/index.d.ts",
38
38
  "files": [
39
39
  "dist"
@@ -44,11 +44,11 @@
44
44
  "peerDependencies": {
45
45
  "@clerc/core": "*"
46
46
  },
47
- "dependencies": {
47
+ "devDependencies": {
48
48
  "type-fest": "^3.5.3"
49
49
  },
50
50
  "scripts": {
51
- "build": "puild",
51
+ "build": "puild --minify",
52
52
  "watch": "puild --watch"
53
53
  }
54
54
  }
package/dist/index.mjs DELETED
@@ -1,32 +0,0 @@
1
- const toArray = (a) => Array.isArray(a) ? a : [a];
2
- const camelCase = (s) => s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
3
- const kebabCase = (s) => s.replace(/([A-Z])/g, (_, c) => `-${c.toLowerCase()}`);
4
- const gracefulFlagName = (n) => n.length <= 1 ? `-${n}` : `--${kebabCase(n)}`;
5
- const gracefulVersion = (v) => v.length === 0 ? "" : v.startsWith("v") ? v : `v${v}`;
6
- const arrayEquals = (arr1, arr2) => {
7
- if (arr2.length !== arr1.length) {
8
- return false;
9
- }
10
- return arr1.every((item, i) => item === arr2[i]);
11
- };
12
- const arrayStartsWith = (arr, start) => {
13
- if (start.length > arr.length) {
14
- return false;
15
- }
16
- return arrayEquals(arr.slice(0, start.length), start);
17
- };
18
- const generateCommandRecordFromCommandArray = (commands) => {
19
- const record = {};
20
- for (const command of commands) {
21
- record[command.name] = command;
22
- }
23
- return record;
24
- };
25
- const semanticArray = (arr) => {
26
- if (arr.length <= 1) {
27
- return arr[0];
28
- }
29
- return `${arr.slice(0, -1).join(", ")} and ${arr[arr.length - 1]}`;
30
- };
31
-
32
- export { arrayEquals, arrayStartsWith, camelCase, generateCommandRecordFromCommandArray, gracefulFlagName, gracefulVersion, kebabCase, semanticArray, toArray };