Skip to content

Instantly share code, notes, and snippets.

View ooflorent's full-sized avatar

Florent Cailhol ooflorent

  • Toulouse, France
  • 21:55 (UTC +02:00)
  • X @ooflorent
View GitHub Profile
@ooflorent
ooflorent / instance-const.js
Last active August 29, 2015 14:14
Research about instance constants
function Obj(x) {
if (typeof x !== 'number') throw new Error()
Object.defineProperty(this, 'x', {value: x})
}
var a = new Obj(1)
var b = new Obj(2)
// Do `a` and `b` have the same hidden class in v8?
//
@ooflorent
ooflorent / c1.dart.js
Created February 3, 2015 09:14
dart2js curiosities
// Curiosity #1
// ------------
function dart() {
this.x = 0;
delete this.x;
}
var A = new dart;
export const READ_ONLY = 1
export const DONT_ENUM = 2
export const DONT_DELETE = 4
export function InstallFunctions(object, attributes, functions) {
for (let i = 0; i < functions.length; i += 2) {
let field = functions[i]
let value = functions[i + 1]
AddNamedProperty(object, field, value, attributes)

Usage

var FastMap = require('./fast')
var someMap = FastMap()
---
parser: babel-eslint
ecmaFeatures:
modules: true
env:
es6: true
browser: true
node: true
@ooflorent
ooflorent / flux.js
Created April 16, 2015 13:31
Dummy Flux implementation
export const actions = {
doSomeStuff() {
return fetch('/api/stuff').then(
(res) => (stores.stuffList = res),
(err) => Promise.reject(err)
)
}
}
export const stores = {
@ooflorent
ooflorent / README.md
Last active December 23, 2015 23:49
Strange performance results with makr.js. Could someone explain the third test results?
var Token = {
Concatenate: '0',
Increment: '1',
Decrement: '2',
Multiply: '3',
Divide: '4',
Add: '5',
Subtract: '6',
Exponent: '7',
Modulus: '8',
const eventBus = new EventEmitter()
function someSystem() {
for (const entity of em.query(Timer)) {
const {delay} = entity.get(Timer)
if (delay <= 0) {
// Remove `Timer` component…
entity.remove(Timer)
// …then dispatch an event
eventBus.emit("componentRemoved", {entity})
@ooflorent
ooflorent / webpack.config.js
Last active August 28, 2017 19:05
Simplify extension management in webpack
const ext = (...suffix) => new RegExp(`\\.(?:${ suffix.join('|') })(?:[?#].*)?$`)
const loaders = [
// Traditional cases
{ test: ext('css'), loaders: ['style', 'css'] }, // single
{ test: ext('js', 'jsx', 'es6'), loaders: ['babel'] }, // multiple
// Complex case: Font-Awesome adds query strings and/or hashs to files
{ test: ext('otf', 'eot', 'svg', 'ttf', 'woff', 'woff2'), loaders: ['file?name=[name].[ext]'] },
]