@node-cli/utilities 1.0.3 → 1.0.4

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.
@@ -1,11 +1,11 @@
1
1
  /**
2
- * Converts the first character of string to upper case
2
+ * Converts the first character of string to upper case.
3
3
  * @param {string} string_ the string to convert
4
4
  * @returns {string} the converted string
5
5
  */
6
6
  export declare const upperFirst: (string_: string) => string;
7
7
  /**
8
- * Converts the first character of string to lower case
8
+ * Converts the first character of string to lower case.
9
9
  * @param {string} string_ the string to convert
10
10
  * @returns {string} the converted string
11
11
  */
@@ -13,11 +13,10 @@ export declare const lowerFirst: (string_: string) => string;
13
13
  /**
14
14
  * Generate a random number to append to an `id` string.
15
15
  *
16
- * NOTE: we are still using the good old lodash uniqueId when
17
- * the code is not in production, so that the results are a
18
- * little bit more consistent tests after test instead of
19
- * being completely random, so that they do not break
20
- * potential snapshot tests.
16
+ * NOTE: we are still using the good old lodash uniqueId when the code is not in
17
+ * production, so that the results are a little bit more consistent tests after
18
+ * test instead of being completely random, so that they do not break potential
19
+ * snapshot tests.
21
20
  *
22
21
  * @param {String} prefix - When a prefix is provided, the
23
22
  * function will return a random
@@ -25,26 +24,29 @@ export declare const lowerFirst: (string_: string) => string;
25
24
  * prefix.
26
25
  *
27
26
  * @returns {String} - Returns a string with random numbers.
27
+ *
28
28
  */
29
29
  export declare const uniqueID: (prefix?: string) => string;
30
30
  /**
31
31
  * Wrapper method for lodash `merge()` and `mergeWith()` methods.
32
32
  *
33
- * Without the `customizer` function, this method recursively merges own and inherited
34
- * enumerable string keyed properties of source objects into the destination object.
35
- * Source properties that resolve to undefined are skipped if a destination value exists.
36
- * Array and plain object properties are merged recursively. Other objects and value
37
- * types are overridden by assignment. Source objects are applied from left to right.
38
- * Subsequent sources overwrite property assignments of previous sources.
33
+ * Without the `customizer` function, this method recursively merges own and
34
+ * inherited enumerable string keyed properties of source objects into the
35
+ * destination object. Source properties that resolve to undefined are skipped
36
+ * if a destination value exists. Array and plain object properties are merged
37
+ * recursively. Other objects and value types are overridden by assignment.
38
+ * Source objects are applied from left to right. Subsequent sources overwrite
39
+ * property assignments of previous sources.
39
40
  *
40
- * With the `customizer` function, the behavior is the same except that `customizer` is
41
- * invoked to produce the merged values of the destination and source properties.
42
- * If customizer returns undefined, merging is handled by the `fastMerge` instead.
43
- * The customizer is invoked with six arguments: `(objValue, srcValue, key, object,
44
- * source, stack)`
41
+ * With the `customizer` function, the behavior is the same except that
42
+ * `customizer` is invoked to produce the merged values of the destination and
43
+ * source properties. If customizer returns undefined, merging is handled by the
44
+ * `fastMerge` instead. The customizer is invoked with six arguments:
45
+ * `(objValue, srcValue, key, object, source, stack)`
45
46
  * @param {object} objectA
46
47
  * @param {object} objectB
47
48
  * @param {function} customizer
48
49
  * @returns {object} !! WARNING: this method will mutate objectA
50
+ *
49
51
  */
50
52
  export declare const fastMerge: (objectA: any, objectB: any, customizer?: any) => object;
package/dist/utilities.js CHANGED
@@ -1,22 +1,21 @@
1
1
  import { merge, mergeWith, uniqueId } from "lodash-es";
2
2
  /**
3
- * Converts the first character of string to upper case
3
+ * Converts the first character of string to upper case.
4
4
  * @param {string} string_ the string to convert
5
5
  * @returns {string} the converted string
6
6
  */ export const upperFirst = (string_)=>string_[0].toUpperCase() + string_.slice(1);
7
7
  /**
8
- * Converts the first character of string to lower case
8
+ * Converts the first character of string to lower case.
9
9
  * @param {string} string_ the string to convert
10
10
  * @returns {string} the converted string
11
11
  */ export const lowerFirst = (string_)=>string_[0].toLowerCase() + string_.slice(1);
12
12
  /**
13
13
  * Generate a random number to append to an `id` string.
14
14
  *
15
- * NOTE: we are still using the good old lodash uniqueId when
16
- * the code is not in production, so that the results are a
17
- * little bit more consistent tests after test instead of
18
- * being completely random, so that they do not break
19
- * potential snapshot tests.
15
+ * NOTE: we are still using the good old lodash uniqueId when the code is not in
16
+ * production, so that the results are a little bit more consistent tests after
17
+ * test instead of being completely random, so that they do not break potential
18
+ * snapshot tests.
20
19
  *
21
20
  * @param {String} prefix - When a prefix is provided, the
22
21
  * function will return a random
@@ -24,33 +23,36 @@ import { merge, mergeWith, uniqueId } from "lodash-es";
24
23
  * prefix.
25
24
  *
26
25
  * @returns {String} - Returns a string with random numbers.
26
+ *
27
27
  */ export const uniqueID = (prefix = "")=>{
28
28
  if (process.env.NODE_ENV !== "production") {
29
29
  return uniqueId(prefix);
30
30
  }
31
- // Extract the decimal part
31
+ // Extract the decimal part.
32
32
  const randomNumber = `${Math.random()}`.split(".")[1];
33
33
  return prefix || prefix !== "" ? `${prefix}${randomNumber}` : randomNumber;
34
34
  };
35
35
  /**
36
36
  * Wrapper method for lodash `merge()` and `mergeWith()` methods.
37
37
  *
38
- * Without the `customizer` function, this method recursively merges own and inherited
39
- * enumerable string keyed properties of source objects into the destination object.
40
- * Source properties that resolve to undefined are skipped if a destination value exists.
41
- * Array and plain object properties are merged recursively. Other objects and value
42
- * types are overridden by assignment. Source objects are applied from left to right.
43
- * Subsequent sources overwrite property assignments of previous sources.
38
+ * Without the `customizer` function, this method recursively merges own and
39
+ * inherited enumerable string keyed properties of source objects into the
40
+ * destination object. Source properties that resolve to undefined are skipped
41
+ * if a destination value exists. Array and plain object properties are merged
42
+ * recursively. Other objects and value types are overridden by assignment.
43
+ * Source objects are applied from left to right. Subsequent sources overwrite
44
+ * property assignments of previous sources.
44
45
  *
45
- * With the `customizer` function, the behavior is the same except that `customizer` is
46
- * invoked to produce the merged values of the destination and source properties.
47
- * If customizer returns undefined, merging is handled by the `fastMerge` instead.
48
- * The customizer is invoked with six arguments: `(objValue, srcValue, key, object,
49
- * source, stack)`
46
+ * With the `customizer` function, the behavior is the same except that
47
+ * `customizer` is invoked to produce the merged values of the destination and
48
+ * source properties. If customizer returns undefined, merging is handled by the
49
+ * `fastMerge` instead. The customizer is invoked with six arguments:
50
+ * `(objValue, srcValue, key, object, source, stack)`
50
51
  * @param {object} objectA
51
52
  * @param {object} objectB
52
53
  * @param {function} customizer
53
54
  * @returns {object} !! WARNING: this method will mutate objectA
55
+ *
54
56
  */ export const fastMerge = (objectA, objectB, customizer)=>{
55
57
  return typeof customizer === "function" ? mergeWith(objectA, objectB, customizer) : merge(objectA, objectB);
56
58
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utilities.ts"],"sourcesContent":["import { merge, mergeWith, uniqueId } from \"lodash-es\";\n\n/**\n * Converts the first character of string to upper case\n * @param {string} string_ the string to convert\n * @returns {string} the converted string\n */\nexport const upperFirst = (string_: string): string =>\n\tstring_[0].toUpperCase() + string_.slice(1);\n\n/**\n * Converts the first character of string to lower case\n * @param {string} string_ the string to convert\n * @returns {string} the converted string\n */\nexport const lowerFirst = (string_: string): string =>\n\tstring_[0].toLowerCase() + string_.slice(1);\n\n/**\n * Generate a random number to append to an `id` string.\n *\n * NOTE: we are still using the good old lodash uniqueId when\n * the code is not in production, so that the results are a\n * little bit more consistent tests after test instead of\n * being completely random, so that they do not break\n * potential snapshot tests.\n *\n * @param {String} prefix - When a prefix is provided, the\n * function will return a random\n * number appended to the provided\n * prefix.\n *\n * @returns {String} - Returns a string with random numbers.\n */\nexport const uniqueID = (prefix: string = \"\"): string => {\n\tif (process.env.NODE_ENV !== \"production\") {\n\t\treturn uniqueId(prefix);\n\t}\n\t// Extract the decimal part\n\tconst randomNumber = `${Math.random()}`.split(\".\")[1];\n\treturn prefix || prefix !== \"\" ? `${prefix}${randomNumber}` : randomNumber;\n};\n\n/**\n * Wrapper method for lodash `merge()` and `mergeWith()` methods.\n *\n * Without the `customizer` function, this method recursively merges own and inherited\n * enumerable string keyed properties of source objects into the destination object.\n * Source properties that resolve to undefined are skipped if a destination value exists.\n * Array and plain object properties are merged recursively. Other objects and value\n * types are overridden by assignment. Source objects are applied from left to right.\n * Subsequent sources overwrite property assignments of previous sources.\n *\n * With the `customizer` function, the behavior is the same except that `customizer` is\n * invoked to produce the merged values of the destination and source properties.\n * If customizer returns undefined, merging is handled by the `fastMerge` instead.\n * The customizer is invoked with six arguments: `(objValue, srcValue, key, object,\n * source, stack)`\n * @param {object} objectA\n * @param {object} objectB\n * @param {function} customizer\n * @returns {object} !! WARNING: this method will mutate objectA\n */\nexport const fastMerge = (\n\tobjectA: any,\n\tobjectB: any,\n\tcustomizer?: any,\n): object => {\n\treturn typeof customizer === \"function\"\n\t\t? mergeWith(objectA, objectB, customizer)\n\t\t: merge(objectA, objectB);\n};\n"],"names":["merge","mergeWith","uniqueId","upperFirst","string_","toUpperCase","slice","lowerFirst","toLowerCase","uniqueID","prefix","process","env","NODE_ENV","randomNumber","Math","random","split","fastMerge","objectA","objectB","customizer"],"mappings":"AAAA,SAASA,KAAK,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,YAAY;AAEvD;;;;CAIC,GACD,OAAO,MAAMC,aAAa,CAACC,UAC1BA,OAAO,CAAC,EAAE,CAACC,WAAW,KAAKD,QAAQE,KAAK,CAAC,GAAG;AAE7C;;;;CAIC,GACD,OAAO,MAAMC,aAAa,CAACH,UAC1BA,OAAO,CAAC,EAAE,CAACI,WAAW,KAAKJ,QAAQE,KAAK,CAAC,GAAG;AAE7C;;;;;;;;;;;;;;;CAeC,GACD,OAAO,MAAMG,WAAW,CAACC,SAAiB,EAAE;IAC3C,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QAC1C,OAAOX,SAASQ;IACjB;IACA,2BAA2B;IAC3B,MAAMI,eAAe,GAAGC,KAAKC,MAAM,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;IACrD,OAAOP,UAAUA,WAAW,KAAK,GAAGA,SAASI,cAAc,GAAGA;AAC/D,EAAE;AAEF;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMI,YAAY,CACxBC,SACAC,SACAC;IAEA,OAAO,OAAOA,eAAe,aAC1BpB,UAAUkB,SAASC,SAASC,cAC5BrB,MAAMmB,SAASC;AACnB,EAAE"}
1
+ {"version":3,"sources":["../src/utilities.ts"],"sourcesContent":["import { merge, mergeWith, uniqueId } from \"lodash-es\";\n\n/**\n * Converts the first character of string to upper case.\n * @param {string} string_ the string to convert\n * @returns {string} the converted string\n */\nexport const upperFirst = (string_: string): string =>\n\tstring_[0].toUpperCase() + string_.slice(1);\n\n/**\n * Converts the first character of string to lower case.\n * @param {string} string_ the string to convert\n * @returns {string} the converted string\n */\nexport const lowerFirst = (string_: string): string =>\n\tstring_[0].toLowerCase() + string_.slice(1);\n\n/**\n * Generate a random number to append to an `id` string.\n *\n * NOTE: we are still using the good old lodash uniqueId when the code is not in\n * production, so that the results are a little bit more consistent tests after\n * test instead of being completely random, so that they do not break potential\n * snapshot tests.\n *\n * @param {String} prefix - When a prefix is provided, the\n * function will return a random\n * number appended to the provided\n * prefix.\n *\n * @returns {String} - Returns a string with random numbers.\n *\n */\nexport const uniqueID = (prefix: string = \"\"): string => {\n\tif (process.env.NODE_ENV !== \"production\") {\n\t\treturn uniqueId(prefix);\n\t}\n\t// Extract the decimal part.\n\tconst randomNumber = `${Math.random()}`.split(\".\")[1];\n\treturn prefix || prefix !== \"\" ? `${prefix}${randomNumber}` : randomNumber;\n};\n\n/**\n * Wrapper method for lodash `merge()` and `mergeWith()` methods.\n *\n * Without the `customizer` function, this method recursively merges own and\n * inherited enumerable string keyed properties of source objects into the\n * destination object. Source properties that resolve to undefined are skipped\n * if a destination value exists. Array and plain object properties are merged\n * recursively. Other objects and value types are overridden by assignment.\n * Source objects are applied from left to right. Subsequent sources overwrite\n * property assignments of previous sources.\n *\n * With the `customizer` function, the behavior is the same except that\n * `customizer` is invoked to produce the merged values of the destination and\n * source properties. If customizer returns undefined, merging is handled by the\n * `fastMerge` instead. The customizer is invoked with six arguments:\n * `(objValue, srcValue, key, object, source, stack)`\n * @param {object} objectA\n * @param {object} objectB\n * @param {function} customizer\n * @returns {object} !! WARNING: this method will mutate objectA\n *\n */\nexport const fastMerge = (\n\tobjectA: any,\n\tobjectB: any,\n\tcustomizer?: any,\n): object => {\n\treturn typeof customizer === \"function\"\n\t\t? mergeWith(objectA, objectB, customizer)\n\t\t: merge(objectA, objectB);\n};\n"],"names":["merge","mergeWith","uniqueId","upperFirst","string_","toUpperCase","slice","lowerFirst","toLowerCase","uniqueID","prefix","process","env","NODE_ENV","randomNumber","Math","random","split","fastMerge","objectA","objectB","customizer"],"mappings":"AAAA,SAASA,KAAK,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,YAAY;AAEvD;;;;CAIC,GACD,OAAO,MAAMC,aAAa,CAACC,UAC1BA,OAAO,CAAC,EAAE,CAACC,WAAW,KAAKD,QAAQE,KAAK,CAAC,GAAG;AAE7C;;;;CAIC,GACD,OAAO,MAAMC,aAAa,CAACH,UAC1BA,OAAO,CAAC,EAAE,CAACI,WAAW,KAAKJ,QAAQE,KAAK,CAAC,GAAG;AAE7C;;;;;;;;;;;;;;;CAeC,GACD,OAAO,MAAMG,WAAW,CAACC,SAAiB,EAAE;IAC3C,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QAC1C,OAAOX,SAASQ;IACjB;IACA,4BAA4B;IAC5B,MAAMI,eAAe,GAAGC,KAAKC,MAAM,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;IACrD,OAAOP,UAAUA,WAAW,KAAK,GAAGA,SAASI,cAAc,GAAGA;AAC/D,EAAE;AAEF;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,MAAMI,YAAY,CACxBC,SACAC,SACAC;IAEA,OAAO,OAAOA,eAAe,aAC1BpB,UAAUkB,SAASC,SAASC,cAC5BrB,MAAMmB,SAASC;AACnB,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-cli/utilities",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "description": "A few utilities for Node CLI applications",
@@ -8,7 +8,8 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": "./dist/utilities.js",
10
10
  "files": [
11
- "dist"
11
+ "dist",
12
+ "README.md"
12
13
  ],
13
14
  "node": ">=16",
14
15
  "dependencies": {
@@ -20,7 +21,9 @@
20
21
  "build:js": "swc --strip-leading-paths --source-maps --out-dir dist src",
21
22
  "build:types": "tsc",
22
23
  "clean": "rimraf dist types coverage",
24
+ "comments:fix": "comments --merge-line-comments 'src/**/*.ts'",
23
25
  "lint": "biome lint src",
26
+ "lint:fix": "biome check src --write --no-errors-on-unmatched",
24
27
  "test": "vitest run --globals",
25
28
  "test:coverage": "vitest run --coverage --globals",
26
29
  "test:watch": "vitest --globals",
@@ -30,8 +33,9 @@
30
33
  "access": "public"
31
34
  },
32
35
  "devDependencies": {
36
+ "@node-cli/comments": "0.2.0",
33
37
  "@vitest/coverage-v8": "3.2.4",
34
38
  "vitest": "3.2.4"
35
39
  },
36
- "gitHead": "2cef8f88aa5316a1789caad2bd7327ca908ccb9f"
40
+ "gitHead": "d90392dcb766dd605bc3eeabc7c7a7ab0c8e6da6"
37
41
  }