@ugo-studio/jspp 0.1.8 → 0.2.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.
Files changed (50) hide show
  1. package/README.md +1 -1
  2. package/dist/cli-utils/args.js +2 -0
  3. package/dist/cli.js +1 -1
  4. package/package.json +3 -2
  5. package/scripts/precompile-headers.ts +110 -0
  6. package/scripts/setup-compiler.ts +63 -0
  7. package/src/prelude/any_value.hpp +185 -391
  8. package/src/prelude/any_value_access.hpp +170 -190
  9. package/src/prelude/any_value_defines.hpp +12 -12
  10. package/src/prelude/any_value_helpers.hpp +208 -26
  11. package/src/prelude/exception.hpp +27 -31
  12. package/src/prelude/exception_helpers.hpp +53 -49
  13. package/src/prelude/index.hpp +9 -4
  14. package/src/prelude/library/array.hpp +4 -9
  15. package/src/prelude/library/console.hpp +112 -112
  16. package/src/prelude/library/error.hpp +8 -8
  17. package/src/prelude/library/math.hpp +3 -3
  18. package/src/prelude/library/object.hpp +12 -24
  19. package/src/prelude/library/promise.hpp +1 -1
  20. package/src/prelude/library/symbol.hpp +1 -1
  21. package/src/prelude/library/timer.hpp +3 -3
  22. package/src/prelude/types.hpp +178 -130
  23. package/src/prelude/utils/access.hpp +338 -378
  24. package/src/prelude/utils/log_any_value/function.hpp +39 -39
  25. package/src/prelude/utils/log_any_value/log_any_value.hpp +1 -1
  26. package/src/prelude/utils/operators.hpp +20 -82
  27. package/src/prelude/utils/well_known_symbols.hpp +14 -15
  28. package/src/prelude/values/array.hpp +5 -3
  29. package/src/prelude/values/async_iterator.hpp +3 -1
  30. package/src/prelude/values/descriptors.hpp +15 -3
  31. package/src/prelude/values/function.hpp +5 -9
  32. package/src/prelude/values/helpers/array.hpp +208 -219
  33. package/src/prelude/values/helpers/async_iterator.hpp +7 -11
  34. package/src/prelude/values/helpers/function.hpp +12 -17
  35. package/src/prelude/values/helpers/iterator.hpp +108 -107
  36. package/src/prelude/values/helpers/object.hpp +104 -109
  37. package/src/prelude/values/helpers/promise.hpp +185 -119
  38. package/src/prelude/values/helpers/string.hpp +7 -10
  39. package/src/prelude/values/helpers/symbol.hpp +21 -23
  40. package/src/prelude/values/iterator.hpp +4 -1
  41. package/src/prelude/values/object.hpp +6 -4
  42. package/src/prelude/values/promise.hpp +5 -2
  43. package/src/prelude/values/prototypes/array.hpp +22 -22
  44. package/src/prelude/values/prototypes/async_iterator.hpp +3 -10
  45. package/src/prelude/values/prototypes/iterator.hpp +51 -58
  46. package/src/prelude/values/prototypes/promise.hpp +32 -28
  47. package/src/prelude/values/prototypes/string.hpp +5 -5
  48. package/src/prelude/values/prototypes/symbol.hpp +1 -1
  49. package/src/prelude/values/string.hpp +3 -1
  50. package/src/prelude/values/symbol.hpp +101 -102
@@ -1,112 +1,112 @@
1
- #pragma once
2
-
3
- #include <chrono>
4
- #include "types.hpp"
5
- #include "values/non_values.hpp"
6
- #include "values/object.hpp"
7
- #include "values/function.hpp"
8
- #include "utils/operators.hpp"
9
- #include "exception.hpp"
10
- #include "utils/log_any_value/log_any_value.hpp"
11
-
12
- #include <cmath>
13
- #include <sstream>
14
- #include <iomanip>
15
-
16
- static std::map<std::string, std::chrono::steady_clock::time_point> timers = {};
17
-
18
- auto logFn = jspp::AnyValue::make_function([](const jspp::AnyValue &thisVal, std::span<const jspp::AnyValue> args)
19
- {
20
- for (size_t i = 0; i < args.size(); ++i)
21
- {
22
- std::cout << jspp::LogAnyValue::to_log_string(args[i]);
23
- if (i < args.size() - 1)
24
- std::cout << " ";
25
- }
26
- std::cout << "\n" << std::flush;
27
- return jspp::AnyValue::make_undefined(); }, "log");
28
- auto warnFn = jspp::AnyValue::make_function([](const jspp::AnyValue &thisVal, std::span<const jspp::AnyValue> args)
29
- {
30
- std::cerr << "\033[33m";
31
- for (size_t i = 0; i < args.size(); ++i)
32
- {
33
- std::cout << jspp::LogAnyValue::to_log_string(args[i]);
34
- if (i < args.size() - 1)
35
- std::cout << " ";
36
- }
37
- std::cerr << "\033[0m" << "\n" << std::flush; // reset
38
- return jspp::AnyValue::make_undefined(); }, "warn");
39
- auto errorFn = jspp::AnyValue::make_function([](const jspp::AnyValue &thisVal, std::span<const jspp::AnyValue> args)
40
- {
41
- std::cerr << "\033[31m";
42
- for (size_t i = 0; i < args.size(); ++i)
43
- {
44
- std::cout << jspp::LogAnyValue::to_log_string(args[i]);
45
- if (i < args.size() - 1)
46
- std::cout << " ";
47
- }
48
- std::cerr << "\033[0m" << "\n" << std::flush; // reset
49
- return jspp::AnyValue::make_undefined(); }, "error");
50
- auto timeFn = jspp::AnyValue::make_function([](const jspp::AnyValue &thisVal, std::span<const jspp::AnyValue> args)
51
- {
52
- auto start = std::chrono::steady_clock::now(); // capture immediately
53
- auto key_str = args.size() > 0 ? args[0].to_std_string() : "default";
54
- timers[key_str] = start;
55
- return jspp::AnyValue::make_undefined(); }, "time");
56
-
57
- // helper to format duration in ms -> ms/s/m/h with nice precision
58
- static auto format_duration = [](double ms) -> std::string
59
- {
60
- std::ostringstream ss;
61
- if (ms < 1000.0)
62
- {
63
- ss << std::fixed << std::setprecision(4) << ms << "ms";
64
- return ss.str();
65
- }
66
- double total_s = ms / 1000.0;
67
- if (ms < 60000.0)
68
- { // less than a minute -> show seconds
69
- ss << std::fixed << std::setprecision(4) << total_s << "s";
70
- return ss.str();
71
- }
72
- if (ms < 3600000.0)
73
- { // less than an hour -> show minutes + seconds
74
- int minutes = static_cast<int>(ms / 60000.0);
75
- double seconds = (ms - minutes * 60000.0) / 1000.0;
76
- ss << minutes << "m " << std::fixed << std::setprecision(4) << seconds << "s";
77
- return ss.str();
78
- }
79
- // hours, minutes, seconds
80
- int hours = static_cast<int>(ms / 3600000.0);
81
- int minutes = static_cast<int>((ms - hours * 3600000.0) / 60000.0);
82
- double seconds = (ms - hours * 3600000.0 - minutes * 60000.0) / 1000.0;
83
- ss << hours << "h " << minutes << "m " << std::fixed << std::setprecision(4) << seconds << "s";
84
- return ss.str();
85
- };
86
-
87
- auto timeEndFn = jspp::AnyValue::make_function([](const jspp::AnyValue &thisVal, std::span<const jspp::AnyValue> args)
88
- {
89
- auto end = std::chrono::steady_clock::now(); // capture immediately
90
- auto key_str = args.size() > 0 ? args[0].to_std_string() : "default";
91
- auto it = timers.find(key_str);
92
- if (it != timers.end())
93
- {
94
- std::chrono::duration<double, std::milli> duration = end - it->second;
95
- double ms = duration.count();
96
- std::string formatted = format_duration(ms);
97
- std::cout << "\033[90m" << "[" << format_duration(ms) << "] " << "\033[0m" << key_str << "\n";
98
- timers.erase(it); // remove the timer after ending it
99
- }
100
- else
101
- {
102
- std::cout << "Timer '" << key_str << "' does not exist." << "\n";
103
- }
104
- return jspp::AnyValue::make_undefined(); }, "timeEnd");
105
-
106
- inline auto console = jspp::AnyValue::make_object({
107
- {"log", logFn},
108
- {"warn", warnFn},
109
- {"error", errorFn},
110
- {"time", timeFn},
111
- {"timeEnd", timeEndFn},
112
- });
1
+ #pragma once
2
+
3
+ #include <chrono>
4
+ #include "types.hpp"
5
+ #include "values/non_values.hpp"
6
+ #include "values/object.hpp"
7
+ #include "values/function.hpp"
8
+ #include "utils/operators.hpp"
9
+ #include "exception.hpp"
10
+ #include "utils/log_any_value/log_any_value.hpp"
11
+
12
+ #include <cmath>
13
+ #include <sstream>
14
+ #include <iomanip>
15
+
16
+ static std::map<std::string, std::chrono::steady_clock::time_point> timers = {};
17
+
18
+ auto logFn = jspp::AnyValue::make_function([](const jspp::AnyValue &thisVal, std::span<const jspp::AnyValue> args)
19
+ {
20
+ for (size_t i = 0; i < args.size(); ++i)
21
+ {
22
+ std::cout << jspp::LogAnyValue::to_log_string(args[i]);
23
+ if (i < args.size() - 1)
24
+ std::cout << " ";
25
+ }
26
+ std::cout << "\n" << std::flush;
27
+ return jspp::Constants::UNDEFINED; }, "log");
28
+ auto warnFn = jspp::AnyValue::make_function([](const jspp::AnyValue &thisVal, std::span<const jspp::AnyValue> args)
29
+ {
30
+ std::cerr << "\033[33m";
31
+ for (size_t i = 0; i < args.size(); ++i)
32
+ {
33
+ std::cout << jspp::LogAnyValue::to_log_string(args[i]);
34
+ if (i < args.size() - 1)
35
+ std::cout << " ";
36
+ }
37
+ std::cerr << "\033[0m" << "\n" << std::flush; // reset
38
+ return jspp::Constants::UNDEFINED; }, "warn");
39
+ auto errorFn = jspp::AnyValue::make_function([](const jspp::AnyValue &thisVal, std::span<const jspp::AnyValue> args)
40
+ {
41
+ std::cerr << "\033[31m";
42
+ for (size_t i = 0; i < args.size(); ++i)
43
+ {
44
+ std::cout << jspp::LogAnyValue::to_log_string(args[i]);
45
+ if (i < args.size() - 1)
46
+ std::cout << " ";
47
+ }
48
+ std::cerr << "\033[0m" << "\n" << std::flush; // reset
49
+ return jspp::Constants::UNDEFINED; }, "error");
50
+ auto timeFn = jspp::AnyValue::make_function([](const jspp::AnyValue &thisVal, std::span<const jspp::AnyValue> args)
51
+ {
52
+ auto start = std::chrono::steady_clock::now(); // capture immediately
53
+ auto key_str = args.size() > 0 ? args[0].to_std_string() : "default";
54
+ timers[key_str] = start;
55
+ return jspp::Constants::UNDEFINED; }, "time");
56
+
57
+ // helper to format duration in ms -> ms/s/m/h with nice precision
58
+ static auto format_duration = [](double ms) -> std::string
59
+ {
60
+ std::ostringstream ss;
61
+ if (ms < 1000.0)
62
+ {
63
+ ss << std::fixed << std::setprecision(4) << ms << "ms";
64
+ return ss.str();
65
+ }
66
+ double total_s = ms / 1000.0;
67
+ if (ms < 60000.0)
68
+ { // less than a minute -> show seconds
69
+ ss << std::fixed << std::setprecision(4) << total_s << "s";
70
+ return ss.str();
71
+ }
72
+ if (ms < 3600000.0)
73
+ { // less than an hour -> show minutes + seconds
74
+ int minutes = static_cast<int>(ms / 60000.0);
75
+ double seconds = (ms - minutes * 60000.0) / 1000.0;
76
+ ss << minutes << "m " << std::fixed << std::setprecision(4) << seconds << "s";
77
+ return ss.str();
78
+ }
79
+ // hours, minutes, seconds
80
+ int hours = static_cast<int>(ms / 3600000.0);
81
+ int minutes = static_cast<int>((ms - hours * 3600000.0) / 60000.0);
82
+ double seconds = (ms - hours * 3600000.0 - minutes * 60000.0) / 1000.0;
83
+ ss << hours << "h " << minutes << "m " << std::fixed << std::setprecision(4) << seconds << "s";
84
+ return ss.str();
85
+ };
86
+
87
+ auto timeEndFn = jspp::AnyValue::make_function([](const jspp::AnyValue &thisVal, std::span<const jspp::AnyValue> args)
88
+ {
89
+ auto end = std::chrono::steady_clock::now(); // capture immediately
90
+ auto key_str = args.size() > 0 ? args[0].to_std_string() : "default";
91
+ auto it = timers.find(key_str);
92
+ if (it != timers.end())
93
+ {
94
+ std::chrono::duration<double, std::milli> duration = end - it->second;
95
+ double ms = duration.count();
96
+ std::string formatted = format_duration(ms);
97
+ std::cout << "\033[90m" << "[" << format_duration(ms) << "] " << "\033[0m" << key_str << "\n";
98
+ timers.erase(it); // remove the timer after ending it
99
+ }
100
+ else
101
+ {
102
+ std::cout << "Timer '" << key_str << "' does not exist." << "\n";
103
+ }
104
+ return jspp::Constants::UNDEFINED; }, "timeEnd");
105
+
106
+ inline auto console = jspp::AnyValue::make_object({
107
+ {"log", logFn},
108
+ {"warn", warnFn},
109
+ {"error", errorFn},
110
+ {"time", timeFn},
111
+ {"timeEnd", timeEndFn},
112
+ });
@@ -18,7 +18,7 @@ inline auto errorConstructor = [](const jspp::AnyValue &thisVal, std::span<const
18
18
  if (target.is_object())
19
19
  {
20
20
  auto obj = target.as_object();
21
- if (obj->proto && is_strictly_equal_to_primitive((*obj->proto), proto))
21
+ if (!obj->proto.is_null() && !obj->proto.is_undefined() && is_strictly_equal_to_primitive(obj->proto, proto))
22
22
  {
23
23
  is_construct_call = true;
24
24
  }
@@ -55,10 +55,10 @@ inline auto errorConstructor = [](const jspp::AnyValue &thisVal, std::span<const
55
55
  // Static Error.isError(val) implementation
56
56
  inline auto isErrorFn = jspp::AnyValue::make_function([](const jspp::AnyValue &thisVal, std::span<const jspp::AnyValue> args) -> jspp::AnyValue
57
57
  {
58
- if (args.empty()) return jspp::AnyValue::make_boolean(false);
58
+ if (args.empty()) return jspp::Constants::FALSE;
59
59
 
60
60
  jspp::AnyValue val = args[0];
61
- if (!val.is_object()) return jspp::AnyValue::make_boolean(false);
61
+ if (!val.is_object()) return jspp::Constants::FALSE;
62
62
 
63
63
  // Check if it inherits from Error.prototype
64
64
  // This is essentially 'instanceof Error'
@@ -67,14 +67,14 @@ inline auto isErrorFn = jspp::AnyValue::make_function([](const jspp::AnyValue &t
67
67
  // Walk prototype chain
68
68
  if (val.is_object()) {
69
69
  auto current = val.as_object()->proto;
70
- while (current && !(*current).is_null()) {
71
- if (is_strictly_equal_to_primitive((*current),proto)) return jspp::AnyValue::make_boolean(true);
72
- if ((*current).is_object()) current = (*current).as_object()->proto;
70
+ while (!current.is_null()) {
71
+ if (is_strictly_equal_to_primitive(current, proto)) return jspp::Constants::TRUE;
72
+ if (current.is_object()) current = current.as_object()->proto;
73
73
  else break;
74
74
  }
75
75
  }
76
76
 
77
- return jspp::AnyValue::make_boolean(false); }, "isError");
77
+ return jspp::Constants::FALSE; }, "isError");
78
78
 
79
79
  // toString method for Error.prototype
80
80
  inline auto errorToStringFn = jspp::AnyValue::make_function([](const jspp::AnyValue &thisVal, std::span<const jspp::AnyValue> args) -> jspp::AnyValue
@@ -110,4 +110,4 @@ struct ErrorInit
110
110
  // Define static Error.isError
111
111
  Error.define_data_property("isError", isErrorFn, true, false, true);
112
112
  }
113
- } errorInit;
113
+ } errorInit;
@@ -111,7 +111,7 @@ struct MathInit {
111
111
 
112
112
  // Math.clz32(x)
113
113
  Math.define_data_property("clz32", AnyValue::make_function([](const AnyValue&, std::span<const AnyValue> args) -> AnyValue {
114
- uint32_t val = Operators_Private::ToInt32(args.empty() ? AnyValue::make_undefined() : args[0]);
114
+ uint32_t val = Operators_Private::ToInt32(args.empty() ? Constants::UNDEFINED : args[0]);
115
115
  if (val == 0) return AnyValue::make_number(32);
116
116
  return AnyValue::make_number(std::countl_zero(val));
117
117
  }, "clz32"));
@@ -173,8 +173,8 @@ struct MathInit {
173
173
 
174
174
  // Math.imul(x, y)
175
175
  Math.define_data_property("imul", AnyValue::make_function([](const AnyValue&, std::span<const AnyValue> args) -> AnyValue {
176
- int32_t a = Operators_Private::ToInt32(args.empty() ? AnyValue::make_undefined() : args[0]);
177
- int32_t b = Operators_Private::ToInt32(args.size() < 2 ? AnyValue::make_undefined() : args[1]);
176
+ int32_t a = Operators_Private::ToInt32(args.empty() ? Constants::UNDEFINED : args[0]);
177
+ int32_t b = Operators_Private::ToInt32(args.size() < 2 ? Constants::UNDEFINED : args[1]);
178
178
  return AnyValue::make_number(a * b);
179
179
  }, "imul"));
180
180
 
@@ -74,9 +74,6 @@ struct ObjectInit
74
74
  auto target = args[0];
75
75
  if (target.is_null() || target.is_undefined()) throw jspp::Exception::make_exception("Cannot convert undefined or null to object", "TypeError");
76
76
 
77
- // In JS, Object.assign modifies target in place if it's an object.
78
- // If it's a primitive, it wraps it (but our primitives are tricky, let's assume objects for now).
79
-
80
77
  for (size_t i = 1; i < args.size(); ++i) {
81
78
  auto source = args[i];
82
79
  if (source.is_null() || source.is_undefined()) continue;
@@ -92,15 +89,14 @@ struct ObjectInit
92
89
  // Object.is(value1, value2)
93
90
  Object.define_data_property("is", jspp::AnyValue::make_function([](const jspp::AnyValue &, std::span<const jspp::AnyValue> args) -> jspp::AnyValue
94
91
  {
95
- jspp::AnyValue v1 = args.size() > 0 ? args[0] : jspp::AnyValue::make_undefined();
96
- jspp::AnyValue v2 = args.size() > 1 ? args[1] : jspp::AnyValue::make_undefined();
92
+ jspp::AnyValue v1 = args.size() > 0 ? args[0] : jspp::Constants::UNDEFINED;
93
+ jspp::AnyValue v2 = args.size() > 1 ? args[1] : jspp::Constants::UNDEFINED;
97
94
 
98
95
  if (v1.is_number() && v2.is_number()) {
99
96
  double d1 = v1.as_double();
100
97
  double d2 = v2.as_double();
101
98
  if (std::isnan(d1) && std::isnan(d2)) return jspp::Constants::TRUE;
102
99
  if (d1 == 0 && d2 == 0) {
103
- // check signs
104
100
  return jspp::AnyValue::make_boolean(std::signbit(d1) == std::signbit(d2));
105
101
  }
106
102
  return jspp::AnyValue::make_boolean(d1 == d2);
@@ -113,25 +109,18 @@ struct ObjectInit
113
109
  {
114
110
  if (args.empty()) throw jspp::Exception::make_exception("Object.getPrototypeOf called on non-object", "TypeError");
115
111
  auto obj = args[0];
116
- // In ES6+, primitives are coerced to objects.
117
- // We'll focus on Objects/Arrays/Functions for now.
118
112
 
119
113
  if (obj.is_object()) {
120
- auto p = obj.as_object()->proto;
121
- return p ? *p : jspp::AnyValue::make_null();
114
+ return obj.as_object()->proto;
122
115
  }
123
116
  if (obj.is_array()) {
124
- auto p = obj.as_array()->proto;
125
- return p ? *p : jspp::AnyValue::make_null();
117
+ return obj.as_array()->proto;
126
118
  }
127
119
  if (obj.is_function()) {
128
- auto p = obj.as_function()->proto;
129
- return p ? *p : jspp::AnyValue::make_null();
120
+ return obj.as_function()->proto;
130
121
  }
131
122
 
132
- // For primitives, they use their prototype from the global constructors usually
133
- // e.g. Number.prototype. For now return null or implement if needed.
134
- return jspp::AnyValue::make_null(); }, "getPrototypeOf"));
123
+ return jspp::Constants::Null; }, "getPrototypeOf"));
135
124
 
136
125
  // Object.setPrototypeOf(obj, proto)
137
126
  Object.define_data_property("setPrototypeOf", jspp::AnyValue::make_function([](const jspp::AnyValue &, std::span<const jspp::AnyValue> args) -> jspp::AnyValue
@@ -145,11 +134,11 @@ struct ObjectInit
145
134
  }
146
135
 
147
136
  if (obj.is_object()) {
148
- obj.as_object()->proto = std::make_shared<jspp::AnyValue>(proto);
137
+ obj.as_object()->proto = proto;
149
138
  } else if (obj.is_array()) {
150
- obj.as_array()->proto = std::make_shared<jspp::AnyValue>(proto);
139
+ obj.as_array()->proto = proto;
151
140
  } else if (obj.is_function()) {
152
- obj.as_function()->proto = std::make_shared<jspp::AnyValue>(proto);
141
+ obj.as_function()->proto = proto;
153
142
  }
154
143
 
155
144
  return obj; }, "setPrototypeOf"));
@@ -202,8 +191,8 @@ struct ObjectInit
202
191
  auto value = descObj.get_own_property("value");
203
192
  obj.define_data_property(prop, value, writable, enumerable, configurable);
204
193
  } else {
205
- jspp::AnyValue getter = jspp::AnyValue::make_undefined();
206
- jspp::AnyValue setter = jspp::AnyValue::make_undefined();
194
+ jspp::AnyValue getter = jspp::Constants::UNDEFINED;
195
+ jspp::AnyValue setter = jspp::Constants::UNDEFINED;
207
196
 
208
197
  if (hasGet) getter = descObj.get_own_property("get");
209
198
  if (hasSet) setter = descObj.get_own_property("set");
@@ -236,7 +225,6 @@ struct ObjectInit
236
225
  o_ptr->storage.push_back(desc);
237
226
  }
238
227
  }
239
- // TODO: Handle Array/Function/others
240
228
  }
241
229
 
242
230
  return obj; }, "defineProperty"));
@@ -285,4 +273,4 @@ struct ObjectInit
285
273
  }
286
274
  return jspp::Constants::FALSE; }, "hasOwnProperty"));
287
275
  }
288
- } objectInit;
276
+ } objectInit;
@@ -37,7 +37,7 @@ inline auto Promise = jspp::AnyValue::make_function([](const jspp::AnyValue &thi
37
37
  }
38
38
  catch (const jspp::Exception &e)
39
39
  {
40
- promise.reject(*e.data);
40
+ promise.reject(e.data);
41
41
  }
42
42
  catch (...)
43
43
  {
@@ -32,7 +32,7 @@ struct SymbolInit
32
32
  auto sym = args[0].as_symbol();
33
33
  auto key = jspp::JsSymbol::key_for(sym);
34
34
  if (key.has_value()) return jspp::AnyValue::make_string(key.value());
35
- return jspp::AnyValue::make_undefined(); }, "keyFor"));
35
+ return jspp::Constants::UNDEFINED; }, "keyFor"));
36
36
 
37
37
  // Well-known symbols
38
38
  Symbol.define_data_property("iterator", jspp::AnyValue::from_symbol(jspp::WellKnownSymbols::iterator), false, false, false);
@@ -46,7 +46,7 @@ inline auto clearTimeout = jspp::AnyValue::make_function([](const jspp::AnyValue
46
46
  size_t id = static_cast<size_t>(args[0].as_double());
47
47
  jspp::Scheduler::instance().clear_timer(id);
48
48
  }
49
- return jspp::AnyValue::make_undefined();
49
+ return jspp::Constants::UNDEFINED;
50
50
  }, "clearTimeout");
51
51
 
52
52
  // setInterval(callback, delay, ...args)
@@ -88,5 +88,5 @@ inline auto clearInterval = jspp::AnyValue::make_function([](const jspp::AnyValu
88
88
  size_t id = static_cast<size_t>(args[0].as_double());
89
89
  jspp::Scheduler::instance().clear_timer(id);
90
90
  }
91
- return jspp::AnyValue::make_undefined();
92
- }, "clearInterval");
91
+ return jspp::Constants::UNDEFINED;
92
+ }, "clearInterval");