@punks/backend-core 0.0.76 → 0.0.77

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.
@@ -0,0 +1,5 @@
1
+ /// <reference types="node" />
2
+ export declare const encodeUtf8: (value: Uint8Array) => string;
3
+ export declare const decodeUtf8: (value: string) => Buffer;
4
+ export declare const encodeBase64: (value: Uint8Array) => string;
5
+ export declare const decodeBase64: (value: string) => Buffer;
@@ -6,6 +6,7 @@ export { getDirectoryFilePaths } from "./files";
6
6
  export { joinPath, splitPath, ensureDirectory, getDirectoryPath, createDayPath, } from "./paths";
7
7
  export * from "./strings";
8
8
  export * from "./objects";
9
+ export * from "./encoding";
9
10
  export { maskVariable } from "./variables";
10
11
  export * from "./text";
11
12
  export * from "./threading";
@@ -1 +1,2 @@
1
1
  export declare const newUuid: () => string;
2
+ export declare const generateHash: (length: number) => string;
package/dist/esm/index.js CHANGED
@@ -412,6 +412,11 @@ const jsonSerialize = (obj, options) => {
412
412
  return JSON.stringify(obj, replacer, spaces);
413
413
  };
414
414
 
415
+ const encodeUtf8 = (value) => Buffer.from(value).toString("utf-8");
416
+ const decodeUtf8 = (value) => Buffer.from(value, "utf-8");
417
+ const encodeBase64 = (value) => Buffer.from(value).toString("base64");
418
+ const decodeBase64 = (value) => Buffer.from(value, "base64");
419
+
415
420
  const maskVariable = (value, unmaskedLength = 4) => value
416
421
  ? value.substring(0, unmaskedLength).concat(Array.from(value.substring(unmaskedLength))
417
422
  .map(() => "*")
@@ -478,6 +483,13 @@ const newUuid = () => {
478
483
  return v.toString(16);
479
484
  });
480
485
  };
486
+ const generateHash = (length) => {
487
+ let text = "";
488
+ const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
489
+ for (let i = 0; i < length; i++)
490
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
491
+ return text;
492
+ };
481
493
 
482
494
  function serializeQueryString(obj) {
483
495
  let queryString = "";
@@ -31247,5 +31259,5 @@ const processArrayItemMove = (items, input) => {
31247
31259
  }));
31248
31260
  };
31249
31261
 
31250
- export { ConsoleLogger, DatadogLogger, ExcelKeyTransform, FileLogger, Log, LogLevel, MetaSerializationType, addTime, buildObject, buildTree, buildUrl, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, createDayPath, csvBuild, csvParse, deserializeQueryString, distinct, distinctElements, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, floorDateToSecond, getDirectoryFilePaths, getDirectoryPath, getQueryParameter, groupBy, indexes, isNullOrUndefined, iterate, joinPath, joinUrl, jsonDistinct, jsonSerialize, last, logMemoryUsage, mapAsync, mapOrThrow, maskVariable, mergeDeep, multipleSplit, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, selectMany, serializeQueryString, sleep, sort, splitPath, subArrays, subtractTime, testInternetConnection, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart, updateQueryParameters };
31262
+ export { ConsoleLogger, DatadogLogger, ExcelKeyTransform, FileLogger, Log, LogLevel, MetaSerializationType, addTime, buildObject, buildTree, buildUrl, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, createDayPath, csvBuild, csvParse, decodeBase64, decodeUtf8, deserializeQueryString, distinct, distinctElements, encodeBase64, encodeUtf8, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, floorDateToSecond, generateHash, getDirectoryFilePaths, getDirectoryPath, getQueryParameter, groupBy, indexes, isNullOrUndefined, iterate, joinPath, joinUrl, jsonDistinct, jsonSerialize, last, logMemoryUsage, mapAsync, mapOrThrow, maskVariable, mergeDeep, multipleSplit, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, selectMany, serializeQueryString, sleep, sort, splitPath, subArrays, subtractTime, testInternetConnection, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart, updateQueryParameters };
31251
31263
  //# sourceMappingURL=index.js.map