@makano/rew 1.2.92 → 1.2.93

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.
@@ -66,20 +66,20 @@ typef.is = function(func, returnType){
66
66
  return typeis(func.returnType.defaultValue, returnType);
67
67
  }
68
68
 
69
- function typeis(obj, typeDef) {
69
+ function typeis(obj, typeDef, missingObjects = false) {
70
70
  // Resolve Type
71
71
  if (typeof typeDef == 'function' && typeDef.type instanceof Type) typeDef = typeDef.type;
72
72
 
73
73
  if (typeDef.isConstucted && typeDef.class && !(obj instanceof typeDef.class)) {
74
- return false;
74
+ return missingObjects ? [false] : false;
75
75
  }
76
76
 
77
77
  if (getType(obj) == 'object' && typeDef.type == 'function') {
78
- return obj instanceof typeDef.class;
78
+ return missingObjects ? [obj instanceof typeDef.class] : obj instanceof typeDef.class;
79
79
  }
80
80
 
81
81
  if (getType(obj) !== typeDef.type) {
82
- return false;
82
+ return missingObjects ? [false] : false;
83
83
  }
84
84
 
85
85
  if (!typeDef.isEmpty) {
@@ -91,14 +91,28 @@ function typeis(obj, typeDef) {
91
91
 
92
92
  if (typeof propTypeDef === 'object') {
93
93
  if (!typeis(obj[key], propTypeDef)) {
94
- return false;
94
+ return missingObjects ? [false, {
95
+ [key]: {
96
+ type_mismatch: propTypeDef,
97
+ given: obj[gen_key]
98
+ }
99
+ }] : false;
95
100
  }
96
- } else if (typeof obj[key] !== propTypeDef) {
97
- return false;
101
+ } else if (typeof obj[key] !== typeof propTypeDef) {
102
+ return missingObjects ? [false, {
103
+ [key]: obj[key] ? {
104
+ type_mismatch: typeof propTypeDef,
105
+ given: typeof obj[key]
106
+ } : {
107
+ not_found: true
108
+ }
109
+ }] : false;
98
110
  }
99
111
  }
100
112
  if (typeDef.strict) {
101
- if (Object.keys(obj).some((key) => !Object.keys(typeDef.defaultValue).includes(key))) return false;
113
+ if (Object.keys(obj).some((key) => !Object.keys(typeDef.defaultValue).includes(key))) return missingObjects ?
114
+ [false, Object.fromEntries(Object.keys(obj).filter((key) => !Object.keys(typeDef.defaultValue).includes(key)).map((key) => [key, { is_extra: true }]))]
115
+ : false;
102
116
  }
103
117
  } else if (typeDef.type == 'string') {
104
118
  return typeDef.defaultValue == obj;
@@ -107,7 +121,7 @@ function typeis(obj, typeDef) {
107
121
  }
108
122
  }
109
123
 
110
- return true;
124
+ return missingObjects ? [true] : true;
111
125
  }
112
126
 
113
127
  function typex(child, parent) {
@@ -181,7 +181,7 @@ function declareAlias(aliases, token) {
181
181
  let nextToken = gnextToken(index, offset+1, tokens);
182
182
  const args = nextToken.token.value;
183
183
  setIndex(ti + offset);
184
- return `${nextToken2.value} = ${token.value} ${args && args !== '(' && args !== '-' && args !== '=' ? `${args},` : ''} ${params.trim()}, ${args == '(' || args == '=' || args == '-' ? args : ''}`.replace(/,(| )$/, '');
184
+ return `${nextToken2.value} = ${token.value} ${args && args !== '(' && args !== '{' && args !== '[' && args !== '-' && args !== '=' ? `${args},` : ''} ${params.trim() ? params.trim() + ', ' : ''}${args == '(' || args == '[' || args == '{' || args == '=' || args == '-' ? args : ''}`.replace(/,(| )$/, '');
185
185
  } else if(nextToken?.value == ' ' && (isDecOnly || nextToken2?.token.value == '=' || nextToken2?.token.value == ':')){
186
186
  nextToken.value = '';
187
187
  if(isDecOnly){
@@ -582,6 +582,8 @@ const compileCivetStuff = (file, options) => {
582
582
  straceLog('OPTION_PREPARE() for CURRENTFILE as', preCompileOptions);
583
583
  const prepared = compileRewStuff(file.content, preCompileOptions);
584
584
 
585
+ // console.log(prepared);
586
+
585
587
  const compileOptions = {
586
588
  ...preCompileOptions,
587
589
  bare: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.92",
3
+ "version": "1.2.93",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {