@takeshape/util 8.38.2 → 8.39.2

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/es/types.js CHANGED
@@ -1,3 +1,4 @@
1
+ import isNull from 'lodash/isNull';
1
2
  export function isObject(obj) {
2
3
  return obj !== null && typeof obj === 'object';
3
4
  }
@@ -16,4 +17,10 @@ export function isRecord(maybeRecord) {
16
17
  */
17
18
  export function createEnumMatcher(enumVariable) {
18
19
  return testValue => Object.entries(enumVariable).find(([, enumValue]) => enumValue === testValue);
20
+ }
21
+ export function isPrimitive(maybePrimitive) {
22
+ return typeof maybePrimitive === 'string' || typeof maybePrimitive === 'number' || typeof maybePrimitive === 'boolean' || typeof maybePrimitive === 'symbol' || typeof maybePrimitive === 'undefined' || typeof maybePrimitive === 'bigint' || isNull(maybePrimitive);
23
+ }
24
+ export function isScalar(maybeScalar) {
25
+ return typeof maybeScalar === 'string' || typeof maybeScalar === 'number' || typeof maybeScalar === 'boolean' || typeof maybeScalar === 'bigint';
19
26
  }
package/lib/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Primitive } from 'type-fest';
1
2
  export declare type StringProps<Obj> = {
2
3
  [K in keyof Required<Obj>]: Obj[K] extends string ? K : never;
3
4
  }[keyof Obj];
@@ -21,4 +22,7 @@ export declare type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
21
22
  export declare function createEnumMatcher<T extends string, TEnum extends string>(enumVariable: {
22
23
  [key in T]: TEnum;
23
24
  }): (testValue: string) => [string, unknown] | undefined;
25
+ export declare function isPrimitive(maybePrimitive: unknown): maybePrimitive is Primitive;
26
+ export declare type Scalar = string | number | boolean | bigint;
27
+ export declare function isScalar(maybeScalar: unknown): maybeScalar is Scalar;
24
28
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW,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CAAC,GAAG,KAAK;CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAE1G,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAErE;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,OAAO,GAAG,WAAW,IAAI,CAAC,CAElG;AAED,oBAAY,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAG/E,oBAAY,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;AAErC;;;GAGG;AACH,oBAAY,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAErE;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,SAAS,MAAM,EAAE,YAAY,EAAE;KAAE,GAAG,IAAI,CAAC,GAAG,KAAK;CAAC,eACtF,MAAM,mCAC1B;AAED,wBAAgB,WAAW,CAAC,cAAc,EAAE,OAAO,GAAG,cAAc,IAAI,SAAS,CAUhF;AAED,oBAAY,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAExD,wBAAgB,QAAQ,CAAC,WAAW,EAAE,OAAO,GAAG,WAAW,IAAI,MAAM,CAOpE"}
package/lib/types.js CHANGED
@@ -5,7 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createEnumMatcher = createEnumMatcher;
7
7
  exports.isObject = isObject;
8
+ exports.isPrimitive = isPrimitive;
8
9
  exports.isRecord = isRecord;
10
+ exports.isScalar = isScalar;
11
+
12
+ var _isNull = _interopRequireDefault(require("lodash/isNull"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
15
 
10
16
  function isObject(obj) {
11
17
  return obj !== null && typeof obj === 'object';
@@ -26,4 +32,12 @@ function isRecord(maybeRecord) {
26
32
  */
27
33
  function createEnumMatcher(enumVariable) {
28
34
  return testValue => Object.entries(enumVariable).find(([, enumValue]) => enumValue === testValue);
35
+ }
36
+
37
+ function isPrimitive(maybePrimitive) {
38
+ return typeof maybePrimitive === 'string' || typeof maybePrimitive === 'number' || typeof maybePrimitive === 'boolean' || typeof maybePrimitive === 'symbol' || typeof maybePrimitive === 'undefined' || typeof maybePrimitive === 'bigint' || (0, _isNull.default)(maybePrimitive);
39
+ }
40
+
41
+ function isScalar(maybeScalar) {
42
+ return typeof maybeScalar === 'string' || typeof maybeScalar === 'number' || typeof maybeScalar === 'boolean' || typeof maybeScalar === 'bigint';
29
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/util",
3
- "version": "8.38.2",
3
+ "version": "8.39.2",
4
4
  "description": "Shared utilities",
5
5
  "homepage": "https://www.takeshape.io",
6
6
  "repository": {
@@ -21,7 +21,7 @@
21
21
  "es"
22
22
  ],
23
23
  "dependencies": {
24
- "@takeshape/routing": "8.38.2",
24
+ "@takeshape/routing": "8.39.2",
25
25
  "@types/url-parse": "^1.4.4",
26
26
  "aws-sdk": "^2.802.0",
27
27
  "classnames": "^2.2.5",