This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Utils_GlobalsMgmt = { | |
temp_disable_screenupdating: function(excel_app, func) { | |
var original_setting = excel_app.ScreenUpdating | |
excel_app.ScreenUpdating = false; | |
var output = func(); | |
excel_app.ScreenUpdating = original_setting; | |
return output; | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_text_in_file(filepath) { | |
var FS = new ActiveXObject("Scripting.FileSystemObject"); | |
return FS.OpenTextFile(filepath, 1).ReadAll(); // 1 = for reading | |
} | |
function require(filepath) { | |
eval(get_text_in_file(filepath)); | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
An object literal containing arrays and computed properties | |
can act as a recordset. | |
This would be a pain to edit in a text editor for long arrays, | |
but Mesh should make it intuitive via the grid interface. | |
*/ | |
const data = { | |
name: ['John Doe', 'Jane Smith'], | |
age: [30, 29], | |
get adult_yrs() {return this.age.map(x => x - 18)}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
module.exports = (function() { | |
// It would be good to get rid of the my_module declaration entirely | |
const my_module = { | |
a: 'abc', | |
get b() {return 123}, | |
get c() {return my_module.a}, | |
get c2() {return this.a}, | |
get d() {return { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define a sheet (ATTACHMENTS omitted for brevity) | |
const calc = { | |
term: 3, | |
rate: 0.05, | |
start_value: 100, | |
get end_value() {return this.start_value * (1 + this.rate) ** this.term} | |
} | |
// Simple example of using a sheet as a template - | |
// equivalent in Excel would be overwriting a cell, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The below format takes the 'store each sheet in one file' approach. | |
// | |
// I suspect we will end up deciding having multiple sheets in one file would be bad practice | |
// (eg too much code to read in one file, and better coding style to keep things modular). | |
// | |
// A single-sheet-per-file approach would likely discourage inter-sheet references | |
// (as in, imports or requires), because of the overhead of having an extra import. | |
// What I *think* would happen instead is you'd have: | |
// - an 'assumptions' sheet which is full of hardcodes, | |
// - a 'calcs' sheet that contains only the assumptions it needs for its calcs, and |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const ROOT = { | |
get _cache() { | |
// These two lines let the proxy get access to the sheet | |
const calc = this; | |
delete calc._cache; | |
return (calc._cache = new Proxy({}, { | |
get(c, k) { | |
// TODO how does speed compare to try/catch? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ROOT = [ | |
['hello', [1, 1], $ => `world`], | |
['calc', [0, 0], $ => $['hello']], | |
].reduce((o,[k,g,v]) => Object.defineProperty(o, k, { | |
get: () => { | |
console.log('Recording', k); | |
delete o[k]; | |
return o[k]=v(o) | |
}, | |
configurable:true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myWorker = new Worker('worker.js'); | |
myWorker.onmessage = (e) => console.log(e.data); | |
myWorker.postMessage("Hello!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Table extends Array { | |
static get [Symbol.species]() { return Array; } // Fixes map method | |
constructor() { | |
super(); | |
Object.defineProperty(this, '_iteratorPairs', {value: []}); | |
Object.defineProperty(this, '_headings', {value: []}); | |
for (let {heading:h, iterable:i} of arguments) { | |
this._headings.push(h); | |
this._iteratorPairs.push([h, i[Symbol.iterator]()]); | |
Object.defineProperty(this, h, {get: () => this.map(r => r[h])}); |
OlderNewer