inibase 1.2.4 → 1.2.6

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/file.js CHANGED
@@ -558,7 +558,7 @@ export const search = async (filePath, operator, comparedAtValue, logicalOperato
558
558
  if (offset && linesNumbers.size < offset)
559
559
  continue;
560
560
  // Check if the limit has been reached.
561
- if (limit && linesNumbers.size >= limit + (offset ?? 0)) {
561
+ if (limit && linesNumbers.size > limit + (offset ? offset - 1 : 0)) {
562
562
  if (readWholeFile)
563
563
  continue;
564
564
  break;
package/dist/index.js CHANGED
@@ -907,20 +907,18 @@ export default class Inibase {
907
907
  .map((singleContent) => singleContent
908
908
  ? Array.isArray(singleContent)
909
909
  ? singleContent.map(formatLineContent)
910
- : items
911
- ? items.find(({ id }) => singleContent === id)
912
- : {
913
- id: singleContent,
914
- }
910
+ : items?.find(({ id }) => singleContent === id)
915
911
  : singleContent)
916
912
  .filter(Boolean)
917
- : (items?.find(({ id }) => lineContent === id) ?? {
918
- id: lineContent,
919
- });
913
+ : items?.find(({ id }) => lineContent === id);
920
914
  for (const [lineNumber, lineContent] of searchableIDs.entries()) {
921
915
  if (!lineContent)
922
916
  continue;
923
- RETURN[lineNumber][field.key] = formatLineContent(lineContent);
917
+ const formatedLineContent = formatLineContent(lineContent);
918
+ if (formatedLineContent &&
919
+ (!Array.isArray(formatedLineContent) ||
920
+ formatedLineContent.length > 0))
921
+ RETURN[lineNumber][field.key] = formatedLineContent;
924
922
  }
925
923
  }
926
924
  }
@@ -1021,7 +1019,8 @@ export default class Inibase {
1021
1019
  ...field,
1022
1020
  databasePath: this.databasePath,
1023
1021
  table: field.table ?? tableName,
1024
- }, options.perPage, (options.page - 1) * options.perPage + 1, true);
1022
+ }, options.perPage, (options.page - 1) * options.perPage +
1023
+ (options.page > 1 ? 1 : 0), true);
1025
1024
  if (searchResult) {
1026
1025
  const formatedSearchResult = Object.fromEntries(Object.entries(searchResult).map(([id, value]) => {
1027
1026
  const nestedObj = {};
@@ -1108,6 +1107,7 @@ export default class Inibase {
1108
1107
  options.columns.push("id");
1109
1108
  }
1110
1109
  // Default values for page and perPage
1110
+ options.columns = options.columns || [];
1111
1111
  options.page = options.page || 1;
1112
1112
  options.perPage = options.perPage || 15;
1113
1113
  let RETURN;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inibase",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Karim Amahtil",