extra-utils 3.7.0 → 4.0.1

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
@@ -29,11 +29,15 @@ function isntFalsy<T>(val: T): val is Exclude<T, Falsy>
29
29
 
30
30
  ### JSON
31
31
  ```ts
32
- function isJson(val: unknown): Json
33
- function isntJson<T>(val: T): val is Exclude<T, Json>
34
-
35
- function isJsonable<T extends Json>(val: unknown): val is Jsonable<T>
36
- function isntJsonable<T>(val: T): val is Exclude<T, Jsonable<Json>>
32
+ function isJSONValue(val: unknown): val is JSONValue
33
+ function isntJSONValue<T>(val: T): val is Exclude<T, JSONValue>
34
+
35
+ function isJSONSerializable<T extends
36
+ | JSONValue
37
+ | Record<string, JSONValue | JSONSerializable<any>>
38
+ | Array<JSONValue | JSONSerializable<any>>
39
+ >(val: unknown): val is JSONSerializable<T>
40
+ function isntJSONSerializable<T>(val: T): val is Exclude<T, JSONSerializable<any>>
37
41
  ```
38
42
 
39
43
  ### Nullish
@@ -272,6 +276,6 @@ function pipe<A, B>(
272
276
  ): B
273
277
  function pipe<T, U>(
274
278
  value: T
275
- , ...operators: Array<(value: unknown) => unknown>
279
+ , ...operators: Array<(value: any) => unknown>
276
280
  ): U
277
281
  ```
@@ -1,2 +1,2 @@
1
- export * from './is-json';
2
- export * from './is-jsonable';
1
+ export * from './is-json-value';
2
+ export * from './is-json-serializable';
package/lib/json/index.js CHANGED
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./is-json"), exports);
18
- __exportStar(require("./is-jsonable"), exports);
17
+ __exportStar(require("./is-json-value"), exports);
18
+ __exportStar(require("./is-json-serializable"), exports);
19
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/json/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,gDAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/json/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,yDAAsC"}
@@ -0,0 +1,3 @@
1
+ import { JSONValue, JSONSerializable } from 'justypes';
2
+ export declare function isJSONSerializable<T extends JSONValue | Record<string, JSONValue | JSONSerializable<any>> | Array<JSONValue | JSONSerializable<any>>>(val: unknown): val is JSONSerializable<T>;
3
+ export declare function isntJSONSerializable<T>(val: T): val is Exclude<T, JSONSerializable<any>>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isntJSONSerializable = exports.isJSONSerializable = void 0;
4
+ const object_1 = require("../object");
5
+ const is_function_1 = require("../is-function");
6
+ function isJSONSerializable(val) {
7
+ return (0, object_1.isObject)(val)
8
+ && 'toJSON' in val
9
+ && (0, is_function_1.isFunction)(val.toJSON);
10
+ }
11
+ exports.isJSONSerializable = isJSONSerializable;
12
+ function isntJSONSerializable(val) {
13
+ return !isJSONSerializable(val);
14
+ }
15
+ exports.isntJSONSerializable = isntJSONSerializable;
16
+ //# sourceMappingURL=is-json-serializable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-json-serializable.js","sourceRoot":"","sources":["../../src/json/is-json-serializable.ts"],"names":[],"mappings":";;;AACA,wCAAsC;AACtC,kDAA6C;AAE7C,SAAgB,kBAAkB,CAIhC,GAAY;IACZ,OAAO,IAAA,iBAAQ,EAAC,GAAG,CAAC;WACb,QAAQ,IAAI,GAAG;WACf,IAAA,wBAAU,EAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAC/B,CAAC;AARD,gDAQC;AAED,SAAgB,oBAAoB,CAAI,GAAM;IAC5C,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAA;AACjC,CAAC;AAFD,oDAEC"}
@@ -0,0 +1,3 @@
1
+ import { JSONValue } from 'justypes';
2
+ export declare function isJSONValue(val: unknown): val is JSONValue;
3
+ export declare function isntJSONValue<T>(val: T): val is Exclude<T, JSONValue>;
@@ -1,23 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isntJson = exports.isJson = void 0;
3
+ exports.isntJSONValue = exports.isJSONValue = void 0;
4
4
  const nullish_1 = require("../nullish");
5
5
  const boolean_1 = require("../boolean");
6
6
  const string_1 = require("../string");
7
7
  const number_1 = require("../number");
8
8
  const array_1 = require("../array");
9
9
  const object_1 = require("../object");
10
- function isJson(val) {
10
+ function isJSONValue(val) {
11
11
  return (0, nullish_1.isNull)(val)
12
12
  || (0, boolean_1.isBoolean)(val)
13
13
  || (0, string_1.isString)(val)
14
14
  || (0, number_1.isNumber)(val)
15
- || ((0, array_1.isArray)(val) && val.every(isJson))
16
- || ((0, object_1.isPlainObject)(val) && Object.values(val).every(isJson));
15
+ || ((0, array_1.isArray)(val) && val.every(isJSONValue))
16
+ || ((0, object_1.isPlainObject)(val) && Object.values(val).every(isJSONValue));
17
17
  }
18
- exports.isJson = isJson;
19
- function isntJson(val) {
20
- return !isJson(val);
18
+ exports.isJSONValue = isJSONValue;
19
+ function isntJSONValue(val) {
20
+ return !isJSONValue(val);
21
21
  }
22
- exports.isntJson = isntJson;
23
- //# sourceMappingURL=is-json.js.map
22
+ exports.isntJSONValue = isntJSONValue;
23
+ //# sourceMappingURL=is-json-value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-json-value.js","sourceRoot":"","sources":["../../src/json/is-json-value.ts"],"names":[],"mappings":";;;AACA,0CAAqC;AACrC,0CAAwC;AACxC,wCAAsC;AACtC,wCAAsC;AACtC,sCAAoC;AACpC,wCAA2C;AAE3C,SAAgB,WAAW,CAAC,GAAY;IACtC,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,WAAW,CAAC,CAAC;WACxC,CAAC,IAAA,sBAAa,EAAC,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAA;AACtE,CAAC;AAPD,kCAOC;AAED,SAAgB,aAAa,CAAI,GAAM;IACrC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;AAC1B,CAAC;AAFD,sCAEC"}
package/lib/pipe.d.ts CHANGED
@@ -40,4 +40,4 @@ export declare function pipe<A, B, C>(value: A, ...operators: [
40
40
  export declare function pipe<A, B>(value: A, ...operators: [
41
41
  (value: A) => B
42
42
  ]): B;
43
- export declare function pipe<T, U>(value: T, ...operators: Array<(value: unknown) => unknown>): U;
43
+ export declare function pipe<T, U>(value: T, ...operators: Array<(value: any) => unknown>): U;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extra-utils",
3
- "version": "3.7.0",
3
+ "version": "4.0.1",
4
4
  "description": "Utilities for JavaScript and Typescript",
5
5
  "files": [
6
6
  "lib"
@@ -11,6 +11,9 @@
11
11
  "repository": "git@github.com:BlackGlory/extra-utils.git",
12
12
  "author": "BlackGlory <woshenmedoubuzhidao@blackglory.me>",
13
13
  "license": "MIT",
14
+ "engines": {
15
+ "node": ">=12"
16
+ },
14
17
  "scripts": {
15
18
  "lint": "eslint --ext .js,.jsx,.ts,.tsx --quiet src __tests__",
16
19
  "test": "jest --runInBand --config jest.config.js",
@@ -29,33 +32,29 @@
29
32
  "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
30
33
  }
31
34
  },
32
- "engines": {
33
- "node": ">=12"
34
- },
35
35
  "devDependencies": {
36
36
  "@blackglory/pass": "^1.1.0",
37
37
  "@commitlint/cli": "^17.3.0",
38
38
  "@commitlint/config-conventional": "^17.3.0",
39
- "@types/jest": "^29.2.3",
39
+ "@types/jest": "^29.2.4",
40
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",
41
+ "@types/lodash": "^4.14.191",
42
+ "@typescript-eslint/eslint-plugin": "^5.46.1",
43
+ "@typescript-eslint/parser": "^5.46.1",
44
+ "eslint": "^8.30.0",
45
45
  "husky": "^4.3.8",
46
46
  "jest": "^29.3.1",
47
- "jest-extended": "^3.2.0",
48
47
  "npm-run-all": "^4.1.5",
49
48
  "rimraf": "^3.0.2",
50
49
  "standard-version": "^9.5.0",
51
50
  "ts-jest": "^29.0.3",
52
51
  "tscpaths": "^0.0.9",
53
- "tsd": "^0.24.1",
52
+ "tsd": "^0.25.0",
54
53
  "tslib": "^2.4.1",
55
54
  "typescript": "4.9.3"
56
55
  },
57
56
  "dependencies": {
58
- "justypes": "^3.1.2",
57
+ "justypes": "^4.0.0",
59
58
  "lodash": "^4.17.21"
60
59
  }
61
60
  }
@@ -1,3 +0,0 @@
1
- import { Json } 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>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-json.js","sourceRoot":"","sources":["../../src/json/is-json.ts"],"names":[],"mappings":";;;AACA,0CAAqC;AACrC,0CAAwC;AACxC,wCAAsC;AACtC,wCAAsC;AACtC,sCAAoC;AACpC,wCAA2C;AAE3C,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"}
@@ -1,3 +0,0 @@
1
- import { Json, Jsonable } from 'justypes';
2
- export declare function isJsonable<T extends Json>(val: unknown): val is Jsonable<T>;
3
- export declare function isntJsonable<T>(val: T): val is Exclude<T, Jsonable<Json>>;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isntJsonable = exports.isJsonable = void 0;
4
- const object_1 = require("../object");
5
- const is_function_1 = require("../is-function");
6
- function isJsonable(val) {
7
- return (0, object_1.isObject)(val)
8
- && 'toJSON' in val
9
- && (0, is_function_1.isFunction)(val.toJSON);
10
- }
11
- exports.isJsonable = isJsonable;
12
- function isntJsonable(val) {
13
- return !isJsonable(val);
14
- }
15
- exports.isntJsonable = isntJsonable;
16
- //# sourceMappingURL=is-jsonable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-jsonable.js","sourceRoot":"","sources":["../../src/json/is-jsonable.ts"],"names":[],"mappings":";;;AACA,wCAAsC;AACtC,kDAA6C;AAE7C,SAAgB,UAAU,CAAiB,GAAY;IACrD,OAAO,IAAA,iBAAQ,EAAC,GAAG,CAAC;WACb,QAAQ,IAAI,GAAG;WACf,IAAA,wBAAU,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"}