@leexi/shared 0.3.6 → 0.3.7

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.
@@ -2,18 +2,19 @@ type SetRecord<T extends Record<string, unknown>, P extends readonly string[], V
2
2
  [K in F]: R extends [] ? V : SetRecord<T[K] extends T ? T[K] : {}, R, V>;
3
3
  } : T;
4
4
  /**
5
- * Deeply sets an attribute at a specified path within a nested object.
6
- * **This method is destructive.**
5
+ * Sets a value within a nested object structure based on a provided path.
6
+ * It mutates the original object and creates nested objects if they don't exist along the path.
7
7
  *
8
- * @param record - a record
9
- * @param path - an array of strings leading to a deeply nested key in the record
10
- * @param value - a value to be set at the given path
11
- * @returns the mutated record
8
+ * @param record The object within which to set the value.
9
+ * @param path An array of strings representing the path to the desired property.
10
+ * @param value The value to set at the specified path.
11
+ * @returns The modified object with the value set at the specified path.
12
12
  *
13
13
  * @example
14
- * const foo = {}
15
- * set(foo, ['bar', 'biz'], 'fiz')
16
- * foo // => { bar: { biz: 'fiz' } }
14
+ * const myObject = { a: { b: { c: 1 } } };
15
+ * set(myObject, ['a', 'b', 'd'], 2);
16
+ *
17
+ * console.log(myObject); // Output: { a: { b: { c: 1, d: 2 } } }
17
18
  */
18
19
  export declare const set: <T extends Record<string, unknown>, const P extends string[], V>(record: T, path: P, value: V) => SetRecord<T, P, V>;
19
20
  export {};
@@ -1,8 +1,12 @@
1
1
  /**
2
- * Convert a kebab-case string or a snake_case string to a camelCase string
2
+ * Converts a string from snake_case or kebab-case to camelCase.
3
+ *
4
+ * @param string The input string to convert.
5
+ * @returns The camelCased string.
3
6
  *
4
7
  * @example
5
- * camelcase('foo_bar') // => 'fooBar'
6
- * camelcase('foo-bar') // => 'fooBar'
8
+ * console.log(camelcase('my_variable_name')); // Output: myVariableName
9
+ * console.log(camelcase('my-variable-name')); // Output: myVariableName
10
+ * console.log(camelcase('myVariable')); // Output: myVariable
7
11
  */
8
12
  export declare const camelcase: (string: string) => string;
@@ -1 +1 @@
1
- export const camelcase = (string) => string.replaceAll(/[-_][a-z]/g, (char) => char.toUpperCase().replace("_", "").replace("-", ""));
1
+ export const camelcase = (string) => string.replace(/^[A-Z]/, (char) => char.toLowerCase()).replaceAll(/[-_ ][a-z]/g, (char) => char.toUpperCase().replace(/[-_ ]/, ""));
@@ -1,7 +1,11 @@
1
1
  /**
2
- * Capitalizes a string
2
+ * Capitalizes the first letter of a string.
3
+ *
4
+ * @param string The input string. Defaults to an empty string if not provided.
5
+ * @returns The string with the first letter capitalized.
3
6
  *
4
7
  * @example
5
- * capitalize('foo') // => 'Foo'
8
+ * console.log(capitalize('hello world')); // Output: Hello world
9
+ * console.log(capitalize('')); // Output: ''
6
10
  */
7
- export declare const capitalize: (string?: string) => string;
11
+ export declare const capitalize: (string: string) => string;
@@ -1 +1 @@
1
- export const capitalize = (string = "") => `${string.charAt(0).toUpperCase()}${string.slice(1)}`;
1
+ export const capitalize = (string) => `${string.charAt(0).toUpperCase()}${string.slice(1)}`;
@@ -1,8 +1,12 @@
1
1
  /**
2
- * Convert a camelCase string or a snake_case string to a kebab-case string
2
+ * Converts a string from camelCase or snake_case to kebab-case.
3
+ *
4
+ * @param string The input string to convert.
5
+ * @returns The kebab-cased string.
3
6
  *
4
7
  * @example
5
- * kebabcase('fooBar') // => 'foo-bar'
6
- * kebabcase('foo_bar') // => 'foo-bar'
8
+ * console.log(kebabcase('myVariableName')); // Output: my-variable-name
9
+ * console.log(kebabcase('my_variable_name')); // Output: my-variable-name
10
+ * console.log(kebabcase('my-variable-name')); // Output: my-variable-name
7
11
  */
8
12
  export declare const kebabcase: (string: string) => string;
@@ -1 +1 @@
1
- export const kebabcase = (string) => string.replaceAll(/[A-Z]|_[a-z]/g, (char) => `-${char.toLowerCase().replace("_", "")}`);
1
+ export const kebabcase = (string) => string.replaceAll(/[A-Z]|[_ ][a-z]/g, (char) => `-${char.toLowerCase().replace(/[_ ]/, "")}`).replace(/^-/, "");
@@ -1,8 +1,12 @@
1
1
  /**
2
- * Convert a camelCase string or a kebab-case string to a snake_case string
2
+ * Converts a string from camelCase or kebab-case to snake_case.
3
+ *
4
+ * @param string The input string to convert.
5
+ * @returns The snake-cased string.
3
6
  *
4
7
  * @example
5
- * snakecase('fooBar') // => 'foo_bar'
6
- * snakecase('foo-bar') // => 'foo_bar'
8
+ * console.log(snakecase('myVariableName')); // Output: my_variable_name
9
+ * console.log(snakecase('my-variable-name')); // Output: my_variable_name
10
+ * console.log(snakecase('my_variable_name')); // Output: my_variable_name
7
11
  */
8
12
  export declare const snakecase: (string: string) => string;
@@ -1 +1 @@
1
- export const snakecase = (string) => string.replaceAll(/[A-Z]|-[a-z]/g, (char) => `_${char.toLowerCase().replace("-", "")}`);
1
+ export const snakecase = (string) => string.replaceAll(/[A-Z]|[- ][a-z]/g, (char) => `_${char.toLowerCase().replace(/[- ]/, "")}`).replace(/^_/, "");
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "license": "UNLICENSED",
3
3
  "name": "@leexi/shared",
4
4
  "type": "module",
5
- "version": "0.3.6",
5
+ "version": "0.3.7",
6
6
  "exports": {
7
7
  "./composables": {
8
8
  "import": "./dist/runtime/composables/index.js",
@@ -41,30 +41,29 @@
41
41
  "dev": "nuxi dev playground",
42
42
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
43
43
  "lint": "eslint .",
44
- "prepack": "yarn lint && yarn test --reporter default && yarn tsc && yarn build",
44
+ "prepack": "yarn dev:prepare && yarn lint && yarn tsc && yarn test --reporter default && yarn build",
45
45
  "test": "vitest run",
46
46
  "tsc": "vue-tsc --noEmit"
47
47
  },
48
48
  "dependencies": {
49
- "@stylistic/eslint-plugin-js": "^4.2.0",
50
- "@stylistic/eslint-plugin-ts": "^4.2.0",
49
+ "@stylistic/eslint-plugin": "^4.4.0",
51
50
  "@types/eslint-plugin-tailwindcss": "^3.17.0",
52
- "eslint": "^9.25.1",
51
+ "eslint": "^9.28.0",
53
52
  "eslint-plugin-tailwindcss": "^3.18.0",
54
53
  "eslint-plugin-vue": "^10.1.0",
55
- "globals": "^16.0.0",
54
+ "globals": "^16.2.0",
56
55
  "typescript": "^5.8.3",
57
- "typescript-eslint": "^8.31.1",
56
+ "typescript-eslint": "^8.33.0",
58
57
  "vue-eslint-parser": "^10.1.3"
59
58
  },
60
59
  "devDependencies": {
61
60
  "@nuxt/module-builder": "^1.0.1",
62
- "@nuxt/test-utils": "^3.17.2",
63
- "@types/node": "^22.15.3",
64
- "happy-dom": "^17.4.6",
65
- "nuxt": "^3.17.1",
61
+ "@nuxt/test-utils": "3.18.0",
62
+ "@types/node": "^22.15.29",
63
+ "happy-dom": "^17.5.6",
64
+ "nuxt": "^3.17.4",
66
65
  "tailwindcss": "<4.0.0",
67
- "vitest": "^3.1.2",
66
+ "vitest": "^3.1.4",
68
67
  "vue-tsc": "^2.2.10"
69
68
  }
70
69
  }