Skip to content

Instantly share code, notes, and snippets.

@cevek
cevek / promise-devtools.js
Created September 19, 2018 12:33
Devtools enhancement: Pause on exceptions inside promise.then or catch without checked caught in exceptions
function create(fn, name) {
if (fn === undefined) return;
const callback = data => {
let ret;
new Promise(() => (ret = fn(data)));
return ret;
};
callback.displayName = name;
return callback;
}
function abc(obj, prop) {
for (let j = 0; j < 1e7; j++) {
var x = obj[prop];
}
return x;
}
function abc2(obj) {
for (let j = 0; j < 1e7; j++) {
var x = obj.b;
--use-strict (enforce strict mode)
type: bool default: false
--es-staging (enable test-worthy harmony features (for internal use only))
type: bool default: false
--harmony (enable all completed harmony features)
type: bool default: false
--harmony-shipping (enable all shipped harmony features)
type: bool default: true
--harmony-regexp-sequence (enable "RegExp Unicode sequence properties" (in progress))
type: bool default: false
@cevek
cevek / example.js
Last active October 19, 2018 20:21
var foo, bar;
class Aaa {
constructor(a, b) {
this.a = a;
this.b = b;
}
}
class Bbb {
https://cs.chromium.org/chromium/src/v8/src/runtime/runtime.h?l=20&rcl=05720af2b09a18be5c41bbf224a58f3f0618f6be
@cevek
cevek / index.html
Last active October 25, 2018 17:29
set vs array performance
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
import * as ts from 'typescript';
const watchCompilerHost = ts.createWatchCompilerHost(
['index.ts'],
{strict: true, target: ts.ScriptTarget.ESNext},
ts.sys,
);
const originalCreateProgram = watchCompilerHost.createProgram;
watchCompilerHost.watchFile = (path, callback) => {
// console.log('watchFile', path);
return {
@cevek
cevek / nouns
Created August 22, 2019 18:34
programing words
specification
interpretation
initialization
implementation
persistence
orientation
inheritance
environment
compilation
registration
import * as React from 'react';
import * as ReactDom from 'react-dom';
type ZoneContext = {name: string; params?: {}; parent: ZoneContext | null; children: ZoneContext[]};
const Context = React.createContext<ZoneContext | null>(null);
function useMetrika(someData?: {}) {
const context = React.useContext(Context);
const parents: ZoneContext[] = [];
if (context !== null) {
let ctx = context;
function prepare(n) {
const arr = [];
for (let i = 0; i < n; i++) {
arr[i] = {a: i % 2 === 0 ? -i : i, b: {h: {x: i}, c: {i: i, d: {e: {e: {u: {x: i}}}}}}};
}
shuffleArray(arr);
return arr;
}
function shuffleArray(array) {
for (var i = array.length - 1; i > 0; i--) {