Skip to content

Instantly share code, notes, and snippets.

View arv's full-sized avatar
👋
Reflecting...

Erik Arvidsson arv

👋
Reflecting...
View GitHub Profile
Object.prototype.$super = function() {
var func = arguments.callee.caller;
var name = func.foundName_;
if (!name) {
for (var p in this) {
if (this[p] == func) {
name = p;
break;
}
}
@arv
arv / gist:3900429
Created October 16, 2012 16:39
indent import
import {
variablesInFunction,
variablesInBlock,
thinger,
otherthinger,
...
} from '../semantics/VariableBinder.js';
@arv
arv / gist:3900474
Created October 16, 2012 16:45
ExportSpecifierSet
ExportSpecifierSet ::= "{" ExportSpecifier ("," ExportSpecifier)* "}" ("from" Path)?
| Id ("from" Path)?
| "*" ("from" Path)?
@arv
arv / gist:3756613
Created September 20, 2012 15:28
notify
var data = 42;
var object = {
get x() {
return data;
},
set x(v) {
notifier.notify({
type: 'updated',
name: 'x',
oldValue: data
@arv
arv / ES5 + __proto__
Created June 1, 2012 22:16
Custom Elements
// And in browsers that support __proto__:
document.register('x-foo', {
extends: 'p',
prototype: {
__proto__: HTMLParagraphElement.prototype,
get foo() { return 'foo'; }
}
})
var C = 1;
function f(x = C) {
var C = 2;
return x;
}
var result = f(); // ???
@arv
arv / node-append.js
Created October 6, 2011 21:56
Node.prototype.append
(function() {
function isNode(value) {
return value instanceof Node;
}
function isAttrObject(value) {
return value != null && typeof value === 'object' && !isNode(value);
}
'use strict';
class Base {
constructor(x) {
this.x = x;
}
}
let f;
class D1 extends Base {
constructor() {
@arv
arv / .js
Last active August 29, 2015 14:17
createPropertyAccessor: function(name, ignoreWrites) {
var proto = this.prototype;
var privateName = name + '_';
var privateObservable = name + 'Observable_';
Object.defineProperty(proto, name, {
get: function() {
var observable = this[privateObservable];
if (observable)
observable.deliver();
@arv
arv / test.js
Created February 20, 2015 01:38
Map -0 bug
var assert = {
equal: function(x, y) {
if (x === y) return;
throw new Error();
},
isTrue: function(x) {
if (x) return;
throw new Error();
}
};