Alternatively, use esbuild
and tsc
through the CLI to generate both CJS and ESM outputs: https://dev.to/endel/nodejs-package-authors-please-support-both-cjs-and-esm-1oj3
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
/* | |
* modified from http://www.voidware.com/moon_phase.htm | |
*/ | |
function getMoonPhase(year, month, day) | |
{ | |
var c = e = jd = b = 0; | |
if (month < 3) { | |
year--; |
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
#!/usr/local/bin/fontforge | |
Open($1) | |
Generate($1:r + ".otf") | |
Generate($1:r + ".svg") | |
Generate($1:r + ".woff") | |
Generate($1:r + ".woff2") |
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
// This code was written by Tyler Akins and has been placed in the | |
// public domain. It would be nice if you left this header intact. | |
// Base64 code from Tyler Akins -- http://rumkin.com | |
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; | |
function encode64(input) { | |
var output = new StringMaker(); | |
var chr1, chr2, chr3; | |
var enc1, enc2, enc3, enc4; |
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
# Allow non-root node to use ports 80 (HTTP) and 443 (HTTPS) | |
sudo setcap 'cap_net_bind_service=+ep' $(which node) |
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
Number.prototype.pad = function(size) { | |
var s = String(this); | |
while (s.length < (size || 2)) {s = "0" + s;} | |
return s; | |
} | |
(1).pad(3) // => "001" | |
(10).pad(3) // => "010" | |
(100).pad(3) // => "100" |
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
room.onStateChange.once(function() { | |
function registerCallbacksOnStructure (schemaInstance, path) { | |
const schema = schemaInstance['_definition'].schema; | |
for (let field in schema) { | |
const schemaType = typeof(schema[field]); | |
if (schemaType === "object") { | |
// on item added to collection | |
schemaInstance[field].onAdd(function (item, key) { | |
onItemAdd([...path, field], item, key); |
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
// three.js JSON Atlas Loader | |
// Requires: whatwg-fetch (https://github.com/github/fetch) | |
var materials = {} | |
fetch('images/spritesheet.json').then(function(response) { | |
return response.json() | |
}).then(function(json) { | |
var atlasTexture = THREE.ImageUtils.loadTexture('images/' + json.meta.image, undefined, function() { |
Hi everybody! Regarding the possible new schema callback API, so far this is what I could came up so far, feedback highly appreciated! Do let me know if you feel I need to clarify anything!
I understand this may be long and hard to grasp, I can provide a side-by-side comparison between the new API and previous one so you can clearly see the difference.
The new API would allow to create all the callbacks at once, after the connection with the room has been established (even on deep structures) - rather than binding callbacks as Schema instances that are created on-demand on the client-side.
class Point extends Schema {
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
export function* generateUserAgent() { | |
let webkitVersion = 10; | |
let chromeVersion = 1000; | |
const so = [ | |
'Windows NT 6.1; WOW64', | |
'Windows NT 6.2; Win64; x64', | |
"Windows NT 5.1; Win64; x64",, | |
'Macintosh; Intel Mac OS X 10_12_6', | |
"X11; Linux x86_64", |
NewerOlder