@xylabs/object-model 4.13.14 β 4.13.16
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 +33 -42
- package/dist/neutral/AnyObject.d.ts +6 -0
- package/dist/neutral/AsTypeFactory.d.ts +7 -0
- package/dist/neutral/AsTypeFunction.d.ts +13 -0
- package/dist/neutral/Compare.d.ts +1 -0
- package/dist/neutral/index.d.ts +4 -42
- package/dist/neutral/types.d.ts +19 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,69 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
# @xylabs/object-model
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[![logo][]](https://xylabs.com)
|
|
4
4
|
|
|
5
|
+
[![main-build][]][main-build-link]
|
|
5
6
|
[![npm-badge][]][npm-link]
|
|
6
7
|
[![npm-downloads-badge][]][npm-link]
|
|
7
8
|
[![jsdelivr-badge][]][jsdelivr-link]
|
|
8
9
|
[![npm-license-badge][]](LICENSE)
|
|
10
|
+
[![codacy-badge][]][codacy-link]
|
|
11
|
+
[![codeclimate-badge][]][codeclimate-link]
|
|
12
|
+
[![snyk-badge][]][snyk-link]
|
|
9
13
|
[![socket-badge][]][socket-link]
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Table of Contents
|
|
14
|
-
|
|
15
|
-
- [Description](#description)
|
|
16
|
-
- [Install](#install)
|
|
17
|
-
- [Maintainers](#maintainers)
|
|
18
|
-
- [License](#license)
|
|
19
|
-
- [Credits](#credits)
|
|
20
|
-
|
|
21
|
-
## Description
|
|
22
|
-
|
|
23
|
-
Common Javascript code that is used throughout XYO projects that use React.
|
|
24
|
-
|
|
25
|
-
## Install
|
|
26
|
-
|
|
27
|
-
Using npm:
|
|
15
|
+
Version: 4.13.15
|
|
28
16
|
|
|
29
|
-
|
|
30
|
-
npm i --save @xylabs/object
|
|
31
|
-
```
|
|
17
|
+
Primary SDK for using XYO Protocol 2.0
|
|
32
18
|
|
|
33
|
-
|
|
19
|
+
## Documentation
|
|
34
20
|
|
|
35
|
-
|
|
36
|
-
yarn add @xylabs/object
|
|
37
|
-
```
|
|
21
|
+
Coming Soon!
|
|
38
22
|
|
|
39
|
-
|
|
40
|
-
[Developer Reference](https://xylabs.github.io/sdk-js)
|
|
23
|
+
Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js)
|
|
41
24
|
|
|
42
25
|
## Maintainers
|
|
43
26
|
|
|
44
27
|
- [Arie Trouw](https://github.com/arietrouw) ([arietrouw.com](https://arietrouw.com))
|
|
45
|
-
- [Joel Carter](https://github.com/JoelBCarter)
|
|
46
28
|
- [Matt Jones](https://github.com/jonesmac)
|
|
29
|
+
- [Joel Carter](https://github.com/JoelBCarter)
|
|
47
30
|
- [Jordan Trouw](https://github.com/jordantrouw)
|
|
48
31
|
|
|
49
32
|
## License
|
|
50
33
|
|
|
51
|
-
See the [LICENSE](LICENSE) file for license details
|
|
34
|
+
> See the [LICENSE](LICENSE) file for license details
|
|
52
35
|
|
|
53
36
|
## Credits
|
|
54
37
|
|
|
55
|
-
[Made with π₯and βοΈ by
|
|
38
|
+
[Made with π₯ and βοΈ by XYLabs](https://xylabs.com)
|
|
56
39
|
|
|
57
40
|
[logo]: https://cdn.xy.company/img/brand/XYPersistentCompany_Logo_Icon_Colored.svg
|
|
58
41
|
|
|
59
|
-
[
|
|
60
|
-
[
|
|
61
|
-
|
|
62
|
-
[npm-
|
|
63
|
-
[
|
|
64
|
-
|
|
65
|
-
[
|
|
66
|
-
[
|
|
67
|
-
|
|
68
|
-
[
|
|
69
|
-
|
|
42
|
+
[main-build]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml/badge.svg
|
|
43
|
+
[main-build-link]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml
|
|
44
|
+
[npm-badge]: https://img.shields.io/npm/v/@xylabs/object-model.svg
|
|
45
|
+
[npm-link]: https://www.npmjs.com/package/@xylabs/object-model
|
|
46
|
+
[codacy-badge]: https://app.codacy.com/project/badge/Grade/c8e15e14f37741c18cfb47ac7245c698
|
|
47
|
+
[codacy-link]: https://www.codacy.com/gh/xylabs/sdk-js/dashboard?utm_source=github.com&utm_medium=referral&utm_content=xylabs/sdk-js&utm_campaign=Badge_Grade
|
|
48
|
+
[codeclimate-badge]: https://api.codeclimate.com/v1/badges/c5eb068f806f0b047ea7/maintainability
|
|
49
|
+
[codeclimate-link]: https://codeclimate.com/github/xylabs/sdk-js/maintainability
|
|
50
|
+
[snyk-badge]: https://snyk.io/test/github/xylabs/sdk-js/badge.svg?targetFile=package.json
|
|
51
|
+
[snyk-link]: https://snyk.io/test/github/xylabs/sdk-js?targetFile=package.json
|
|
52
|
+
|
|
53
|
+
[npm-downloads-badge]: https://img.shields.io/npm/dw/@xylabs/object-model
|
|
54
|
+
[npm-license-badge]: https://img.shields.io/npm/l/@xylabs/object-model
|
|
55
|
+
|
|
56
|
+
[jsdelivr-badge]: https://data.jsdelivr.com/v1/package/npm/@xylabs/object-model/badge
|
|
57
|
+
[jsdelivr-link]: https://www.jsdelivr.com/package/npm/@xylabs/object-model
|
|
58
|
+
|
|
59
|
+
[socket-badge]: https://socket.dev/api/badge/npm/package/@xylabs/object-model
|
|
60
|
+
[socket-link]: https://socket.dev/npm/package/@xylabs/object-model
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TypedKey } from '@xylabs/typeof';
|
|
2
|
+
/**
|
|
3
|
+
* Any object, which means that it does not enforce the set of fields that it has. Extending from AnyObject
|
|
4
|
+
* will result in a type that includes the universal set of field names
|
|
5
|
+
*/
|
|
6
|
+
export type AnyObject = Record<TypedKey, unknown>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AnyNonPromise } from '@xylabs/promise';
|
|
2
|
+
import type { AsTypeFunction } from './AsTypeFunction.ts';
|
|
3
|
+
import type { TypeCheck } from './types.ts';
|
|
4
|
+
export declare const AsTypeFactory: {
|
|
5
|
+
create: <T extends AnyNonPromise>(typeCheck: TypeCheck<T>) => AsTypeFunction<T>;
|
|
6
|
+
createOptional: <T extends AnyNonPromise>(typeCheck: TypeCheck<T>) => (value: AnyNonPromise) => T | undefined;
|
|
7
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AnyNonPromise } from '@xylabs/promise';
|
|
2
|
+
import type { StringOrAlertFunction, TypeCheckConfig, TypeCheckOptionalConfig, TypeCheckRequiredConfig } from './types.ts';
|
|
3
|
+
export type AsTypeFunction<T extends AnyNonPromise = AnyNonPromise> = {
|
|
4
|
+
<TType extends T>(value: AnyNonPromise): TType | undefined;
|
|
5
|
+
<TType extends T>(value: AnyNonPromise, config: TypeCheckRequiredConfig): TType;
|
|
6
|
+
<TType extends T>(value: AnyNonPromise, config: TypeCheckConfig | TypeCheckOptionalConfig): TType | undefined;
|
|
7
|
+
<TType extends T>(value: AnyNonPromise, assert: StringOrAlertFunction<TType>): TType | undefined;
|
|
8
|
+
<TType extends T>(value: AnyNonPromise, assert: StringOrAlertFunction<TType>, config: TypeCheckRequiredConfig): TType;
|
|
9
|
+
<TType extends T>(value: AnyNonPromise, assert: StringOrAlertFunction<TType>, config: TypeCheckConfig | TypeCheckOptionalConfig): TType | undefined;
|
|
10
|
+
};
|
|
11
|
+
export type AsOptionalTypeFunction<T extends AnyNonPromise = AnyNonPromise> = {
|
|
12
|
+
<TType extends T>(value: AnyNonPromise): TType | undefined;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Compare<T> = (a: T, b: T) => number;
|
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,42 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Any object, which means that it does not enforce the set of fields that it has. Extending from AnyObject
|
|
8
|
-
* will result in a type that includes the universal set of field names
|
|
9
|
-
*/
|
|
10
|
-
type AnyObject = Record<TypedKey, unknown>;
|
|
11
|
-
|
|
12
|
-
interface TypeCheckConfig {
|
|
13
|
-
log?: boolean | Logger;
|
|
14
|
-
}
|
|
15
|
-
interface TypeCheckRequiredConfig extends TypeCheckConfig {
|
|
16
|
-
required: true;
|
|
17
|
-
}
|
|
18
|
-
interface TypeCheckOptionalConfig extends TypeCheckConfig {
|
|
19
|
-
required: false;
|
|
20
|
-
}
|
|
21
|
-
type StringOrAlertFunction<T extends AnyNonPromise> = string | AssertExMessageFunc<T>;
|
|
22
|
-
type TypeCheck<T extends TypedValue> = {
|
|
23
|
-
(obj: AnyNonPromise): obj is T;
|
|
24
|
-
(obj: AnyNonPromise, config: TypeCheckConfig): obj is T;
|
|
25
|
-
(obj: AnyNonPromise, config: TypeCheckConfig | number | undefined): obj is T;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
type AsTypeFunction<T extends AnyNonPromise = AnyNonPromise> = {
|
|
29
|
-
<TType extends T>(value: AnyNonPromise): TType | undefined;
|
|
30
|
-
<TType extends T>(value: AnyNonPromise, config: TypeCheckRequiredConfig): TType;
|
|
31
|
-
<TType extends T>(value: AnyNonPromise, config: TypeCheckConfig | TypeCheckOptionalConfig): TType | undefined;
|
|
32
|
-
<TType extends T>(value: AnyNonPromise, assert: StringOrAlertFunction<TType>): TType | undefined;
|
|
33
|
-
<TType extends T>(value: AnyNonPromise, assert: StringOrAlertFunction<TType>, config: TypeCheckRequiredConfig): TType;
|
|
34
|
-
<TType extends T>(value: AnyNonPromise, assert: StringOrAlertFunction<TType>, config: TypeCheckConfig | TypeCheckOptionalConfig): TType | undefined;
|
|
35
|
-
};
|
|
36
|
-
type AsOptionalTypeFunction<T extends AnyNonPromise = AnyNonPromise> = {
|
|
37
|
-
<TType extends T>(value: AnyNonPromise): TType | undefined;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
type Compare<T> = (a: T, b: T) => number;
|
|
41
|
-
|
|
42
|
-
export type { AnyObject, AsOptionalTypeFunction, AsTypeFunction, Compare, StringOrAlertFunction, TypeCheck, TypeCheckConfig, TypeCheckOptionalConfig, TypeCheckRequiredConfig };
|
|
1
|
+
export * from './AnyObject.ts';
|
|
2
|
+
export * from './AsTypeFunction.ts';
|
|
3
|
+
export * from './Compare.ts';
|
|
4
|
+
export * from './types.ts';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AssertExMessageFunc } from '@xylabs/assert';
|
|
2
|
+
import type { Logger } from '@xylabs/logger';
|
|
3
|
+
import type { AnyNonPromise } from '@xylabs/promise';
|
|
4
|
+
import type { TypedValue } from '@xylabs/typeof';
|
|
5
|
+
export interface TypeCheckConfig {
|
|
6
|
+
log?: boolean | Logger;
|
|
7
|
+
}
|
|
8
|
+
export interface TypeCheckRequiredConfig extends TypeCheckConfig {
|
|
9
|
+
required: true;
|
|
10
|
+
}
|
|
11
|
+
export interface TypeCheckOptionalConfig extends TypeCheckConfig {
|
|
12
|
+
required: false;
|
|
13
|
+
}
|
|
14
|
+
export type StringOrAlertFunction<T extends AnyNonPromise> = string | AssertExMessageFunc<T>;
|
|
15
|
+
export type TypeCheck<T extends TypedValue> = {
|
|
16
|
+
(obj: AnyNonPromise): obj is T;
|
|
17
|
+
(obj: AnyNonPromise, config: TypeCheckConfig): obj is T;
|
|
18
|
+
(obj: AnyNonPromise, config: TypeCheckConfig | number | undefined): obj is T;
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/object-model",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.16",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"module": "dist/neutral/index.mjs",
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@xylabs/assert": "^4.13.
|
|
33
|
-
"@xylabs/logger": "^4.13.
|
|
34
|
-
"@xylabs/promise": "^4.13.
|
|
35
|
-
"@xylabs/typeof": "^4.13.
|
|
32
|
+
"@xylabs/assert": "^4.13.16",
|
|
33
|
+
"@xylabs/logger": "^4.13.16",
|
|
34
|
+
"@xylabs/promise": "^4.13.16",
|
|
35
|
+
"@xylabs/typeof": "^4.13.16"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.0-rc.
|
|
39
|
-
"@xylabs/tsconfig": "^7.0.0-rc.
|
|
38
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.0-rc.27",
|
|
39
|
+
"@xylabs/tsconfig": "^7.0.0-rc.27",
|
|
40
40
|
"typescript": "^5.8.3",
|
|
41
41
|
"vitest": "^3.2.4"
|
|
42
42
|
},
|