xanv 1.0.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/XanvType.d.ts +17 -0
- package/XanvType.js +51 -0
- package/XanvType.js.map +1 -0
- package/XanvType.mjs +51 -0
- package/XanvType.mjs.map +1 -0
- package/index.d.ts +33 -0
- package/index.js +14 -0
- package/index.js.map +1 -0
- package/index.mjs +14 -0
- package/index.mjs.map +1 -0
- package/package.json +33 -0
- package/readme.md +121 -0
- package/types/Any.d.ts +10 -0
- package/types/Any.js +8 -0
- package/types/Any.js.map +1 -0
- package/types/Any.mjs +8 -0
- package/types/Any.mjs.map +1 -0
- package/types/Array.d.ts +17 -0
- package/types/Array.js +84 -0
- package/types/Array.js.map +1 -0
- package/types/Array.mjs +84 -0
- package/types/Array.mjs.map +1 -0
- package/types/Boolean.d.ts +10 -0
- package/types/Boolean.js +11 -0
- package/types/Boolean.js.map +1 -0
- package/types/Boolean.mjs +11 -0
- package/types/Boolean.mjs.map +1 -0
- package/types/Date.d.ts +10 -0
- package/types/Date.js +11 -0
- package/types/Date.js.map +1 -0
- package/types/Date.mjs +11 -0
- package/types/Date.mjs.map +1 -0
- package/types/Enum.d.ts +13 -0
- package/types/Enum.js +18 -0
- package/types/Enum.js.map +1 -0
- package/types/Enum.mjs +18 -0
- package/types/Enum.mjs.map +1 -0
- package/types/File.d.ts +15 -0
- package/types/File.js +51 -0
- package/types/File.js.map +1 -0
- package/types/File.mjs +51 -0
- package/types/File.mjs.map +1 -0
- package/types/Map.d.ts +14 -0
- package/types/Map.js +24 -0
- package/types/Map.js.map +1 -0
- package/types/Map.mjs +24 -0
- package/types/Map.mjs.map +1 -0
- package/types/Number.d.ts +17 -0
- package/types/Number.js +66 -0
- package/types/Number.js.map +1 -0
- package/types/Number.mjs +66 -0
- package/types/Number.mjs.map +1 -0
- package/types/Object.d.ts +13 -0
- package/types/Object.js +27 -0
- package/types/Object.js.map +1 -0
- package/types/Object.mjs +27 -0
- package/types/Object.mjs.map +1 -0
- package/types/Record.d.ts +14 -0
- package/types/Record.js +24 -0
- package/types/Record.js.map +1 -0
- package/types/Record.mjs +24 -0
- package/types/Record.mjs.map +1 -0
- package/types/Set.d.ts +15 -0
- package/types/Set.js +36 -0
- package/types/Set.js.map +1 -0
- package/types/Set.mjs +36 -0
- package/types/Set.mjs.map +1 -0
- package/types/String.d.ts +19 -0
- package/types/String.js +84 -0
- package/types/String.js.map +1 -0
- package/types/String.mjs +84 -0
- package/types/String.mjs.map +1 -0
- package/types/Tuple.d.ts +13 -0
- package/types/Tuple.js +24 -0
- package/types/Tuple.js.map +1 -0
- package/types/Tuple.mjs +24 -0
- package/types/Tuple.mjs.map +1 -0
- package/types/Union.d.ts +13 -0
- package/types/Union.js +29 -0
- package/types/Union.js.map +1 -0
- package/types/Union.mjs +29 -0
- package/types/Union.mjs.map +1 -0
- package/types.d.ts +24 -0
package/XanvType.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { XVCheckCallback, XanvTransformCallback } from './types.js';
|
|
2
|
+
|
|
3
|
+
declare abstract class XanvType<TypeKeys extends string | number | symbol, Default> {
|
|
4
|
+
private checkes;
|
|
5
|
+
private _def;
|
|
6
|
+
abstract name: string;
|
|
7
|
+
protected abstract check(value: any): any;
|
|
8
|
+
set(key: TypeKeys, check: XVCheckCallback<Default>): void;
|
|
9
|
+
get(key: TypeKeys): XVCheckCallback<Default> | undefined;
|
|
10
|
+
optional(): this;
|
|
11
|
+
default(value: Default): this;
|
|
12
|
+
nullable(): this;
|
|
13
|
+
transform(cb: XanvTransformCallback<any>): void;
|
|
14
|
+
parse(value: any): Default | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { XanvType as default };
|
package/XanvType.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});class XanvType {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.checkes = new Map();
|
|
4
|
+
this._def = {
|
|
5
|
+
optional: false,
|
|
6
|
+
nullable: false,
|
|
7
|
+
default: undefined,
|
|
8
|
+
transform: undefined,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
set(key, check) {
|
|
12
|
+
this.checkes.set(key, check);
|
|
13
|
+
}
|
|
14
|
+
get(key) {
|
|
15
|
+
return this.checkes.get(key);
|
|
16
|
+
}
|
|
17
|
+
optional() {
|
|
18
|
+
this._def.optional = true;
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
default(value) {
|
|
22
|
+
this._def.default = value;
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
nullable() {
|
|
26
|
+
this._def.nullable = true;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
transform(cb) {
|
|
30
|
+
this._def.transform = cb;
|
|
31
|
+
}
|
|
32
|
+
parse(value) {
|
|
33
|
+
if (this._def.nullable && value === null) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (this._def.default !== undefined && (value === undefined || value === null)) {
|
|
37
|
+
return this._def.default;
|
|
38
|
+
}
|
|
39
|
+
if (this._def.optional && (value === undefined || value === null)) {
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
value = this.check(value) || value;
|
|
43
|
+
for (const [, check] of Array.from(this.checkes.entries())) {
|
|
44
|
+
check(value);
|
|
45
|
+
}
|
|
46
|
+
if (this._def.transform) {
|
|
47
|
+
value = this._def.transform(value);
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
}exports.default=XanvType;//# sourceMappingURL=XanvType.js.map
|
package/XanvType.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XanvType.js","sources":["../src/XanvType.ts"],"sourcesContent":["import { XanvTransformCallback, XVCheckCallback } from \"./types\";\n\nabstract class XanvType<TypeKeys extends string | number | symbol, Default> {\n private checkes = new Map<TypeKeys, XVCheckCallback<Default>>();\n private _def: any = {\n optional: false,\n nullable: false,\n default: undefined as Default | undefined,\n transform: undefined as XanvTransformCallback<Default> | undefined,\n }\n abstract name: string;\n protected abstract check(value: any): any;\n\n set(key: TypeKeys, check: XVCheckCallback<Default>) {\n this.checkes.set(key, check);\n }\n\n get(key: TypeKeys) {\n return this.checkes.get(key);\n }\n\n optional(): this {\n this._def.optional = true;\n return this\n }\n\n default(value: Default): this {\n this._def.default = value;\n return this\n }\n\n nullable(): this {\n this._def.nullable = true;\n return this\n }\n\n transform(cb: XanvTransformCallback<any>) {\n this._def.transform = cb\n }\n\n parse(value: any): Default | null {\n if (this._def.nullable && value === null) {\n return null;\n }\n\n if (this._def.default !== undefined && (value === undefined || value === null)) {\n return this._def.default;\n }\n\n if (this._def.optional && (value === undefined || value === null)) {\n return value;\n }\n\n value = this.check(value) || value;\n\n for (const [, check] of Array.from(this.checkes.entries())) {\n check(value);\n }\n\n if (this._def.transform) {\n value = this._def.transform(value);\n }\n\n return value;\n }\n}\n\nexport default XanvType;"],"names":[],"mappings":"sEAEA,MAAe,QAAQ,CAAA;AAAvB,IAAA,WAAA,GAAA;AACW,QAAA,IAAA,CAAA,OAAO,GAAG,IAAI,GAAG,EAAsC;AACvD,QAAA,IAAA,CAAA,IAAI,GAAQ;AACjB,YAAA,QAAQ,EAAE,KAAK;AACf,YAAA,QAAQ,EAAE,KAAK;AACf,YAAA,OAAO,EAAE,SAAgC;AACzC,YAAA,SAAS,EAAE,SAAuD;SACpE;IAwDJ;IApDG,GAAG,CAAC,GAAa,EAAE,KAA+B,EAAA;QAC/C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC;IAC/B;AAEA,IAAA,GAAG,CAAC,GAAa,EAAA;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAC/B;IAEA,QAAQ,GAAA;AACL,QAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI;AACzB,QAAA,O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,51 @@
|
|
|
1
|
+
class XanvType {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.checkes = new Map();
|
|
4
|
+
this._def = {
|
|
5
|
+
optional: false,
|
|
6
|
+
nullable: false,
|
|
7
|
+
default: undefined,
|
|
8
|
+
transform: undefined,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
set(key, check) {
|
|
12
|
+
this.checkes.set(key, check);
|
|
13
|
+
}
|
|
14
|
+
get(key) {
|
|
15
|
+
return this.checkes.get(key);
|
|
16
|
+
}
|
|
17
|
+
optional() {
|
|
18
|
+
this._def.optional = true;
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
default(value) {
|
|
22
|
+
this._def.default = value;
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
nullable() {
|
|
26
|
+
this._def.nullable = true;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
transform(cb) {
|
|
30
|
+
this._def.transform = cb;
|
|
31
|
+
}
|
|
32
|
+
parse(value) {
|
|
33
|
+
if (this._def.nullable && value === null) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (this._def.default !== undefined && (value === undefined || value === null)) {
|
|
37
|
+
return this._def.default;
|
|
38
|
+
}
|
|
39
|
+
if (this._def.optional && (value === undefined || value === null)) {
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
value = this.check(value) || value;
|
|
43
|
+
for (const [, check] of Array.from(this.checkes.entries())) {
|
|
44
|
+
check(value);
|
|
45
|
+
}
|
|
46
|
+
if (this._def.transform) {
|
|
47
|
+
value = this._def.transform(value);
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
}export{XanvType as default};//# sourceMappingURL=XanvType.mjs.map
|
package/XanvType.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XanvType.mjs","sources":["../src/XanvType.ts"],"sourcesContent":["import { XanvTransformCallback, XVCheckCallback } from \"./types\";\n\nabstract class XanvType<TypeKeys extends string | number | symbol, Default> {\n private checkes = new Map<TypeKeys, XVCheckCallback<Default>>();\n private _def: any = {\n optional: false,\n nullable: false,\n default: undefined as Default | undefined,\n transform: undefined as XanvTransformCallback<Default> | undefined,\n }\n abstract name: string;\n protected abstract check(value: any): any;\n\n set(key: TypeKeys, check: XVCheckCallback<Default>) {\n this.checkes.set(key, check);\n }\n\n get(key: TypeKeys) {\n return this.checkes.get(key);\n }\n\n optional(): this {\n this._def.optional = true;\n return this\n }\n\n default(value: Default): this {\n this._def.default = value;\n return this\n }\n\n nullable(): this {\n this._def.nullable = true;\n return this\n }\n\n transform(cb: XanvTransformCallback<any>) {\n this._def.transform = cb\n }\n\n parse(value: any): Default | null {\n if (this._def.nullable && value === null) {\n return null;\n }\n\n if (this._def.default !== undefined && (value === undefined || value === null)) {\n return this._def.default;\n }\n\n if (this._def.optional && (value === undefined || value === null)) {\n return value;\n }\n\n value = this.check(value) || value;\n\n for (const [, check] of Array.from(this.checkes.entries())) {\n check(value);\n }\n\n if (this._def.transform) {\n value = this._def.transform(value);\n }\n\n return value;\n }\n}\n\nexport default XanvType;"],"names":[],"mappings":"AAEA,MAAe,QAAQ,CAAA;AAAvB,IAAA,WAAA,GAAA;AACW,QAAA,IAAA,CAAA,OAAO,GAAG,IAAI,GAAG,EAAsC;AACvD,QAAA,IAAA,CAAA,IAAI,GAAQ;AACjB,YAAA,QAAQ,EAAE,KAAK;AACf,YAAA,QAAQ,EAAE,KAAK;AACf,YAAA,OAAO,EAAE,SAAgC;AACzC,YAAA,SAAS,EAAE,SAAuD;SACpE;IAwDJ;IApDG,GAAG,CAAC,GAAa,EAAE,KAA+B,EAAA;QAC/C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC;IAC/B;AAEA,IAAA,GAAG,CAAC,GAAa,EAAA;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAC/B;I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C;AACpC,QAAA;AAED,QAAA,OAAO,KAAK;IACf;AACF"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export { default as XVAny } from './types/Any.js';
|
|
2
|
+
import XVArray from './types/Array.js';
|
|
3
|
+
import XVBoolean from './types/Boolean.js';
|
|
4
|
+
import XVDate from './types/Date.js';
|
|
5
|
+
import XVEnum from './types/Enum.js';
|
|
6
|
+
export { default as XVFile } from './types/File.js';
|
|
7
|
+
import XVMap from './types/Map.js';
|
|
8
|
+
import XVNumber from './types/Number.js';
|
|
9
|
+
import XVObject from './types/Object.js';
|
|
10
|
+
import XVRecord from './types/Record.js';
|
|
11
|
+
import XVSet from './types/Set.js';
|
|
12
|
+
import XVString from './types/String.js';
|
|
13
|
+
import XVTuple from './types/Tuple.js';
|
|
14
|
+
import XVUnion from './types/Union.js';
|
|
15
|
+
import { XVInstanceType, XVEnumValues, XVObjectType } from './types.js';
|
|
16
|
+
export { XVCheckCallback, XVObjectKeyType, XVObjectValueType } from './types.js';
|
|
17
|
+
|
|
18
|
+
declare const xv: {
|
|
19
|
+
array: (type: XVInstanceType, length?: number) => XVArray;
|
|
20
|
+
boolean: () => XVBoolean;
|
|
21
|
+
date: () => XVDate;
|
|
22
|
+
enum: (values: XVEnumValues) => XVEnum;
|
|
23
|
+
map: (key: XVInstanceType, value: XVInstanceType) => XVMap;
|
|
24
|
+
number: (length?: number) => XVNumber;
|
|
25
|
+
object: (arg?: XVObjectType) => XVObject;
|
|
26
|
+
record: (key: XVInstanceType, value: XVInstanceType) => XVRecord;
|
|
27
|
+
set: (type: XVInstanceType) => XVSet;
|
|
28
|
+
string: (length?: number) => XVString;
|
|
29
|
+
tuple: (type: XVInstanceType[]) => XVTuple;
|
|
30
|
+
union: (type: XVInstanceType[]) => XVUnion;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { XVArray, XVBoolean, XVDate, XVEnum, XVEnumValues, XVInstanceType, XVMap, XVNumber, XVObject, XVObjectType, XVRecord, XVSet, XVString, XVTuple, XVUnion, xv };
|
package/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var Any=require('./types/Any.js'),Array=require('./types/Array.js'),Boolean=require('./types/Boolean.js'),Date=require('./types/Date.js'),Enum=require('./types/Enum.js'),File=require('./types/File.js'),Map=require('./types/Map.js'),Number=require('./types/Number.js'),Object$1=require('./types/Object.js'),Record=require('./types/Record.js'),Set=require('./types/Set.js'),String=require('./types/String.js'),Tuple=require('./types/Tuple.js'),Union=require('./types/Union.js');const xv = {
|
|
2
|
+
array: (type, length) => new Array.default(type, length),
|
|
3
|
+
boolean: () => new Boolean.default(),
|
|
4
|
+
date: () => new Date.default(),
|
|
5
|
+
enum: (values) => new Enum.default(values),
|
|
6
|
+
map: (key, value) => new Map.default(key, value),
|
|
7
|
+
number: (length) => new Number.default(length),
|
|
8
|
+
object: (arg) => new Object$1.default(arg),
|
|
9
|
+
record: (key, value) => new Record.default(key, value),
|
|
10
|
+
set: (type) => new Set.default(type),
|
|
11
|
+
string: (length) => new String.default(length),
|
|
12
|
+
tuple: (type) => new Tuple.default(type),
|
|
13
|
+
union: (type) => new Union.default(type),
|
|
14
|
+
};exports.XVAny=Any.default;exports.XVArray=Array.default;exports.XVBoolean=Boolean.default;exports.XVDate=Date.default;exports.XVEnum=Enum.default;exports.XVFile=File.default;exports.XVMap=Map.default;exports.XVNumber=Number.default;exports.XVObject=Object$1.default;exports.XVRecord=Record.default;exports.XVSet=Set.default;exports.XVString=String.default;exports.XVTuple=Tuple.default;exports.XVUnion=Union.default;exports.xv=xv;//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import XVAny from \"./types/Any\";\nimport XVArray from \"./types/Array\";\nimport XVBoolean from \"./types/Boolean\";\nimport XVDate from \"./types/Date\";\nimport XVEnum from \"./types/Enum\";\nimport XVFile from \"./types/File\";\nimport XVMap from \"./types/Map\";\nimport XVNumber from \"./types/Number\";\nimport XVObject from \"./types/Object\";\nimport XVRecord from \"./types/Record\";\nimport XVSet from \"./types/Set\";\nimport XVString from \"./types/String\";\nimport XVTuple from \"./types/Tuple\";\nimport XVUnion from \"./types/Union\";\nimport {\n XVEnumValues,\n XVInstanceType,\n XVObjectType,\n XVCheckCallback,\n XVObjectKeyType,\n XVObjectValueType,\n} from \"./types\";\n\nexport type {\n XVEnumValues,\n XVInstanceType,\n XVObjectType,\n XVCheckCallback,\n XVObjectKeyType,\n XVObjectValueType,\n};\n\nexport {\n XVAny,\n XVArray,\n XVBoolean,\n XVDate,\n XVEnum,\n XVFile,\n XVMap,\n XVNumber,\n XVObject,\n XVRecord,\n XVSet,\n XVString,\n XVTuple,\n XVUnion,\n};\n\nexport const xv = {\n array: (type: XVInstanceType, length?: number) => new XVArray(type, length),\n boolean: () => new XVBoolean(),\n date: () => new XVDate(),\n enum: (values: XVEnumValues) => new XVEnum(values),\n map: (key: XVInstanceType, value: XVInstanceType) => new XVMap(key, value),\n number: (length?: number) => new XVNumber(length),\n object: (arg?: XVObjectType) => new XVObject(arg),\n record: (key: XVInstanceType, value: XVInstanceType) => new XVRecord(key, value),\n set: (type: XVInstanceType) => new XVSet(type),\n string: (length?: number) => new XVString(length),\n tuple: (type: XVInstanceType[]) => new XVTuple(type),\n union: (type: XVInstanceType[]) => new XVUnion(type),\n}\n\n"],"names":["XVArray","XVBoolean","XVDate","XVEnum","XVMap","XVNumber","XVObject","XVRecord","XVSet","XVString","XVTuple","XVUnion"],"mappings":"kiBAiDO,MAAM,EAAE,GAAG;AACf,IAAA,KAAK,EAAE,CAAC,IAAoB,EAAE,MAAe,KAAK,IAAIA,aAAO,CAAC,IAAI,EAAE,MAAM,CAAC;AAC3E,IAAA,OAAO,EAAE,MAAM,IAAIC,eAAS,EAAE;AAC9B,IAAA,IAAI,EAAE,MAAM,IAAIC,YAAM,EAAE;IACxB,IAAI,EAAE,CAAC,MAAoB,KAAK,IAAIC,YAAM,CAAC,MAAM,CAAC;AAClD,IAAA,GAAG,EAAE,CAAC,GAAmB,EAAE,KAAqB,KAAK,IAAIC,WAAK,CAAC,GAAG,EAAE,KAAK,CAAC;IAC1E,MAAM,EAAE,CAAC,MAAe,KAAK,IAAIC,cAAQ,CAAC,MAAM,CAAC;IACjD,MAAM,EAAE,CAAC,GAAkB,KAAK,IAAIC,gBAAQ,CAAC,GAAG,CAAC;AACjD,IAAA,MAAM,EAAE,CAAC,GAAmB,EAAE,KAAqB,KAAK,IAAIC,cAAQ,CAAC,GAAG,EAAE,KAAK,CAAC;IAChF,GAAG,EAAE,CAAC,IAAoB,KAAK,IAAIC,WAAK,CAAC,IAAI,CAAC;IAC9C,MAAM,EAAE,CAAC,MAAe,KAAK,IAAIC,cAAQ,CAAC,MAAM,CAAC;IACjD,KAAK,EAAE,CAAC,IAAsB,KAAK,IAAIC,aAAO,CAAC,IAAI,CAAC;IACpD,KAAK,EAAE,CAAC,IAAsB,KAAK,IAAIC,aAAO,CAAC,IAAI,CAAC;"}
|
package/index.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export{default as XVAny}from'./types/Any.mjs';import XVArray from'./types/Array.mjs';import XVBoolean from'./types/Boolean.mjs';import XVDate from'./types/Date.mjs';import XVEnum from'./types/Enum.mjs';export{default as XVFile}from'./types/File.mjs';import XVMap from'./types/Map.mjs';import XVNumber from'./types/Number.mjs';import XVObject from'./types/Object.mjs';import XVRecord from'./types/Record.mjs';import XVSet from'./types/Set.mjs';import XVString from'./types/String.mjs';import XVTuple from'./types/Tuple.mjs';import XVUnion from'./types/Union.mjs';const xv = {
|
|
2
|
+
array: (type, length) => new XVArray(type, length),
|
|
3
|
+
boolean: () => new XVBoolean(),
|
|
4
|
+
date: () => new XVDate(),
|
|
5
|
+
enum: (values) => new XVEnum(values),
|
|
6
|
+
map: (key, value) => new XVMap(key, value),
|
|
7
|
+
number: (length) => new XVNumber(length),
|
|
8
|
+
object: (arg) => new XVObject(arg),
|
|
9
|
+
record: (key, value) => new XVRecord(key, value),
|
|
10
|
+
set: (type) => new XVSet(type),
|
|
11
|
+
string: (length) => new XVString(length),
|
|
12
|
+
tuple: (type) => new XVTuple(type),
|
|
13
|
+
union: (type) => new XVUnion(type),
|
|
14
|
+
};export{XVArray,XVBoolean,XVDate,XVEnum,XVMap,XVNumber,XVObject,XVRecord,XVSet,XVString,XVTuple,XVUnion,xv};//# sourceMappingURL=index.mjs.map
|
package/index.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import XVAny from \"./types/Any\";\nimport XVArray from \"./types/Array\";\nimport XVBoolean from \"./types/Boolean\";\nimport XVDate from \"./types/Date\";\nimport XVEnum from \"./types/Enum\";\nimport XVFile from \"./types/File\";\nimport XVMap from \"./types/Map\";\nimport XVNumber from \"./types/Number\";\nimport XVObject from \"./types/Object\";\nimport XVRecord from \"./types/Record\";\nimport XVSet from \"./types/Set\";\nimport XVString from \"./types/String\";\nimport XVTuple from \"./types/Tuple\";\nimport XVUnion from \"./types/Union\";\nimport {\n XVEnumValues,\n XVInstanceType,\n XVObjectType,\n XVCheckCallback,\n XVObjectKeyType,\n XVObjectValueType,\n} from \"./types\";\n\nexport type {\n XVEnumValues,\n XVInstanceType,\n XVObjectType,\n XVCheckCallback,\n XVObjectKeyType,\n XVObjectValueType,\n};\n\nexport {\n XVAny,\n XVArray,\n XVBoolean,\n XVDate,\n XVEnum,\n XVFile,\n XVMap,\n XVNumber,\n XVObject,\n XVRecord,\n XVSet,\n XVString,\n XVTuple,\n XVUnion,\n};\n\nexport const xv = {\n array: (type: XVInstanceType, length?: number) => new XVArray(type, length),\n boolean: () => new XVBoolean(),\n date: () => new XVDate(),\n enum: (values: XVEnumValues) => new XVEnum(values),\n map: (key: XVInstanceType, value: XVInstanceType) => new XVMap(key, value),\n number: (length?: number) => new XVNumber(length),\n object: (arg?: XVObjectType) => new XVObject(arg),\n record: (key: XVInstanceType, value: XVInstanceType) => new XVRecord(key, value),\n set: (type: XVInstanceType) => new XVSet(type),\n string: (length?: number) => new XVString(length),\n tuple: (type: XVInstanceType[]) => new XVTuple(type),\n union: (type: XVInstanceType[]) => new XVUnion(type),\n}\n\n"],"names":[],"mappings":"kjBAiDO,MAAM,EAAE,GAAG;AACf,IAAA,KAAK,EAAE,CAAC,IAAoB,EAAE,MAAe,KAAK,IAAI,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;AAC3E,IAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE;AAC9B,IAAA,IAAI,EAAE,MAAM,IAAI,MAAM,EAAE;IACxB,IAAI,EAAE,CAAC,MAAoB,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC;AAClD,IAAA,GAAG,EAAE,CAAC,GAAmB,EAAE,KAAqB,KAAK,IAAI,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC;IAC1E,MAAM,EAAE,CAAC,MAAe,KAAK,IAAI,QAAQ,CAAC,MAAM,CAAC;IACjD,MAAM,EAAE,CAAC,GAAkB,KAAK,IAAI,QAAQ,CAAC,GAAG,CAAC;AACjD,IAAA,MAAM,EAAE,CAAC,GAAmB,EAAE,KAAqB,KAAK,IAAI,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC;IAChF,GAAG,EAAE,CAAC,IAAoB,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC;IAC9C,MAAM,EAAE,CAAC,MAAe,KAAK,IAAI,QAAQ,CAAC,MAAM,CAAC;IACjD,KAAK,EAAE,CAAC,IAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IACpD,KAAK,EAAE,CAAC,IAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "xanv",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"types": "./index.d.ts",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"module": "./index.mjs",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
"@types/react": "^19.0.2",
|
|
10
|
+
"@types/react-dom": "^19.0.2",
|
|
11
|
+
"makepack": "^1.7.12",
|
|
12
|
+
"react": "^19.0.0",
|
|
13
|
+
"react-dom": "^19.0.0",
|
|
14
|
+
"typescript": "^4.4.2"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./index.mjs",
|
|
19
|
+
"require": "./index.js",
|
|
20
|
+
"types": "./index.d.ts"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"description": "",
|
|
24
|
+
"keywords": [],
|
|
25
|
+
"author": {
|
|
26
|
+
"name": "Naxrul Ahmed",
|
|
27
|
+
"email": "devnaxrul@gmail.com"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/devnax/youid.git"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# `youid`
|
|
2
|
+
|
|
3
|
+
`youid` is a lightweight JavaScript function that generates unique identifiers (UIDs) from strings. It can also generate random UIDs if no string input is provided. `youid` is flexible, allowing you to specify the length of the UID.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
To install `youid` as an npm package:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install youid
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
`youid` provides a simple API to generate UIDs from strings or create random UIDs. The function takes two optional parameters:
|
|
16
|
+
|
|
17
|
+
- `str` (optional): The input string from which the UID will be generated.
|
|
18
|
+
- `length` (optional): The desired length of the UID.
|
|
19
|
+
|
|
20
|
+
### Importing the Function
|
|
21
|
+
|
|
22
|
+
If using a module bundler:
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
import youid from 'youid';
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Generating a UID
|
|
29
|
+
|
|
30
|
+
#### 1. UID from a String
|
|
31
|
+
To generate a UID based on a string:
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
const uid = youid('HelloWorld');
|
|
35
|
+
console.log(uid); // Example output: "j1m3q4v9"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### 2. Specifying the Length
|
|
39
|
+
You can control the length of the generated UID:
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
const uid = youid('HelloWorld', 10);
|
|
43
|
+
console.log(uid); // Example output: "j1m3q4v900"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### 3. Generating a Random UID
|
|
47
|
+
If no string is provided, `youid` generates a random UID:
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
const randomUID = youid();
|
|
51
|
+
console.log(randomUID); // Example output: "x5y7z1w8a2"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Function Signature
|
|
55
|
+
```javascript
|
|
56
|
+
const youid = (str?: string, length?: number) => string;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Parameters
|
|
60
|
+
1. **`str`** *(optional)*: A string input to generate a hash-based UID.
|
|
61
|
+
- If omitted, a random UID generator function is returned.
|
|
62
|
+
|
|
63
|
+
2. **`length`** *(optional)*: The desired length of the UID.
|
|
64
|
+
- Defaults to the full length of the generated hash or random string.
|
|
65
|
+
|
|
66
|
+
### Return Value
|
|
67
|
+
- **If `str` is provided**: A string UID based on the input string.
|
|
68
|
+
- **If `str` is omitted**: A function that generates random UIDs, optionally constrained by `length`.
|
|
69
|
+
|
|
70
|
+
## Examples
|
|
71
|
+
|
|
72
|
+
### Basic Examples
|
|
73
|
+
#### Hash-Based UID:
|
|
74
|
+
```javascript
|
|
75
|
+
const uid = youid('MyString');
|
|
76
|
+
console.log(uid); // Example output: "k9l2m5"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### Length-Controlled UID:
|
|
80
|
+
```javascript
|
|
81
|
+
const uid = youid('AnotherString', 12);
|
|
82
|
+
console.log(uid); // Example output: "k9l2m5n0pqr8"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### Random UID:
|
|
86
|
+
```javascript
|
|
87
|
+
const randomUID = youid(null, 8);
|
|
88
|
+
console.log(randomUID); // Example output: "abc123xy"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Real-World Usage
|
|
92
|
+
#### Generating IDs for HTML Elements:
|
|
93
|
+
```javascript
|
|
94
|
+
const elementID = youid('button-submit', 10);
|
|
95
|
+
document.getElementById('my-element').id = elementID;
|
|
96
|
+
console.log(elementID); // Example output: "b8t9w7z6x1"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### Random UIDs for Testing:
|
|
100
|
+
```javascript
|
|
101
|
+
const randomIDGenerate = youid();
|
|
102
|
+
console.log(randomIDGenerate); // Example output: "a9b3c5d7"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## How It Works
|
|
106
|
+
|
|
107
|
+
1. If a string is provided, the function computes a hash using bitwise operations and converts it to a base-36 representation.
|
|
108
|
+
2. If `length` is specified, the UID is padded or truncated to match the desired length.
|
|
109
|
+
3. If no string is provided, the function returns another function that generates random UIDs using `Math.random()`.
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
`youid` is open-source software licensed under the [MIT License](LICENSE).
|
|
114
|
+
|
|
115
|
+
## Contributions
|
|
116
|
+
|
|
117
|
+
Contributions are welcome! Please open an issue or submit a pull request on [GitHub](https://github.com/devnax/`youid`).
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
For any issues or inquiries, please contact the [maintainer](mailto:edvnaxrul@gmail.com).
|
package/types/Any.d.ts
ADDED
package/types/Any.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var XanvType=require('../XanvType.js');class XVAny extends XanvType.default {
|
|
2
|
+
constructor() {
|
|
3
|
+
super(...arguments);
|
|
4
|
+
this.name = 'XVAny';
|
|
5
|
+
}
|
|
6
|
+
check(value) {
|
|
7
|
+
}
|
|
8
|
+
}exports.default=XVAny;//# sourceMappingURL=Any.js.map
|
package/types/Any.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Any.js","sources":["../../src/types/Any.ts"],"sourcesContent":["import XanvType from \"../XanvType\";\nexport type XVAnyInfo = \"\"\nclass XVAny extends XanvType<XVAnyInfo, boolean> {\n name: string = 'XVAny';\n protected check(value: any) {\n }\n}\n\nexport default XVAny;"],"names":["XanvType"],"mappings":"6GAEA,MAAM,KAAM,SAAQA,gBAA4B,CAAA;AAAhD,IAAA,WAAA,GAAA;;QACG,IAAA,CAAA,IAAI,GAAW,OAAO;IAGzB;AAFa,IAAA,KAAK,CAAC,KAAU,EAAA;IAC1B;AACF"}
|
package/types/Any.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Any.mjs","sources":["../../src/types/Any.ts"],"sourcesContent":["import XanvType from \"../XanvType\";\nexport type XVAnyInfo = \"\"\nclass XVAny extends XanvType<XVAnyInfo, boolean> {\n name: string = 'XVAny';\n protected check(value: any) {\n }\n}\n\nexport default XVAny;"],"names":[],"mappings":"sCAEA,MAAM,KAAM,SAAQ,QAA4B,CAAA;AAAhD,IAAA,WAAA,GAAA;;QACG,IAAA,CAAA,IAAI,GAAW,OAAO;IAGzB;AAFa,IAAA,KAAK,CAAC,KAAU,EAAA;IAC1B;AACF"}
|
package/types/Array.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import XanvType from '../XanvType.js';
|
|
2
|
+
import { XVInstanceType } from '../types.js';
|
|
3
|
+
|
|
4
|
+
type XVArrayInfo = "min" | "max" | "unique";
|
|
5
|
+
declare class XVArray extends XanvType<XVArrayInfo, any[]> {
|
|
6
|
+
private type?;
|
|
7
|
+
private length?;
|
|
8
|
+
name: string;
|
|
9
|
+
constructor(type?: XVInstanceType, length?: number);
|
|
10
|
+
protected check(value: any): void;
|
|
11
|
+
min(length: number): this;
|
|
12
|
+
max(length: number): this;
|
|
13
|
+
unique(): this;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { XVArray as default };
|
|
17
|
+
export type { XVArrayInfo };
|
package/types/Array.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var Map=require('./Map.js'),Object$1=require('./Object.js'),Record=require('./Record.js'),XanvType=require('../XanvType.js');class XVArray extends XanvType.default {
|
|
2
|
+
constructor(type, length) {
|
|
3
|
+
super();
|
|
4
|
+
this.name = "XanvArray";
|
|
5
|
+
this.type = type;
|
|
6
|
+
this.length = length;
|
|
7
|
+
}
|
|
8
|
+
check(value) {
|
|
9
|
+
let _value = value;
|
|
10
|
+
if (!Array.isArray(value)) {
|
|
11
|
+
throw new Error(`Value should be an array, received ${typeof value}`);
|
|
12
|
+
}
|
|
13
|
+
if (this.length !== undefined && value.length !== this.length) {
|
|
14
|
+
throw new Error(`Array length should be ${this.length}, received ${value.length}`);
|
|
15
|
+
}
|
|
16
|
+
if (this.type) {
|
|
17
|
+
for (let i = 0; i < value.length; i++) {
|
|
18
|
+
const item = value[i];
|
|
19
|
+
try {
|
|
20
|
+
_value[i] = this.type.parse(item);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw new Error(`Array item at index ${i} should be of type ${this.type.name}, received ${typeof item}: ${error.message}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return _value;
|
|
28
|
+
}
|
|
29
|
+
min(length) {
|
|
30
|
+
this.set("min", v => {
|
|
31
|
+
if (v.length < length) {
|
|
32
|
+
throw new Error(`Array length should be at least ${length} items, received ${v.length}`);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
max(length) {
|
|
38
|
+
this.set("max", v => {
|
|
39
|
+
if (v.length > length) {
|
|
40
|
+
throw new Error(`Array length should not exceed ${length} items, received ${v.length}`);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
unique() {
|
|
46
|
+
this.set("unique", v => {
|
|
47
|
+
let format = [];
|
|
48
|
+
for (let i = 0; i < v.length; i++) {
|
|
49
|
+
if (this.type instanceof Object$1.default || this.type instanceof Record.default) {
|
|
50
|
+
const u = JSON.stringify(v[i]);
|
|
51
|
+
if (format.includes(u)) {
|
|
52
|
+
throw new Error(`Array items should be unique, found duplicate: ${u}`);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
format.push(u);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (this.type instanceof XVArray) {
|
|
59
|
+
const u = JSON.stringify(v[i]);
|
|
60
|
+
if (format.includes(u)) {
|
|
61
|
+
throw new Error(`Array items should be unique, found duplicate: ${u}`);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
format.push(u);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else if (this.type instanceof Map.default) {
|
|
68
|
+
const u = JSON.stringify(Array.from(v.entries()));
|
|
69
|
+
if (format.includes(u)) {
|
|
70
|
+
throw new Error(`Array items should be unique, found duplicate: ${u}`);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
format.push(u);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const uitems = new Set(v);
|
|
78
|
+
if (uitems.size !== v.length) {
|
|
79
|
+
throw new Error(`Array items should be unique, found duplicates`);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
}exports.default=XVArray;//# sourceMappingURL=Array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Array.js","sources":["../../src/types/Array.ts"],"sourcesContent":["import XVMap from \"./Map\";\nimport XVObject from \"./Object\";\nimport XVRecord from \"./Record\";\nimport XanvType from \"../XanvType\";\nimport { XVInstanceType } from \"../types\";\n\nexport type XVArrayInfo = \"min\" | \"max\" | \"unique\"\n\nclass XVArray extends XanvType<XVArrayInfo, any[]> {\n private type?: XVInstanceType;\n private length?: number;\n name = \"XanvArray\";\n\n constructor(type?: XVInstanceType, length?: number) {\n super();\n this.type = type;\n this.length = length;\n }\n\n protected check(value: any): void {\n let _value = value;\n if (!Array.isArray(value)) {\n throw new Error(`Value should be an array, received ${typeof value}`);\n }\n\n if (this.length !== undefined && value.length !== this.length) {\n throw new Error(`Array length should be ${this.length}, received ${value.length}`);\n }\n\n if (this.type) {\n for (let i = 0; i < value.length; i++) {\n const item = value[i];\n try {\n _value[i] = this.type.parse(item);\n } catch (error: any) {\n throw new Error(`Array item at index ${i} should be of type ${this.type.name}, received ${typeof item}: ${error.message}`);\n }\n }\n }\n return _value;\n }\n\n min(length: number): this {\n this.set(\"min\", v => {\n if (v.length < length) {\n throw new Error(`Array length should be at least ${length} items, received ${v.length}`)\n }\n });\n return this;\n }\n\n max(length: number): this {\n this.set(\"max\", v => {\n if (v.length > length) {\n throw new Error(`Array length should not exceed ${length} items, received ${v.length}`)\n }\n });\n return this;\n }\n\n unique(): this {\n this.set(\"unique\", v => {\n let format: any = []\n for (let i = 0; i < v.length; i++) {\n if (this.type instanceof XVObject || this.type instanceof XVRecord) {\n const u = JSON.stringify(v[i]);\n if (format.includes(u)) {\n throw new Error(`Array items should be unique, found duplicate: ${u}`);\n } else {\n format.push(u);\n }\n } else if (this.type instanceof XVArray) {\n const u = JSON.stringify(v[i]);\n if (format.includes(u)) {\n throw new Error(`Array items should be unique, found duplicate: ${u}`);\n } else {\n format.push(u);\n }\n } else if (this.type instanceof XVMap) {\n const u = JSON.stringify(Array.from(v.entries()));\n if (format.includes(u)) {\n throw new Error(`Array items should be unique, found duplicate: ${u}`);\n } else {\n format.push(u);\n }\n }\n }\n\n const uitems = new Set(v);\n if (uitems.size !== v.length) {\n throw new Error(`Array items should be unique, found duplicates`);\n }\n });\n return this;\n }\n\n}\n\nexport default XVArray;"],"names":["XanvType","XVObject","XVRecord","XVMap"],"mappings":"mMAQA,MAAM,OAAQ,SAAQA,gBAA4B,CAAA;IAK/C,WAAA,CAAY,IAAqB,EAAE,MAAe,EAAA;AAC/C,QAAA,KAAK,EAAE;QAHV,IAAA,CAAA,IAAI,GAAG,WAAW;AAIf,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI;AAChB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;IACvB;AAEU,IAAA,KAAK,CAAC,KAAU,EAAA;QACvB,IAAI,MAAM,GAAG,KAAK;AAClB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACxB,MAAM,IAAI,KAAK,CAAC,CAAA,mCAAA,EAAsC,OAAO,KAAK,CAAA,CAAE,CAAC;AACvE,QAAA;AAED,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE;AAC5D,YAAA,MAAM,IAAI,KAAK,CAAC,CAAA,uBAAA,EAA0B,IAAI,CAAC,MAAM,CAAA,WAAA,EAAc,KAAK,CAAC,MAAM,CAAA,CAAE,CAAC;AACpF,QAAA;QAED,IAAI,IAAI,CAAC,IAAI,EAAE;AACZ,YAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACpC,gBAAA,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC;gBACrB,IAAI;AACD,oBAAA,MAAM,CAAC,CAAC,CAAC,GAAG,IA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;AACzB,YAAA,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,MAAM,EAAE;AAC3B,gBAAA,MAAM,IAAI,KAAK,CAAC,CAAA,8CAAA,CAAgD,CAAC;AACnE,YAAA;AACJ,QAAA,CAAC,CAAC;AACF,QAAA,OAAO,IAAI;IACd;AAEF"}
|
package/types/Array.mjs
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import XVMap from'./Map.mjs';import XVObject from'./Object.mjs';import XVRecord from'./Record.mjs';import XanvType from'../XanvType.mjs';class XVArray extends XanvType {
|
|
2
|
+
constructor(type, length) {
|
|
3
|
+
super();
|
|
4
|
+
this.name = "XanvArray";
|
|
5
|
+
this.type = type;
|
|
6
|
+
this.length = length;
|
|
7
|
+
}
|
|
8
|
+
check(value) {
|
|
9
|
+
let _value = value;
|
|
10
|
+
if (!Array.isArray(value)) {
|
|
11
|
+
throw new Error(`Value should be an array, received ${typeof value}`);
|
|
12
|
+
}
|
|
13
|
+
if (this.length !== undefined && value.length !== this.length) {
|
|
14
|
+
throw new Error(`Array length should be ${this.length}, received ${value.length}`);
|
|
15
|
+
}
|
|
16
|
+
if (this.type) {
|
|
17
|
+
for (let i = 0; i < value.length; i++) {
|
|
18
|
+
const item = value[i];
|
|
19
|
+
try {
|
|
20
|
+
_value[i] = this.type.parse(item);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw new Error(`Array item at index ${i} should be of type ${this.type.name}, received ${typeof item}: ${error.message}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return _value;
|
|
28
|
+
}
|
|
29
|
+
min(length) {
|
|
30
|
+
this.set("min", v => {
|
|
31
|
+
if (v.length < length) {
|
|
32
|
+
throw new Error(`Array length should be at least ${length} items, received ${v.length}`);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
max(length) {
|
|
38
|
+
this.set("max", v => {
|
|
39
|
+
if (v.length > length) {
|
|
40
|
+
throw new Error(`Array length should not exceed ${length} items, received ${v.length}`);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
unique() {
|
|
46
|
+
this.set("unique", v => {
|
|
47
|
+
let format = [];
|
|
48
|
+
for (let i = 0; i < v.length; i++) {
|
|
49
|
+
if (this.type instanceof XVObject || this.type instanceof XVRecord) {
|
|
50
|
+
const u = JSON.stringify(v[i]);
|
|
51
|
+
if (format.includes(u)) {
|
|
52
|
+
throw new Error(`Array items should be unique, found duplicate: ${u}`);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
format.push(u);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (this.type instanceof XVArray) {
|
|
59
|
+
const u = JSON.stringify(v[i]);
|
|
60
|
+
if (format.includes(u)) {
|
|
61
|
+
throw new Error(`Array items should be unique, found duplicate: ${u}`);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
format.push(u);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else if (this.type instanceof XVMap) {
|
|
68
|
+
const u = JSON.stringify(Array.from(v.entries()));
|
|
69
|
+
if (format.includes(u)) {
|
|
70
|
+
throw new Error(`Array items should be unique, found duplicate: ${u}`);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
format.push(u);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const uitems = new Set(v);
|
|
78
|
+
if (uitems.size !== v.length) {
|
|
79
|
+
throw new Error(`Array items should be unique, found duplicates`);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
}export{XVArray as default};//# sourceMappingURL=Array.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Array.mjs","sources":["../../src/types/Array.ts"],"sourcesContent":["import XVMap from \"./Map\";\nimport XVObject from \"./Object\";\nimport XVRecord from \"./Record\";\nimport XanvType from \"../XanvType\";\nimport { XVInstanceType } from \"../types\";\n\nexport type XVArrayInfo = \"min\" | \"max\" | \"unique\"\n\nclass XVArray extends XanvType<XVArrayInfo, any[]> {\n private type?: XVInstanceType;\n private length?: number;\n name = \"XanvArray\";\n\n constructor(type?: XVInstanceType, length?: number) {\n super();\n this.type = type;\n this.length = length;\n }\n\n protected check(value: any): void {\n let _value = value;\n if (!Array.isArray(value)) {\n throw new Error(`Value should be an array, received ${typeof value}`);\n }\n\n if (this.length !== undefined && value.length !== this.length) {\n throw new Error(`Array length should be ${this.length}, received ${value.length}`);\n }\n\n if (this.type) {\n for (let i = 0; i < value.length; i++) {\n const item = value[i];\n try {\n _value[i] = this.type.parse(item);\n } catch (error: any) {\n throw new Error(`Array item at index ${i} should be of type ${this.type.name}, received ${typeof item}: ${error.message}`);\n }\n }\n }\n return _value;\n }\n\n min(length: number): this {\n this.set(\"min\", v => {\n if (v.length < length) {\n throw new Error(`Array length should be at least ${length} items, received ${v.length}`)\n }\n });\n return this;\n }\n\n max(length: number): this {\n this.set(\"max\", v => {\n if (v.length > length) {\n throw new Error(`Array length should not exceed ${length} items, received ${v.length}`)\n }\n });\n return this;\n }\n\n unique(): this {\n this.set(\"unique\", v => {\n let format: any = []\n for (let i = 0; i < v.length; i++) {\n if (this.type instanceof XVObject || this.type instanceof XVRecord) {\n const u = JSON.stringify(v[i]);\n if (format.includes(u)) {\n throw new Error(`Array items should be unique, found duplicate: ${u}`);\n } else {\n format.push(u);\n }\n } else if (this.type instanceof XVArray) {\n const u = JSON.stringify(v[i]);\n if (format.includes(u)) {\n throw new Error(`Array items should be unique, found duplicate: ${u}`);\n } else {\n format.push(u);\n }\n } else if (this.type instanceof XVMap) {\n const u = JSON.stringify(Array.from(v.entries()));\n if (format.includes(u)) {\n throw new Error(`Array items should be unique, found duplicate: ${u}`);\n } else {\n format.push(u);\n }\n }\n }\n\n const uitems = new Set(v);\n if (uitems.size !== v.length) {\n throw new Error(`Array items should be unique, found duplicates`);\n }\n });\n return this;\n }\n\n}\n\nexport default XVArray;"],"names":[],"mappings":"yIAQA,MAAM,OAAQ,SAAQ,QAA4B,CAAA;IAK/C,WAAA,CAAY,IAAqB,EAAE,MAAe,EAAA;AAC/C,QAAA,KAAK,EAAE;QAHV,IAAA,CAAA,IAAI,GAAG,WAAW;AAIf,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI;AAChB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;IACvB;AAEU,IAAA,KAAK,CAAC,KAAU,EAAA;QACvB,IAAI,MAAM,GAAG,KAAK;AAClB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACxB,MAAM,IAAI,KAAK,CAAC,CAAA,mCAAA,EAAsC,OAAO,KAAK,CAAA,CAAE,CAAC;AACvE,QAAA;AAED,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE;AAC5D,YAAA,MAAM,IAAI,KAAK,CAAC,CAAA,uBAAA,EAA0B,IAAI,CAAC,MAAM,CAAA,WAAA,EAAc,KAAK,CAAC,MAAM,CAAA,CAAE,CAAC;AACpF,QAAA;QAED,IAAI,IAAI,CAAC,IAAI,EAAE;AACZ,YAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACpC,gBAAA,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC;gBACrB,IAAI;AACD,oBAAA,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;AACnC,gBAAA;AAAC,gBAAA,OAAO,KAAU,EAAE;oBAClB,MAAM,IAAI,KAAK,CAAC,CAAA,oBAAA,EAAuB,CAAC,CAAA,mBAAA,EAAsB,IAAI,CAAC,IAAI,CAAC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