some-common-functions-js 1.0.5 → 1.0.8

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 (3) hide show
  1. package/CHANGELOG.md +7 -2
  2. package/README.md +22 -20
  3. package/package.json +4 -1
package/CHANGELOG.md CHANGED
@@ -19,8 +19,13 @@ Improve README.md documentation.
19
19
  ## Version 1.0.4 - 2025/11/20 - ITA
20
20
  - Improved the readability of README.me
21
21
 
22
- ## Version 1.05 - 2025/11/21 - ITA
22
+ ## Version 1.0.5 - 2025/11/21 - ITA
23
23
  - Corrected README documentation.
24
24
 
25
- ## Version 1.06 - 2025/11/21 - ITA
25
+ ## Version 1.0.6 - 2025/11/21 - ITA
26
26
  - Updated package.json version in lieu of changes. Otherwise the updated package won't be published on npm.
27
+ ## Version 1.0.7 - 2025/11/21 - ITA
28
+ - Corrected README documentation.
29
+
30
+ ## Version 1.0.8 - 2025/11/21 - ITA
31
+ - Corrected test code and README documentation
package/README.md CHANGED
@@ -11,8 +11,8 @@ Common functions used for working with JavaScript objects and validating field v
11
11
  ### `getPaths(anObject)`
12
12
  Returns a string array of path/field names inside a JavaScript object.
13
13
  ***Example***
14
- const { getPaths } = require("some-common-functions-js");
15
14
  ```
15
+ const { getPaths } = require("some-common-functions-js");
16
16
  let client = {
17
17
  name: "Jack",
18
18
  surname: "Stober",
@@ -200,16 +200,16 @@ let anObject3 = {
200
200
  let objArray = [anObject2, anObject, anObject3];
201
201
  // Using objCompare to sort objects in objArray using multiple fields including nested fields.
202
202
  objArray.sort((obj1, obj2)=> {
203
- return commonFunctions.objCompare(
204
- obj1, obj2,
205
- "address.country.name",
206
- "address.city",
207
- "adress.mainPlace",
208
- "address.subPlace",
209
- "lastName",
210
- "firstName"
211
- );
212
- });
203
+ return objCompare(
204
+ obj1, obj2,
205
+ "address.country.name",
206
+ "address.city",
207
+ "adress.mainPlace",
208
+ "address.subPlace",
209
+ "lastName",
210
+ "firstName"
211
+ );
212
+ });
213
213
  console.log(objArray);
214
214
  /*
215
215
  [
@@ -281,11 +281,11 @@ let teams = [
281
281
  // Using objCompare to sort fields where there are mixed sort directions.
282
282
  // Sort by score descending, then by numGames ascending.
283
283
  teams.sort((team1, team2) => {
284
- return commonFunctions.objCompare(
285
- team1, team2,
286
- "score desc",
287
- "numGames asc"
288
- );
284
+ return objCompare(
285
+ team1, team2,
286
+ "score desc",
287
+ "numGames asc"
288
+ );
289
289
  });
290
290
  console.log(teams);
291
291
  /*
@@ -310,6 +310,7 @@ Binary Search the sorted (ascending or descending order) array of objects for a
310
310
 
311
311
  ***Example***
312
312
  ```
313
+ const { objCompare, binarySearchObj } = require("some-common-functions-js");
313
314
  let teamsArray = [
314
315
  { score: 90, numGames: 10 },
315
316
  { score: 90, numGames: 12 },
@@ -317,12 +318,12 @@ let teamsArray = [
317
318
  { score: 85, numGames: 10 }
318
319
  ]; // Sorted by "score desc", "numGames asc".
319
320
  let searchObj = { score: 85, numGames: 8 };
320
- let anIndex = (commonFunctions.binarySearchObj(teamsArray, searchObj, "score desc", "numGames asc"));
321
+ let anIndex = binarySearchObj(teamsArray, searchObj, 0, "score desc", "numGames asc");
321
322
 
322
- let result = commonFunctions.objCompare(searchObj, teamsArray[anIndex], "score desc", "numGames asc"); // 0 -- an object with value { score: 85, numGames: 8} exists at teamsArray[anIndex];
323
+ let result = objCompare(searchObj, teamsArray[anIndex], "score desc", "numGames asc"); // 0 -- an object with value { score: 85, numGames: 8} exists at teamsArray[anIndex];
323
324
  ```
324
325
  ## 4. `getObjArrayWithNoDuplicates(objArray, firstOfDuplicates, ...comparisonFields)`
325
- Create an array of objects with duplicates eliminated. Taking only the first or last object from each duplicate set. The input array must be sorted according to the values comparisonFields.
326
+ Create an array of objects with duplicates eliminated. Taking only the first or last object from each duplicate set. The input array must be sorted according to the values of comparisonFields.
326
327
  * If firstOfDuplicates === true, then the first element in each set of duplicates is taken.
327
328
  * if firstOfDuplicates === false, then the last element is taken from each set of duplicates.
328
329
  * Assumed field data types are Number, String and Date.
@@ -333,6 +334,7 @@ Create an array of objects with duplicates eliminated. Taking only the first or
333
334
 
334
335
  ***Example***
335
336
  ```
337
+ const { getObjArrayWithNoDuplicates } = require("some-common-functions-js");
336
338
  let teamsArray = [
337
339
  { score: 90, numGames: 10 },
338
340
  { score: 90, numGames: 10 },
@@ -347,7 +349,7 @@ let teamsArray = [
347
349
  { score: 85, numGames: 10 }
348
350
  ]; // Sorted by "score desc", "numGames asc".
349
351
 
350
- let noDuplicatesArray = commonFunctions.getObjArrayWithNoDuplicates(teamsArray, true, "score desc", "numGames asc");
352
+ let noDuplicatesArray = getObjArrayWithNoDuplicates(teamsArray, true, "score desc", "numGames asc");
351
353
  console.log(noDuplicatesArray); // Should contain only unique objects according to comparison fields.
352
354
  /*
353
355
  [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "some-common-functions-js",
3
- "version": "1.0.5",
3
+ "version": "1.0.8",
4
4
  "description": "Common functions used with Javascript objects, and field validation functions.",
5
5
  "keywords": [
6
6
  "validation",
@@ -20,7 +20,10 @@
20
20
  "functions",
21
21
  "helpers",
22
22
  "object utils",
23
+ "object utilities",
23
24
  "object validation",
25
+ "object array search",
26
+ "object compaare",
24
27
  "nodejs"
25
28
  ],
26
29
  "repository": {