@makano/rew 1.2.91 → 1.2.93

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,26 +59,27 @@ function typef(fn, returnType) {
59
59
  return result;
60
60
  }
61
61
  wrappedFn.returnType = returnType;
62
+ wrappedFn.type = returnType;
62
63
  return wrappedFn;
63
64
  }
64
65
  typef.is = function(func, returnType){
65
66
  return typeis(func.returnType.defaultValue, returnType);
66
67
  }
67
68
 
68
- function typeis(obj, typeDef) {
69
+ function typeis(obj, typeDef, missingObjects = false) {
69
70
  // Resolve Type
70
71
  if (typeof typeDef == 'function' && typeDef.type instanceof Type) typeDef = typeDef.type;
71
72
 
72
73
  if (typeDef.isConstucted && typeDef.class && !(obj instanceof typeDef.class)) {
73
- return false;
74
+ return missingObjects ? [false] : false;
74
75
  }
75
76
 
76
77
  if (getType(obj) == 'object' && typeDef.type == 'function') {
77
- return obj instanceof typeDef.class;
78
+ return missingObjects ? [obj instanceof typeDef.class] : obj instanceof typeDef.class;
78
79
  }
79
80
 
80
81
  if (getType(obj) !== typeDef.type) {
81
- return false;
82
+ return missingObjects ? [false] : false;
82
83
  }
83
84
 
84
85
  if (!typeDef.isEmpty) {
@@ -90,14 +91,28 @@ function typeis(obj, typeDef) {
90
91
 
91
92
  if (typeof propTypeDef === 'object') {
92
93
  if (!typeis(obj[key], propTypeDef)) {
93
- return false;
94
+ return missingObjects ? [false, {
95
+ [key]: {
96
+ type_mismatch: propTypeDef,
97
+ given: obj[gen_key]
98
+ }
99
+ }] : false;
94
100
  }
95
- } else if (typeof obj[key] !== propTypeDef) {
96
- 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;
97
110
  }
98
111
  }
99
112
  if (typeDef.strict) {
100
- 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;
101
116
  }
102
117
  } else if (typeDef.type == 'string') {
103
118
  return typeDef.defaultValue == obj;
@@ -106,7 +121,7 @@ function typeis(obj, typeDef) {
106
121
  }
107
122
  }
108
123
 
109
- return true;
124
+ return missingObjects ? [true] : true;
110
125
  }
111
126
 
112
127
  function typex(child, parent) {
@@ -86,6 +86,15 @@ function tokenizeCoffeeScript(code) {
86
86
  }
87
87
  tokens.push({ type: 'IDENTIFIER', value: identifier });
88
88
  i--; // Move back one character to recheck
89
+ } else if (/[a-f0-9.n]/.test(char)) {
90
+ let num = char;
91
+ i++;
92
+ while (i < code.length && /[a-f0-9.n]/.test(code[i])) {
93
+ num += code[i];
94
+ i++;
95
+ }
96
+ tokens.push({ type: 'NUMBER', value: num });
97
+ i--; // Move back one character to recheck
89
98
  } else {
90
99
  // Other characters
91
100
  tokens.push({ type: 'OTHER', value: char });
@@ -172,7 +181,7 @@ function declareAlias(aliases, token) {
172
181
  let nextToken = gnextToken(index, offset+1, tokens);
173
182
  const args = nextToken.token.value;
174
183
  setIndex(ti + offset);
175
- return `${nextToken2.value} = ${token.value} ${args && args !== '(' ? `${args},` : ''} ${params.trim()}, ${args == '(' ? args : ''}`;
184
+ return `${nextToken2.value} = ${token.value} ${args && args !== '(' && args !== '{' && args !== '[' && args !== '-' && args !== '=' ? `${args},` : ''} ${params.trim() ? params.trim() + ', ' : ''}${args == '(' || args == '[' || args == '{' || args == '=' || args == '-' ? args : ''}`.replace(/,(| )$/, '');
176
185
  } else if(nextToken?.value == ' ' && (isDecOnly || nextToken2?.token.value == '=' || nextToken2?.token.value == ':')){
177
186
  nextToken.value = '';
178
187
  if(isDecOnly){
@@ -573,6 +582,8 @@ const compileCivetStuff = (file, options) => {
573
582
  straceLog('OPTION_PREPARE() for CURRENTFILE as', preCompileOptions);
574
583
  const prepared = compileRewStuff(file.content, preCompileOptions);
575
584
 
585
+ // console.log(prepared);
586
+
576
587
  const compileOptions = {
577
588
  ...preCompileOptions,
578
589
  bare: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.91",
3
+ "version": "1.2.93",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {