extra-utils 3.3.0 → 3.4.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.
package/README.md CHANGED
@@ -11,28 +11,56 @@ yarn add extra-utils
11
11
  ## API
12
12
  ### pipe
13
13
  ```ts
14
- function pipe<T, U, V>(
15
- value: T
14
+ function pipe<A, B, C, D, E>(
15
+ value: A
16
16
  , ...operators: [
17
- (value: T) => U
18
- , ...Array<(value: U) => U>
19
- , (value: U) => V
17
+ (value: A) => B
18
+ , (value: B) => C
19
+ , ...Array<(value: C) => C>
20
+ , (value: C) => D
21
+ , (value: D) => E
20
22
  ]
21
- ): V
22
- function pipe<T, U>(
23
- value: T
23
+ ): E
24
+ function pipe<A, B, C, D>(
25
+ value: A
24
26
  , ...operators: [
25
- (value: T) => U
26
- , ...Array<(value: U) => U>
27
+ (value: A) => B
28
+ , (value: B) => C
29
+ , ...Array<(value: C) => C>
30
+ , (value: C) => D
27
31
  ]
28
- ): U
29
- function pipe<T, U>(
30
- value: T
32
+ ): D
33
+ function pipe<A, B, C, D>(
34
+ value: A
35
+ , ...operators: [
36
+ (value: A) => B
37
+ , ...Array<(value: B) => B>
38
+ , (value: B) => C
39
+ , (value: C) => D
40
+ ]
41
+ ): D
42
+ function pipe<A, B, C>(
43
+ value: A
44
+ , ...operators: [
45
+ (value: A) => B
46
+ , ...Array<(value: B) => B>
47
+ , (value: B) => C
48
+ ]
49
+ ): C
50
+ function pipe<A, B>(
51
+ value: A
52
+ , ...operators: [
53
+ (value: A) => B
54
+ , ...Array<(value: B) => B>
55
+ ]
56
+ ): B
57
+ function pipe<A, B>(
58
+ value: A
31
59
  , ...operators: [
32
- ...Array<(value: T) => T>
33
- , (value: T) => U
60
+ ...Array<(value: A) => A>
61
+ , (value: A) => B
34
62
  ]
35
- ): U
63
+ ): B
36
64
  function pipe<T>(
37
65
  value: T
38
66
  , ...operators: Array<(value: T) => T>
@@ -134,9 +162,15 @@ function isntPlainObject<T>(
134
162
 
135
163
  function isEmptyObject(val: object): boolean
136
164
  function isntEmptyObject(val: object): boolean
165
+ ```
137
166
 
167
+ ### JSON
168
+ ```ts
138
169
  function isJson(val: unknown): Json
139
170
  function isntJson<T>(val: T): val is Exclude<T, Json>
171
+
172
+ function isJsonable<T extends Json>(val: unknown): val is Jsonable<T>
173
+ function isntJsonable<T>(val: T): val is Exclude<T, Jsonable<Json>>
140
174
  ```
141
175
 
142
176
  ### RegExp
package/lib/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from './function';
7
7
  export * from './nullish';
8
8
  export * from './number';
9
9
  export * from './object';
10
+ export * from './json';
10
11
  export * from './pipe';
11
12
  export * from './string';
12
13
  export * from './regexp';
package/lib/index.js CHANGED
@@ -23,6 +23,7 @@ __exportStar(require("./function"), exports);
23
23
  __exportStar(require("./nullish"), exports);
24
24
  __exportStar(require("./number"), exports);
25
25
  __exportStar(require("./object"), exports);
26
+ __exportStar(require("./json"), exports);
26
27
  __exportStar(require("./pipe"), exports);
27
28
  __exportStar(require("./string"), exports);
28
29
  __exportStar(require("./regexp"), exports);
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,2CAAwB;AACxB,4CAAyB;AACzB,yCAAsB;AACtB,yCAAsB;AACtB,6CAA0B;AAC1B,4CAAyB;AACzB,2CAAwB;AACxB,2CAAwB;AACxB,yCAAsB;AACtB,2CAAwB;AACxB,2CAAwB;AACxB,2CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,2CAAwB;AACxB,4CAAyB;AACzB,yCAAsB;AACtB,yCAAsB;AACtB,6CAA0B;AAC1B,4CAAyB;AACzB,2CAAwB;AACxB,2CAAwB;AACxB,yCAAsB;AACtB,yCAAsB;AACtB,2CAAwB;AACxB,2CAAwB;AACxB,2CAAwB"}
package/lib/json.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { Json, Jsonable } from 'justypes';
2
+ export declare function isJson(val: unknown): val is Json;
3
+ export declare function isntJson<T>(val: T): val is Exclude<T, Json>;
4
+ export declare function isJsonable<T extends Json>(val: unknown): val is Jsonable<T>;
5
+ export declare function isntJsonable<T>(val: T): val is Exclude<T, Jsonable<Json>>;
package/lib/json.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isntJsonable = exports.isJsonable = exports.isntJson = exports.isJson = void 0;
4
+ const nullish_1 = require("./nullish");
5
+ const boolean_1 = require("./boolean");
6
+ const string_1 = require("./string");
7
+ const number_1 = require("./number");
8
+ const array_1 = require("./array");
9
+ const object_1 = require("./object");
10
+ const function_1 = require("./function");
11
+ function isJson(val) {
12
+ return (0, nullish_1.isNull)(val)
13
+ || (0, boolean_1.isBoolean)(val)
14
+ || (0, string_1.isString)(val)
15
+ || (0, number_1.isNumber)(val)
16
+ || ((0, array_1.isArray)(val) && val.every(isJson))
17
+ || ((0, object_1.isPlainObject)(val) && Object.values(val).every(isJson));
18
+ }
19
+ exports.isJson = isJson;
20
+ function isntJson(val) {
21
+ return !isJson(val);
22
+ }
23
+ exports.isntJson = isntJson;
24
+ function isJsonable(val) {
25
+ return (0, object_1.isObject)(val)
26
+ && 'toJSON' in val
27
+ && (0, function_1.isFunction)(val.toJSON);
28
+ }
29
+ exports.isJsonable = isJsonable;
30
+ function isntJsonable(val) {
31
+ return !isJsonable(val);
32
+ }
33
+ exports.isntJsonable = isntJsonable;
34
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":";;;AACA,uCAAkC;AAClC,uCAAqC;AACrC,qCAAmC;AACnC,qCAAmC;AACnC,mCAAiC;AACjC,qCAAkD;AAClD,yCAAuC;AAEvC,SAAgB,MAAM,CAAC,GAAY;IACjC,OAAO,IAAA,gBAAM,EAAC,GAAG,CAAC;WACX,IAAA,mBAAS,EAAC,GAAG,CAAC;WACd,IAAA,iBAAQ,EAAC,GAAG,CAAC;WACb,IAAA,iBAAQ,EAAC,GAAG,CAAC;WACb,CAAC,IAAA,eAAO,EAAC,GAAG,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;WACnC,CAAC,IAAA,sBAAa,EAAC,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AACjE,CAAC;AAPD,wBAOC;AAED,SAAgB,QAAQ,CAAI,GAAM;IAChC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AACrB,CAAC;AAFD,4BAEC;AAED,SAAgB,UAAU,CAAiB,GAAY;IACrD,OAAO,IAAA,iBAAQ,EAAC,GAAG,CAAC;WACb,QAAQ,IAAI,GAAG;WACf,IAAA,qBAAU,EAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAC/B,CAAC;AAJD,gCAIC;AAED,SAAgB,YAAY,CAAI,GAAM;IACpC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;AACzB,CAAC;AAFD,oCAEC"}
package/lib/object.d.ts CHANGED
@@ -1,9 +1,6 @@
1
- import { Json } from 'justypes';
2
1
  export declare function isObject(val: unknown): val is object & Record<string | symbol | number, unknown>;
3
2
  export declare function isntObject<T>(val: T): val is Exclude<T, object & Record<string | symbol | number, unknown>>;
4
3
  export declare function isPlainObject(val: unknown): val is object & Record<string | symbol | number, unknown>;
5
4
  export declare function isntPlainObject<T>(val: T): val is Exclude<T, object & Record<string | symbol | number, unknown>>;
6
5
  export declare function isEmptyObject(val: object): boolean;
7
6
  export declare function isntEmptyObject(val: object): boolean;
8
- export declare function isJson(val: unknown): val is Json;
9
- export declare function isntJson<T>(val: T): val is Exclude<T, Json>;
package/lib/object.js CHANGED
@@ -3,13 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isntJson = exports.isJson = exports.isntEmptyObject = exports.isEmptyObject = exports.isntPlainObject = exports.isPlainObject = exports.isntObject = exports.isObject = void 0;
6
+ exports.isntEmptyObject = exports.isEmptyObject = exports.isntPlainObject = exports.isPlainObject = exports.isntObject = exports.isObject = void 0;
7
7
  const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
8
- const nullish_1 = require("./nullish");
9
- const boolean_1 = require("./boolean");
10
- const string_1 = require("./string");
11
- const number_1 = require("./number");
12
- const array_1 = require("./array");
13
8
  function isObject(val) {
14
9
  return val !== null
15
10
  && typeof val === 'object';
@@ -35,17 +30,4 @@ function isntEmptyObject(val) {
35
30
  return Object.keys(val).length !== 0;
36
31
  }
37
32
  exports.isntEmptyObject = isntEmptyObject;
38
- function isJson(val) {
39
- return (0, nullish_1.isNull)(val)
40
- || (0, boolean_1.isBoolean)(val)
41
- || (0, string_1.isString)(val)
42
- || (0, number_1.isNumber)(val)
43
- || ((0, array_1.isArray)(val) && val.every(isJson))
44
- || (isPlainObject(val) && Object.values(val).every(isJson));
45
- }
46
- exports.isJson = isJson;
47
- function isntJson(val) {
48
- return !isJson(val);
49
- }
50
- exports.isntJson = isntJson;
51
33
  //# sourceMappingURL=object.js.map
package/lib/object.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"object.js","sourceRoot":"","sources":["../src/object.ts"],"names":[],"mappings":";;;;;;AAAA,yEAAwD;AAExD,uCAAkC;AAClC,uCAAqC;AACrC,qCAAmC;AACnC,qCAAmC;AACnC,mCAAiC;AAEjC,SAAgB,QAAQ,CACtB,GAAY;IAEZ,OAAO,GAAG,KAAK,IAAI;WACZ,OAAO,GAAG,KAAK,QAAQ,CAAA;AAChC,CAAC;AALD,4BA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Z,OAAO,GAAG,KAAK,IAAI;WACZ,OAAO,GAAG,KAAK,QAAQ,CAAA;AAChC,CAAC;AALD,4BAKC;AAED,SAAgB,UAAU,CACxB,GAAM;IAEN,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AACvB,CAAC;AAJD,gCAIC;AAED,SAAgB,aAAa,CAC3B,GAAY;IAIZ,OAAO,IAAA,uBAAqB,EAAC,GAAG,CAAC,CAAA;AACnC,CAAC;AAND,sCAMC;AAED,SAAgB,eAAe,CAC7B,GAAM;IAEN,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;AAC5B,CAAC;AAJD,0CAIC;AAED,SAAgB,aAAa,CAAC,GAAW;IACvC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAA;AACtC,CAAC;AAFD,sCAEC;AAED,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAA;AACtC,CAAC;AAFD,0CAEC"}
package/lib/pipe.d.ts CHANGED
@@ -1,14 +1,33 @@
1
- export declare function pipe<T, U, V>(value: T, ...operators: [
2
- (value: T) => U,
3
- ...Array<(value: U) => U>,
4
- (value: U) => V
5
- ]): V;
6
- export declare function pipe<T, U>(value: T, ...operators: [
7
- (value: T) => U,
8
- ...Array<(value: U) => U>
9
- ]): U;
10
- export declare function pipe<T, U>(value: T, ...operators: [
11
- ...Array<(value: T) => T>,
12
- (value: T) => U
13
- ]): U;
1
+ export declare function pipe<A, B, C, D, E>(value: A, ...operators: [
2
+ (value: A) => B,
3
+ (value: B) => C,
4
+ ...Array<(value: C) => C>,
5
+ (value: C) => D,
6
+ (value: D) => E
7
+ ]): E;
8
+ export declare function pipe<A, B, C, D>(value: A, ...operators: [
9
+ (value: A) => B,
10
+ (value: B) => C,
11
+ ...Array<(value: C) => C>,
12
+ (value: C) => D
13
+ ]): D;
14
+ export declare function pipe<A, B, C, D>(value: A, ...operators: [
15
+ (value: A) => B,
16
+ ...Array<(value: B) => B>,
17
+ (value: B) => C,
18
+ (value: C) => D
19
+ ]): D;
20
+ export declare function pipe<A, B, C>(value: A, ...operators: [
21
+ (value: A) => B,
22
+ ...Array<(value: B) => B>,
23
+ (value: B) => C
24
+ ]): C;
25
+ export declare function pipe<A, B>(value: A, ...operators: [
26
+ (value: A) => B,
27
+ ...Array<(value: B) => B>
28
+ ]): B;
29
+ export declare function pipe<A, B>(value: A, ...operators: [
30
+ ...Array<(value: A) => A>,
31
+ (value: A) => B
32
+ ]): B;
14
33
  export declare function pipe<T>(value: T, ...operators: Array<(value: T) => T>): T;
package/lib/pipe.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pipe.js","sourceRoot":"","sources":["../src/pipe.ts"],"names":[],"mappings":";;;AA0BA,SAAgB,IAAI,CAClB,KAAQ,EACR,GAAG,SAAyC;IAE5C,IAAI,MAAM,GAAU,KAAK,CAAA;IACzB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;KAC1B;IACD,OAAO,MAAW,CAAA;AACpB,CAAC;AATD,oBASC"}
1
+ {"version":3,"file":"pipe.js","sourceRoot":"","sources":["../src/pipe.ts"],"names":[],"mappings":";;;AAsDA,SAAgB,IAAI,CAClB,KAAQ,EACR,GAAG,SAAyC;IAE5C,IAAI,MAAM,GAAU,KAAK,CAAA;IACzB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;KAC1B;IACD,OAAO,MAAW,CAAA;AACpB,CAAC;AATD,oBASC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extra-utils",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "Utilities for JavaScript and Typescript",
5
5
  "files": [
6
6
  "lib"
@@ -34,28 +34,28 @@
34
34
  },
35
35
  "devDependencies": {
36
36
  "@blackglory/pass": "^1.1.0",
37
- "@commitlint/cli": "^17.1.2",
38
- "@commitlint/config-conventional": "^17.1.0",
39
- "@types/jest": "^27.4.1",
40
- "@types/jsdom": "^16.2.15",
41
- "@types/lodash": "^4.14.186",
42
- "@typescript-eslint/eslint-plugin": "^5.41.0",
43
- "@typescript-eslint/parser": "^5.41.0",
44
- "eslint": "^8.26.0",
37
+ "@commitlint/cli": "^17.3.0",
38
+ "@commitlint/config-conventional": "^17.3.0",
39
+ "@types/jest": "^29.2.3",
40
+ "@types/jsdom": "^20.0.1",
41
+ "@types/lodash": "^4.14.190",
42
+ "@typescript-eslint/eslint-plugin": "^5.44.0",
43
+ "@typescript-eslint/parser": "^5.44.0",
44
+ "eslint": "^8.28.0",
45
45
  "husky": "^4.3.8",
46
- "jest": "^27.5.1",
47
- "jest-extended": "^2.0.0",
46
+ "jest": "^29.3.1",
47
+ "jest-extended": "^3.2.0",
48
48
  "npm-run-all": "^4.1.5",
49
49
  "rimraf": "^3.0.2",
50
50
  "standard-version": "^9.5.0",
51
- "ts-jest": "^27.1.4",
51
+ "ts-jest": "^29.0.3",
52
52
  "tscpaths": "^0.0.9",
53
- "tsd": "^0.20.0",
54
- "tslib": "^2.4.0",
55
- "typescript": "4.7.4"
53
+ "tsd": "^0.24.1",
54
+ "tslib": "^2.4.1",
55
+ "typescript": "4.9.3"
56
56
  },
57
57
  "dependencies": {
58
- "justypes": "^3.0.0",
58
+ "justypes": "^3.1.1",
59
59
  "lodash": "^4.17.21"
60
60
  }
61
61
  }