Deriving a new Array from an existing Array:
['■','●','▲'].slice(1, 3) ⟼ ['●','▲']
['■','●','■'].filter(x => x==='■') ⟼ ['■','■']
['▲','●'].map(x => x+x) ⟼ ['▲▲','●●']
['▲','●'].flatMap(x => [x,x]) ⟼ ['▲','▲','●','●']
import React from 'react'; | |
export function createStrictContext(options = {}) { | |
const Context = React.createContext(undefined); | |
Context.displayName = options.name; | |
function useContext() { | |
const context = React.useContext(Context); | |
if (!context) { | |
throw new Error(options.errorMessage || `${name || ''} Context Provider is missing`); | |
} |
How to get Pull Requests data using Github in the browser, or using the API to allow for automating reporting or building in values into a website.
import { createHash, randomBytes } from 'crypto'; | |
import * as request from 'request'; | |
/** | |
* The configuration object | |
* | |
* @export | |
* @interface IAuthServiceConfig | |
*/ | |
export interface IAuthServiceConfig { |
//@flow | |
import request from 'request' | |
import crypto from 'crypto' | |
import rp from 'request-promise' | |
export type AuthServiceConfig = { | |
authorizeEndpoint: string, | |
clientId: string, | |
audience: string, | |
scope: string, |
The benchmarks used by Marko, with one benchmark containing only a single component with ~50 lines of code, and the other 3 components with one of them fully static markup, are typical micro-benchmarks created to the advantage of certain implementation details. They are too isolated and too trivial to justify across-the-board performance claims.
For client-side performance I recommend using the 3rd party js-framework-benchmark as a more neutral reference; the benchmark tests a much bigger workload and covering a much more comprehensive performance scenarios. According to the data from the latest round Vue actually outperforms Marko. That said, even this benchmark doesn't reflect real world performance where much more overhead comes from big component trees.
Vue has significantly improved SSR performance for
(function (global, document, url) { | |
var calls = []; | |
var spy = {}; | |
var methods = ['config', 'install', 'setUserContext', 'captureException']; | |
for (var i = 0, method; method = methods[i]; i += 1) { | |
spy[method] = (function (name) { | |
return function () { | |
calls.push([name, arguments]); | |
return this; |
{ | |
"presets": [ | |
["es2015", { | |
"es2015": { | |
"loose": true, | |
"modules": false | |
} | |
}], "react" | |
] | |
} |
/* | |
** | |
** Example of Interprocess communication in Node.js through a UNIX domain socket | |
** | |
** Usage: | |
** server> MODE=server node ipc.example.js | |
** client> MODE=client node ipc.example.js | |
** | |
*/ |
Below is the list of modern JS frameworks and almost frameworks – React, Vue, Angular, Ember and others.
All files were downloaded from https://cdnjs.com and named accordingly.
Output from ls
command is stripped out (irrelevant stuff)
$ ls -lhS
566K Jan 4 22:03 angular2.min.js