@tikkhun/nested-args 0.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/README.md +8 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +4 -0
- package/dist/index.mjs +4 -0
- package/dist/nested-args.d.mts +12 -0
- package/dist/nested-args.d.ts +12 -0
- package/dist/nested-args.js +4 -0
- package/dist/nested-args.mjs +4 -0
- package/dist/paramTypes/array.type.d.mts +9 -0
- package/dist/paramTypes/array.type.d.ts +9 -0
- package/dist/paramTypes/array.type.js +4 -0
- package/dist/paramTypes/array.type.mjs +4 -0
- package/dist/paramTypes/boolean.type.d.mts +7 -0
- package/dist/paramTypes/boolean.type.d.ts +7 -0
- package/dist/paramTypes/boolean.type.js +4 -0
- package/dist/paramTypes/boolean.type.mjs +4 -0
- package/dist/paramTypes/index.d.mts +8 -0
- package/dist/paramTypes/index.d.ts +8 -0
- package/dist/paramTypes/index.js +4 -0
- package/dist/paramTypes/index.mjs +4 -0
- package/dist/paramTypes/key-value-array.type.d.mts +5 -0
- package/dist/paramTypes/key-value-array.type.d.ts +5 -0
- package/dist/paramTypes/key-value-array.type.js +4 -0
- package/dist/paramTypes/key-value-array.type.mjs +4 -0
- package/dist/paramTypes/number.type.d.mts +5 -0
- package/dist/paramTypes/number.type.d.ts +5 -0
- package/dist/paramTypes/number.type.js +4 -0
- package/dist/paramTypes/number.type.mjs +4 -0
- package/dist/paramTypes/object-array.type.d.mts +5 -0
- package/dist/paramTypes/object-array.type.d.ts +5 -0
- package/dist/paramTypes/object-array.type.js +4 -0
- package/dist/paramTypes/object-array.type.mjs +4 -0
- package/dist/paramTypes/object.type.d.mts +5 -0
- package/dist/paramTypes/object.type.d.ts +5 -0
- package/dist/paramTypes/object.type.js +4 -0
- package/dist/paramTypes/object.type.mjs +4 -0
- package/dist/paramTypes/param-type.interface.d.mts +6 -0
- package/dist/paramTypes/param-type.interface.d.ts +6 -0
- package/dist/paramTypes/param-type.interface.js +1 -0
- package/dist/paramTypes/param-type.interface.mjs +0 -0
- package/dist/paramTypes/param.type.d.mts +13 -0
- package/dist/paramTypes/param.type.d.ts +13 -0
- package/dist/paramTypes/param.type.js +4 -0
- package/dist/paramTypes/param.type.mjs +4 -0
- package/package.json +41 -0
package/README.md
ADDED
package/dist/index.d.mts
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
export { NestedArgs } from './nested-args.mjs';
|
2
|
+
export { KeyValueItem, arrayType } from './paramTypes/array.type.mjs';
|
3
|
+
export { asFalseValues, asTrueValues, booleanType } from './paramTypes/boolean.type.mjs';
|
4
|
+
export { keyValueArrayType } from './paramTypes/key-value-array.type.mjs';
|
5
|
+
export { numberType } from './paramTypes/number.type.mjs';
|
6
|
+
export { objectArrayType } from './paramTypes/object-array.type.mjs';
|
7
|
+
export { objectType } from './paramTypes/object.type.mjs';
|
8
|
+
export { ParamType } from './paramTypes/param-type.interface.mjs';
|
9
|
+
export { TYPES } from './paramTypes/param.type.mjs';
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
export { NestedArgs } from './nested-args.js';
|
2
|
+
export { KeyValueItem, arrayType } from './paramTypes/array.type.js';
|
3
|
+
export { asFalseValues, asTrueValues, booleanType } from './paramTypes/boolean.type.js';
|
4
|
+
export { keyValueArrayType } from './paramTypes/key-value-array.type.js';
|
5
|
+
export { numberType } from './paramTypes/number.type.js';
|
6
|
+
export { objectArrayType } from './paramTypes/object-array.type.js';
|
7
|
+
export { objectType } from './paramTypes/object.type.js';
|
8
|
+
export { ParamType } from './paramTypes/param-type.interface.js';
|
9
|
+
export { TYPES } from './paramTypes/param.type.js';
|
package/dist/index.js
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
'use strict';/**
|
2
|
+
@tikkhun/nested-args
|
3
|
+
*/
|
4
|
+
var i={stringify(e){return e!=null&&e.length?e.toString():""},parse(e){return e.split(",")}};var b=["true",true,"1",1],l=["false",false,"",0],c={stringify(e){return e.toString()},parse(e){return !!b.includes(e)}};var y={stringify(e){return e!=null&&e.length?e.map(r=>`${r==null?void 0:r.key}=${r==null?void 0:r.value}`).join(","):""},parse(e){return e?e.split(",").map(r=>{if(!r)return;let[t,n]=r.split("=");return {key:t,value:n}}).filter(r=>r):[]}};var u={stringify(e){return e.toString()},parse(e){return Number(e)}};var p={stringify(e){return JSON.stringify(e)},parse(e){try{return JSON.parse(e)||[]}catch(r){return []}}};var g={stringify(e){return JSON.stringify(e)},parse(e){return typeof e=="object"?JSON.parse(e):{}}};var a={array:"array",keyValueArray:"keyValueArray",objectArray:"objectArray",boolean:"boolean",number:"number",object:"object",string:"string",select:"select"};var m=class e{constructor(r){this.schema=r;}parse(r){return e.parse(r,this.schema)}static parse(r,t){let n={};return Object.entries(r).forEach(([s,o])=>{let f=t[s];typeof o=="object"?n[s]=e.parse(o,f):n[s]=e.parseValueByType(o,f);}),n}static parseValueByType(r,t){if(r!=="undefined")return t===a.keyValueArray?y.parse(r):t===a.objectArray?p.parse(r):t===a.array?i.parse(r):t===a.object?g.parse(r):t===a.number?u.parse(r):t===a.boolean?c.parse(r):r}static stringify(r){let t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e.stringifyValue(s);}),t}static stringifyValue(r){if(Array.isArray(r)){let t=r[0];return typeof t=="object"?this.isKeyValueObject(t)?y.stringify(r):p.stringify(r):i.stringify(r)}return typeof r=="object"?e.stringify(r):""+r}static isKeyValueObject(r){let t=Object.keys(r);return t[0]==="key"&&t[1]==="value"}};exports.NestedArgs=m;exports.TYPES=a;exports.arrayType=i;exports.asFalseValues=l;exports.asTrueValues=b;exports.booleanType=c;exports.keyValueArrayType=y;exports.numberType=u;exports.objectArrayType=p;exports.objectType=g;
|
package/dist/index.mjs
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
/**
|
2
|
+
@tikkhun/nested-args
|
3
|
+
*/
|
4
|
+
var i={stringify(e){return e!=null&&e.length?e.toString():""},parse(e){return e.split(",")}};var b=["true",true,"1",1],l=["false",false,"",0],c={stringify(e){return e.toString()},parse(e){return !!b.includes(e)}};var y={stringify(e){return e!=null&&e.length?e.map(r=>`${r==null?void 0:r.key}=${r==null?void 0:r.value}`).join(","):""},parse(e){return e?e.split(",").map(r=>{if(!r)return;let[t,n]=r.split("=");return {key:t,value:n}}).filter(r=>r):[]}};var u={stringify(e){return e.toString()},parse(e){return Number(e)}};var p={stringify(e){return JSON.stringify(e)},parse(e){try{return JSON.parse(e)||[]}catch(r){return []}}};var g={stringify(e){return JSON.stringify(e)},parse(e){return typeof e=="object"?JSON.parse(e):{}}};var a={array:"array",keyValueArray:"keyValueArray",objectArray:"objectArray",boolean:"boolean",number:"number",object:"object",string:"string",select:"select"};var m=class e{constructor(r){this.schema=r;}parse(r){return e.parse(r,this.schema)}static parse(r,t){let n={};return Object.entries(r).forEach(([s,o])=>{let f=t[s];typeof o=="object"?n[s]=e.parse(o,f):n[s]=e.parseValueByType(o,f);}),n}static parseValueByType(r,t){if(r!=="undefined")return t===a.keyValueArray?y.parse(r):t===a.objectArray?p.parse(r):t===a.array?i.parse(r):t===a.object?g.parse(r):t===a.number?u.parse(r):t===a.boolean?c.parse(r):r}static stringify(r){let t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e.stringifyValue(s);}),t}static stringifyValue(r){if(Array.isArray(r)){let t=r[0];return typeof t=="object"?this.isKeyValueObject(t)?y.stringify(r):p.stringify(r):i.stringify(r)}return typeof r=="object"?e.stringify(r):""+r}static isKeyValueObject(r){let t=Object.keys(r);return t[0]==="key"&&t[1]==="value"}};export{m as NestedArgs,a as TYPES,i as arrayType,l as asFalseValues,b as asTrueValues,c as booleanType,y as keyValueArrayType,u as numberType,p as objectArrayType,g as objectType};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
declare class NestedArgs {
|
2
|
+
schema: Record<string, any>;
|
3
|
+
constructor(schema: Record<string, any>);
|
4
|
+
parse(obj: Record<string, any>): Record<string, any>;
|
5
|
+
static parse(obj: Record<string, any>, schema: Record<string, any>): Record<string, any>;
|
6
|
+
private static parseValueByType;
|
7
|
+
static stringify(obj: Record<string, any>): Record<string, any>;
|
8
|
+
private static stringifyValue;
|
9
|
+
private static isKeyValueObject;
|
10
|
+
}
|
11
|
+
|
12
|
+
export { NestedArgs };
|
@@ -0,0 +1,12 @@
|
|
1
|
+
declare class NestedArgs {
|
2
|
+
schema: Record<string, any>;
|
3
|
+
constructor(schema: Record<string, any>);
|
4
|
+
parse(obj: Record<string, any>): Record<string, any>;
|
5
|
+
static parse(obj: Record<string, any>, schema: Record<string, any>): Record<string, any>;
|
6
|
+
private static parseValueByType;
|
7
|
+
static stringify(obj: Record<string, any>): Record<string, any>;
|
8
|
+
private static stringifyValue;
|
9
|
+
private static isKeyValueObject;
|
10
|
+
}
|
11
|
+
|
12
|
+
export { NestedArgs };
|
@@ -0,0 +1,4 @@
|
|
1
|
+
'use strict';/**
|
2
|
+
@tikkhun/nested-args
|
3
|
+
*/
|
4
|
+
var i={stringify(e){return e!=null&&e.length?e.toString():""},parse(e){return e.split(",")}};var b=["true",true,"1",1];var f={stringify(e){return e.toString()},parse(e){return !!b.includes(e)}};var y={stringify(e){return e!=null&&e.length?e.map(r=>`${r==null?void 0:r.key}=${r==null?void 0:r.value}`).join(","):""},parse(e){return e?e.split(",").map(r=>{if(!r)return;let[t,n]=r.split("=");return {key:t,value:n}}).filter(r=>r):[]}};var u={stringify(e){return e.toString()},parse(e){return Number(e)}};var p={stringify(e){return JSON.stringify(e)},parse(e){try{return JSON.parse(e)||[]}catch(r){return []}}};var g={stringify(e){return JSON.stringify(e)},parse(e){return typeof e=="object"?JSON.parse(e):{}}};var a={array:"array",keyValueArray:"keyValueArray",objectArray:"objectArray",boolean:"boolean",number:"number",object:"object"};var m=class e{constructor(r){this.schema=r;}parse(r){return e.parse(r,this.schema)}static parse(r,t){let n={};return Object.entries(r).forEach(([s,o])=>{let c=t[s];typeof o=="object"?n[s]=e.parse(o,c):n[s]=e.parseValueByType(o,c);}),n}static parseValueByType(r,t){if(r!=="undefined")return t===a.keyValueArray?y.parse(r):t===a.objectArray?p.parse(r):t===a.array?i.parse(r):t===a.object?g.parse(r):t===a.number?u.parse(r):t===a.boolean?f.parse(r):r}static stringify(r){let t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e.stringifyValue(s);}),t}static stringifyValue(r){if(Array.isArray(r)){let t=r[0];return typeof t=="object"?this.isKeyValueObject(t)?y.stringify(r):p.stringify(r):i.stringify(r)}return typeof r=="object"?e.stringify(r):""+r}static isKeyValueObject(r){let t=Object.keys(r);return t[0]==="key"&&t[1]==="value"}};exports.NestedArgs=m;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
/**
|
2
|
+
@tikkhun/nested-args
|
3
|
+
*/
|
4
|
+
var i={stringify(e){return e!=null&&e.length?e.toString():""},parse(e){return e.split(",")}};var b=["true",true,"1",1];var f={stringify(e){return e.toString()},parse(e){return !!b.includes(e)}};var y={stringify(e){return e!=null&&e.length?e.map(r=>`${r==null?void 0:r.key}=${r==null?void 0:r.value}`).join(","):""},parse(e){return e?e.split(",").map(r=>{if(!r)return;let[t,n]=r.split("=");return {key:t,value:n}}).filter(r=>r):[]}};var u={stringify(e){return e.toString()},parse(e){return Number(e)}};var p={stringify(e){return JSON.stringify(e)},parse(e){try{return JSON.parse(e)||[]}catch(r){return []}}};var g={stringify(e){return JSON.stringify(e)},parse(e){return typeof e=="object"?JSON.parse(e):{}}};var a={array:"array",keyValueArray:"keyValueArray",objectArray:"objectArray",boolean:"boolean",number:"number",object:"object"};var m=class e{constructor(r){this.schema=r;}parse(r){return e.parse(r,this.schema)}static parse(r,t){let n={};return Object.entries(r).forEach(([s,o])=>{let c=t[s];typeof o=="object"?n[s]=e.parse(o,c):n[s]=e.parseValueByType(o,c);}),n}static parseValueByType(r,t){if(r!=="undefined")return t===a.keyValueArray?y.parse(r):t===a.objectArray?p.parse(r):t===a.array?i.parse(r):t===a.object?g.parse(r):t===a.number?u.parse(r):t===a.boolean?f.parse(r):r}static stringify(r){let t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e.stringifyValue(s);}),t}static stringifyValue(r){if(Array.isArray(r)){let t=r[0];return typeof t=="object"?this.isKeyValueObject(t)?y.stringify(r):p.stringify(r):i.stringify(r)}return typeof r=="object"?e.stringify(r):""+r}static isKeyValueObject(r){let t=Object.keys(r);return t[0]==="key"&&t[1]==="value"}};export{m as NestedArgs};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { ParamType } from './param-type.interface.mjs';
|
2
|
+
|
3
|
+
declare const asTrueValues: (string | number | boolean)[];
|
4
|
+
declare const asFalseValues: (string | number | boolean)[];
|
5
|
+
declare const booleanType: ParamType;
|
6
|
+
|
7
|
+
export { asFalseValues, asTrueValues, booleanType };
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { ParamType } from './param-type.interface.js';
|
2
|
+
|
3
|
+
declare const asTrueValues: (string | number | boolean)[];
|
4
|
+
declare const asFalseValues: (string | number | boolean)[];
|
5
|
+
declare const booleanType: ParamType;
|
6
|
+
|
7
|
+
export { asFalseValues, asTrueValues, booleanType };
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export { KeyValueItem, arrayType } from './array.type.mjs';
|
2
|
+
export { asFalseValues, asTrueValues, booleanType } from './boolean.type.mjs';
|
3
|
+
export { keyValueArrayType } from './key-value-array.type.mjs';
|
4
|
+
export { numberType } from './number.type.mjs';
|
5
|
+
export { objectArrayType } from './object-array.type.mjs';
|
6
|
+
export { objectType } from './object.type.mjs';
|
7
|
+
export { ParamType } from './param-type.interface.mjs';
|
8
|
+
export { TYPES } from './param.type.mjs';
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export { KeyValueItem, arrayType } from './array.type.js';
|
2
|
+
export { asFalseValues, asTrueValues, booleanType } from './boolean.type.js';
|
3
|
+
export { keyValueArrayType } from './key-value-array.type.js';
|
4
|
+
export { numberType } from './number.type.js';
|
5
|
+
export { objectArrayType } from './object-array.type.js';
|
6
|
+
export { objectType } from './object.type.js';
|
7
|
+
export { ParamType } from './param-type.interface.js';
|
8
|
+
export { TYPES } from './param.type.js';
|
@@ -0,0 +1,4 @@
|
|
1
|
+
'use strict';/**
|
2
|
+
@tikkhun/nested-args
|
3
|
+
*/
|
4
|
+
var o={stringify(r){return r!=null&&r.length?r.toString():""},parse(r){return r.split(",")}};var a=["true",true,"1",1],s=["false",false,"",0],y={stringify(r){return r.toString()},parse(r){return !!a.includes(r)}};var u={stringify(r){return r!=null&&r.length?r.map(e=>`${e==null?void 0:e.key}=${e==null?void 0:e.value}`).join(","):""},parse(r){return r?r.split(",").map(e=>{if(!e)return;let[t,n]=e.split("=");return {key:t,value:n}}).filter(e=>e):[]}};var g={stringify(r){return r.toString()},parse(r){return Number(r)}};var l={stringify(r){return JSON.stringify(r)},parse(r){try{return JSON.parse(r)||[]}catch(e){return []}}};var T={stringify(r){return JSON.stringify(r)},parse(r){return typeof r=="object"?JSON.parse(r):{}}};var b={array:"array",keyValueArray:"keyValueArray",objectArray:"objectArray",boolean:"boolean",number:"number",object:"object",string:"string",select:"select"};exports.TYPES=b;exports.arrayType=o;exports.asFalseValues=s;exports.asTrueValues=a;exports.booleanType=y;exports.keyValueArrayType=u;exports.numberType=g;exports.objectArrayType=l;exports.objectType=T;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
/**
|
2
|
+
@tikkhun/nested-args
|
3
|
+
*/
|
4
|
+
var o={stringify(r){return r!=null&&r.length?r.toString():""},parse(r){return r.split(",")}};var a=["true",true,"1",1],s=["false",false,"",0],y={stringify(r){return r.toString()},parse(r){return !!a.includes(r)}};var u={stringify(r){return r!=null&&r.length?r.map(e=>`${e==null?void 0:e.key}=${e==null?void 0:e.value}`).join(","):""},parse(r){return r?r.split(",").map(e=>{if(!e)return;let[t,n]=e.split("=");return {key:t,value:n}}).filter(e=>e):[]}};var g={stringify(r){return r.toString()},parse(r){return Number(r)}};var l={stringify(r){return JSON.stringify(r)},parse(r){try{return JSON.parse(r)||[]}catch(e){return []}}};var T={stringify(r){return JSON.stringify(r)},parse(r){return typeof r=="object"?JSON.parse(r):{}}};var b={array:"array",keyValueArray:"keyValueArray",objectArray:"objectArray",boolean:"boolean",number:"number",object:"object",string:"string",select:"select"};export{b as TYPES,o as arrayType,s as asFalseValues,a as asTrueValues,y as booleanType,u as keyValueArrayType,g as numberType,l as objectArrayType,T as objectType};
|
@@ -0,0 +1,4 @@
|
|
1
|
+
'use strict';/**
|
2
|
+
@tikkhun/nested-args
|
3
|
+
*/
|
4
|
+
var u={stringify(e){return e!=null&&e.length?e.map(r=>`${r==null?void 0:r.key}=${r==null?void 0:r.value}`).join(","):""},parse(e){return e?e.split(",").map(r=>{if(!r)return;let[n,a]=r.split("=");return {key:n,value:a}}).filter(r=>r):[]}};exports.keyValueArrayType=u;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
/**
|
2
|
+
@tikkhun/nested-args
|
3
|
+
*/
|
4
|
+
var u={stringify(e){return e!=null&&e.length?e.map(r=>`${r==null?void 0:r.key}=${r==null?void 0:r.value}`).join(","):""},parse(e){return e?e.split(",").map(r=>{if(!r)return;let[n,a]=r.split("=");return {key:n,value:a}}).filter(r=>r):[]}};export{u as keyValueArrayType};
|
@@ -0,0 +1 @@
|
|
1
|
+
'use strict';
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
declare const TYPES: {
|
2
|
+
readonly array: "array";
|
3
|
+
readonly keyValueArray: "keyValueArray";
|
4
|
+
readonly objectArray: "objectArray";
|
5
|
+
readonly boolean: "boolean";
|
6
|
+
readonly number: "number";
|
7
|
+
readonly object: "object";
|
8
|
+
readonly string: "string";
|
9
|
+
readonly select: "select";
|
10
|
+
};
|
11
|
+
type TYPES = keyof typeof TYPES;
|
12
|
+
|
13
|
+
export { TYPES };
|
@@ -0,0 +1,13 @@
|
|
1
|
+
declare const TYPES: {
|
2
|
+
readonly array: "array";
|
3
|
+
readonly keyValueArray: "keyValueArray";
|
4
|
+
readonly objectArray: "objectArray";
|
5
|
+
readonly boolean: "boolean";
|
6
|
+
readonly number: "number";
|
7
|
+
readonly object: "object";
|
8
|
+
readonly string: "string";
|
9
|
+
readonly select: "select";
|
10
|
+
};
|
11
|
+
type TYPES = keyof typeof TYPES;
|
12
|
+
|
13
|
+
export { TYPES };
|
package/package.json
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
{
|
2
|
+
"name": "@tikkhun/nested-args",
|
3
|
+
"version": "0.0.0",
|
4
|
+
"description": "",
|
5
|
+
"main": "dist/index.js",
|
6
|
+
"module": "dist/index.mjs",
|
7
|
+
"types": "dist/index.d.ts",
|
8
|
+
"exports": {
|
9
|
+
".": {
|
10
|
+
"import": {
|
11
|
+
"types": "./dist/index.d.mts",
|
12
|
+
"default": "./dist/index.mjs"
|
13
|
+
},
|
14
|
+
"require": {
|
15
|
+
"types": "./dist/index.d.ts",
|
16
|
+
"default": "./dist/index.js"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
},
|
20
|
+
"files": [
|
21
|
+
"dist"
|
22
|
+
],
|
23
|
+
"publishConfig": {
|
24
|
+
"access": "public"
|
25
|
+
},
|
26
|
+
"keywords": [],
|
27
|
+
"author": "",
|
28
|
+
"license": "ISC",
|
29
|
+
"dependencies": {},
|
30
|
+
"devDependencies": {
|
31
|
+
"@types/node": "^20.3.1",
|
32
|
+
"tsx": "^4.19.1",
|
33
|
+
"tsup": "^8.3.0",
|
34
|
+
"vitest": "^2.1.3"
|
35
|
+
},
|
36
|
+
"scripts": {
|
37
|
+
"build": "tsup",
|
38
|
+
"dev": "tsx ./src/index.ts",
|
39
|
+
"test": "vitest"
|
40
|
+
}
|
41
|
+
}
|