@node-cli/utilities 1.0.0 → 1.0.2
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/utilities.js.map +1 -1
- package/package.json +6 -6
package/dist/utilities.js.map
CHANGED
|
@@ -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
|
|
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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","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,CAAC,EAAEC,KAAKC,MAAM,GAAG,CAAC,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;IACrD,OAAOP,UAAUA,WAAW,KAAK,CAAC,EAAEA,OAAO,EAAEI,aAAa,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-cli/utilities",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"description": "A few utilities for Node CLI applications",
|
|
@@ -15,18 +15,18 @@
|
|
|
15
15
|
"lodash-es": "4.17.21"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
|
-
"build": "
|
|
18
|
+
"build": "npm-run-all --serial clean build:types build:js build:barrel",
|
|
19
19
|
"build:barrel": "barrelsby --delete --directory dist --pattern \"**/*.d.ts\" --name \"index.d\"",
|
|
20
|
-
"build:js": "swc --source-maps --out-dir dist src",
|
|
20
|
+
"build:js": "swc --strip-leading-paths --source-maps --out-dir dist src",
|
|
21
21
|
"build:types": "tsc",
|
|
22
22
|
"clean": "rimraf dist types coverage",
|
|
23
|
-
"lint": "
|
|
23
|
+
"lint": "biome lint src",
|
|
24
24
|
"test": "cross-env-shell NODE_OPTIONS=--experimental-vm-modules jest",
|
|
25
25
|
"test:coverage": "npm run test -- --coverage",
|
|
26
|
-
"watch": "swc --watch --out-dir dist src"
|
|
26
|
+
"watch": "swc --strip-leading-paths --watch --out-dir dist src"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "d7d79f8f71fb3225e5a214aba3a42a89470d8340"
|
|
32
32
|
}
|