Can I use in Google Apps Scripts a defined Class in a library with ES6 (V8)?

As written in the official documentation, Only the following properties in the script are available to library users: enumerable global properties function declarations, variables created outside a function with var, and properties explicitly set on the global object. This would mean every property in the global this object are available to library users. Before ES6, … Read more

What’s the maximum size of a Node.js Buffer

Maximum length of a typed array in V8 is currently set to kSmiMaxValue which depending on the platform is either: 1Gb – 1byte on 32-bit 2Gb – 1byte on 64-bit Relevant constant in the code is v8::internal::JSTypedArray::kMaxLength (source). V8 team is working on increasing this even further on 64-bit platforms, where currently ArrayBuffer objects can … Read more

Does V8 have an event loop?

Your intuition is right that the event loop is something that embedders should have control over. However, it is also a fundamental abstract concept of the JavaScript programming model. V8’s solution is to provide a default implementation that embedders can override; you can find it in the “libplatform” component: https://chromium.googlesource.com/v8/v8/+/master/src/libplatform/default-platform.cc#140 See also Relationship between event … Read more

Accessing line number in V8 JavaScript (Chrome & Node.js)

Object.defineProperty(global, ‘__stack’, { get: function(){ var orig = Error.prepareStackTrace; Error.prepareStackTrace = function(_, stack){ return stack; }; var err = new Error; Error.captureStackTrace(err, arguments.callee); var stack = err.stack; Error.prepareStackTrace = orig; return stack; } }); Object.defineProperty(global, ‘__line’, { get: function(){ return __stack[1].getLineNumber(); } }); console.log(__line); The above will log 19. Combined with arguments.callee.caller you can get … Read more

Dumping whole array: console.log and console.dir output “… NUM more items]”

Setting maxArrayLength There are a few methods all of which require setting maxArrayLength which otherwise defaults to 100. Provide the override as an option to console.dir console.dir(myArry, {‘maxArrayLength’: null}); Set util.inspect.defaultOptions.maxArrayLength = null; which will impact all calls to console.log and util.format Call util.inspect yourself with options. const util = require(‘util’) console.log(util.inspect(array, { maxArrayLength: null … Read more