@candlerip/shared3 0.0.99 → 0.0.100
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/type/index.d.ts +1 -0
- package/src/type/index.js +1 -0
- package/src/type/is-null/index.d.ts +1 -0
- package/src/type/is-null/index.js +1 -0
- package/src/type/object/index.d.ts +1 -0
- package/src/type/object/index.js +1 -0
- package/src/type/object/is-object/index.d.ts +3 -0
- package/src/type/object/is-object/index.js +3 -0
- package/src/type/object/is-object/object/index.d.ts +1 -0
- package/src/type/object/is-object/object/index.js +11 -0
- package/src/type/object/is-object/properties-in-object/index.d.ts +1 -0
- package/src/type/object/is-object/properties-in-object/index.js +8 -0
- package/src/type/object/is-object/property-in-object/index.d.ts +1 -0
- package/src/type/object/is-object/property-in-object/index.js +13 -0
package/package.json
CHANGED
package/src/type/index.d.ts
CHANGED
package/src/type/index.js
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
export declare const isNull: (data?: unknown) => data is null;
|
@@ -0,0 +1 @@
|
|
1
|
+
export const isNull = (data) => data === null;
|
package/src/type/object/index.js
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
export declare const isObject: (data?: unknown) => data is Record<string, unknown>;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { isArray } from '../../../array/index.js';
|
2
|
+
import { isNull } from '../../../is-null/index.js';
|
3
|
+
export const isObject = (data) => {
|
4
|
+
if (typeof data !== 'object') {
|
5
|
+
return false;
|
6
|
+
}
|
7
|
+
if (isNull(data)) {
|
8
|
+
return false;
|
9
|
+
}
|
10
|
+
return !isArray(data);
|
11
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const isPropertiesInObject: <X extends string, T>(props: X[], data?: unknown, typeGuard?: (data?: unknown) => data is T) => data is { [key in X]: T; };
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { isObject } from '../object/index.js';
|
2
|
+
import { isPropertyInObject } from '../property-in-object/index.js';
|
3
|
+
export const isPropertiesInObject = (props, data, typeGuard) => {
|
4
|
+
if (!isObject(data)) {
|
5
|
+
return false;
|
6
|
+
}
|
7
|
+
return props.every((a) => isPropertyInObject(a, data, typeGuard));
|
8
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const isPropertyInObject: <X extends string, T>(prop: X, data?: unknown, typeGuard?: (data?: unknown) => data is T) => data is Record<X, T>;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { isObject } from '../object/index.js';
|
2
|
+
export const isPropertyInObject = (prop, data, typeGuard) => {
|
3
|
+
if (!isObject(data)) {
|
4
|
+
return false;
|
5
|
+
}
|
6
|
+
if (!(prop in data)) {
|
7
|
+
return false;
|
8
|
+
}
|
9
|
+
if (typeGuard && !typeGuard(data[prop])) {
|
10
|
+
return false;
|
11
|
+
}
|
12
|
+
return true;
|
13
|
+
};
|