@aliexme/js-utils 0.5.0 → 0.6.0

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 +1 @@
1
- {"version":3,"file":"asyncify.js","sourceRoot":"","sources":["../src/async/asyncify.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAyB,EAAqB,EAA8B,EAAE;IACpG,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE;QACjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAC3C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC,CAAA"}
1
+ {"version":3,"file":"asyncify.js","sourceRoot":"","sources":["../src/async/asyncify.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAyB,EAAqB,EAAgC,EAAE;IACtG,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE;QACjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAC3C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC,CAAA"}
package/function/noop.js CHANGED
@@ -1,2 +1,4 @@
1
- export const noop = () => { };
1
+ export const noop = () => {
2
+ /* noop */
3
+ };
2
4
  //# sourceMappingURL=noop.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"noop.js","sourceRoot":"","sources":["../src/function/noop.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,EAAE,GAAc,CAAC,CAAA"}
1
+ {"version":3,"file":"noop.js","sourceRoot":"","sources":["../src/function/noop.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,EAAE;IACvB,UAAU;AACZ,CAAC,CAAA"}
package/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './string';
2
+ export * from './number';
2
3
  export * from './array';
3
4
  export * from './object';
4
5
  export * from './function';
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './string';
2
+ export * from './number';
2
3
  export * from './array';
3
4
  export * from './object';
4
5
  export * from './function';
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA"}
@@ -0,0 +1 @@
1
+ export * from './round';
@@ -0,0 +1,2 @@
1
+ export * from './round';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/number/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const round: (value: number, options?: {
2
+ precision?: number;
3
+ }) => number;
@@ -0,0 +1,5 @@
1
+ export const round = (value, options = {}) => {
2
+ const { precision = 0 } = options;
3
+ return Math.round(value * Math.pow(10, precision)) / Math.pow(10, precision);
4
+ };
5
+ //# sourceMappingURL=round.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"round.js","sourceRoot":"","sources":["../src/number/round.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,KAAa,EACb,UAEI,EAAE,EACE,EAAE;IACV,MAAM,EAAE,SAAS,GAAG,CAAC,EAAE,GAAG,OAAO,CAAA;IAEjC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAA;AAC9E,CAAC,CAAA"}
@@ -2,9 +2,7 @@ import { objectForEach } from './objectForEach';
2
2
  export const omitObjectProperties = (obj, keys) => {
3
3
  const result = {};
4
4
  objectForEach(obj, ({ key, value }) => {
5
- const needOmit = Array.isArray(keys)
6
- ? keys.some((omitKey) => String(omitKey) === key)
7
- : String(keys) === key;
5
+ const needOmit = Array.isArray(keys) ? keys.some((omitKey) => String(omitKey) === key) : String(keys) === key;
8
6
  if (!needOmit) {
9
7
  result[key] = value;
10
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"omitObjectProperties.js","sourceRoot":"","sources":["../src/object/omitObjectProperties.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,GAAM,EACN,IAAa,EACD,EAAE;IACd,MAAM,MAAM,GAAG,EAAgB,CAAA;IAE/B,aAAa,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE;QACpC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YAClC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC;YACjD,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAA;QAExB,IAAI,CAAC,QAAQ,EAAE;YACb,MAAM,CAAC,GAA0B,CAAC,GAAG,KAA4B,CAAA;SAClE;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
1
+ {"version":3,"file":"omitObjectProperties.js","sourceRoot":"","sources":["../src/object/omitObjectProperties.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,GAAM,EACN,IAAa,EACD,EAAE;IACd,MAAM,MAAM,GAAG,EAAgB,CAAA;IAE/B,aAAa,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE;QACpC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAA;QAE7G,IAAI,CAAC,QAAQ,EAAE;YACb,MAAM,CAAC,GAA0B,CAAC,GAAG,KAA4B,CAAA;SAClE;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliexme/js-utils",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Common JavaScript utilities",
5
5
  "private": false,
6
6
  "author": "Alexander Smirnov <al.smirnov996@gmail.com>",
@@ -26,16 +26,19 @@
26
26
  },
27
27
  "dependencies": {},
28
28
  "devDependencies": {
29
- "@aliexme/eslint-config": "0.1.1",
30
- "@aliexme/ts-types": "0.2.2",
29
+ "@aliexme/eslint-config": "0.3.1",
30
+ "@aliexme/ts-types": "0.2.3",
31
31
  "@types/jest": "27.5.0",
32
32
  "@typescript-eslint/eslint-plugin": "5.52.0",
33
33
  "@typescript-eslint/parser": "5.52.0",
34
34
  "eslint": "8.34.0",
35
+ "eslint-config-prettier": "8.8.0",
35
36
  "eslint-plugin-import": "2.27.5",
37
+ "eslint-plugin-prettier": "4.2.1",
36
38
  "husky": "8.0.3",
37
39
  "jest": "29.4.3",
38
40
  "lint-staged": "13.1.2",
41
+ "prettier": "2.8.8",
39
42
  "ts-jest": "29.0.5",
40
43
  "typescript": "4.9.5"
41
44
  }
@@ -1,4 +1,4 @@
1
1
  export const capitalize = (str) => {
2
- return str.charAt(0).toUpperCase() + str.slice(1);
2
+ return (str.charAt(0).toUpperCase() + str.slice(1));
3
3
  };
4
4
  //# sourceMappingURL=capitalize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"capitalize.js","sourceRoot":"","sources":["../src/string/capitalize.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAmB,GAAM,EAAiB,EAAE;IACpE,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAkB,CAAA;AACpE,CAAC,CAAA"}
1
+ {"version":3,"file":"capitalize.js","sourceRoot":"","sources":["../src/string/capitalize.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAmB,GAAM,EAAiB,EAAE;IACpE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAkB,CAAA;AACtE,CAAC,CAAA"}
package/string/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './capitalize';
2
+ export * from './secureString';
package/string/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './capitalize';
2
+ export * from './secureString';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const secureString: (str: string, options?: {
2
+ maxInsecureChars?: number;
3
+ }) => string;
@@ -0,0 +1,11 @@
1
+ export const secureString = (str, options = {}) => {
2
+ const { maxInsecureChars = 4 } = options;
3
+ const securePart = '****';
4
+ if (!str) {
5
+ return str;
6
+ }
7
+ const maxInsecureEndPartChars = Math.min(Math.floor(str.length / 2), maxInsecureChars);
8
+ const insecureEndPart = str.slice(str.length - maxInsecureEndPartChars);
9
+ return `${securePart}${insecureEndPart}`;
10
+ };
11
+ //# sourceMappingURL=secureString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secureString.js","sourceRoot":"","sources":["../src/string/secureString.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,GAAW,EACX,UAEI,EAAE,EACE,EAAE;IACV,MAAM,EAAE,gBAAgB,GAAG,CAAC,EAAE,GAAG,OAAO,CAAA;IACxC,MAAM,UAAU,GAAG,MAAM,CAAA;IAEzB,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,GAAG,CAAA;KACX;IAED,MAAM,uBAAuB,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAA;IACtF,MAAM,eAAe,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,GAAG,uBAAuB,CAAC,CAAA;IAEvE,OAAO,GAAG,UAAU,GAAG,eAAe,EAAE,CAAA;AAC1C,CAAC,CAAA"}