This file contains hidden or 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
import fs from 'fs'; | |
import express from 'express'; | |
import https from 'https'; | |
import { createServer as createViteServer } from 'vite'; | |
import createProxyMiddleware from 'http-proxy-middleware'; | |
import ws from 'ws'; | |
import { parse } from 'url'; | |
const dataproxy = createProxyMiddleware('XXX', { changeOrigin: true }); |
This file contains hidden or 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
import { Chunk, ParamType } from './pathParser' | |
import { last } from 'ramda' | |
const evalCache = Object.create(null) | |
const cachedEval = (fn: string): (path: string[]) => {} => { | |
if (!evalCache[fn]) { | |
/* see MDN https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval | |
* from the line "If you use the eval function indirectly..." | |
**/ | |
const globalEval = eval |
This file contains hidden or 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 router (method: string, path: string) { | |
const chunks = path.split('/') | |
let endpoints = compiledTrieMap | |
let children = endpoints.children | |
const chunksLength = chunks.length | |
let i = 0 | |
while (true) { | |
const chunk = chunks[i] | |
if (children.has(chunk)) { |
This file contains hidden or 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
import { compileTrie } from './compileTrie' | |
import { Trie } from './Trie' | |
const makeTrie = (name: string, ...paths: string[]) => { | |
const trie = new Trie() | |
for (const key of paths) { | |
trie.mapValue(key.split('/'), () => `${name} ${key}`) | |
} | |
return trie | |
} |
This file contains hidden or 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 class Node<Value> { | |
children: { | |
[key: string]: Node<Value> | |
} = {} | |
value?: Value | |
hasValue: boolean = false | |
setValue (value: Value) { | |
this.hasValue = true |
This file contains hidden or 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
This file contains hidden or 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 async_hooks = require('async_hooks'); | |
const triggerMap = {}; | |
const asyncId = async_hooks.executionAsyncId(); | |
const triggerId = async_hooks.triggerAsyncId(); | |
const envs = {}; | |
global.env = undefined; | |
let lastResolvedPromiseAsyncId; |
This file contains hidden or 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
require('./magic'); | |
function a() { | |
console.log(global.env.test) | |
} | |
Promise.resolve() | |
.then(async function () { | |
global.env.test = 'baz'; | |
console.log('in async 1', global.env.test); |
This file contains hidden or 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
I, Vsevolod Rodionov, have read and do accept the MuleSoft Contributor Agreement | |
at http://www.mulesoft.org/legal/contributor-agreement.html | |
Accepted on Mon Mar 27 2017 12:19:20 GMT+0300 (+03) |
This file contains hidden or 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 R = require('ramda'); | |
void 0; //to not bloat the output | |
var random = require('seed-random')(1337); | |
var data = [ | |
{input: [0, 0], output: 0}, | |
{input: [1, 0], output: 1}, | |
{input: [0, 1], output: 1}, | |
{input: [1, 1], output: 0}, | |
]; | |
var activation_sigmoid = x => 1 / (1 + Math.exp(-x)); |
NewerOlder