This file contains 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
define('tilemap', function() { | |
var TileMap = (function() { | |
var TileMap = function(width, height) { | |
if (width == null) { | |
width = { | |
min: 0, | |
max: 4 | |
}; |
This file contains 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
class Observable | |
constructor: (data) -> | |
@changes = [] | |
Object.defineProperty @, 'data', | |
get: -> data | |
set: (value) -> | |
data = value | |
i() for i in @changes | |
value |
This file contains 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
class Behavior | |
constructor: (descriptor) -> | |
mixedice [@, @::], new EventMap() | |
@type = 'Behavior' | |
@name = "#{@type}-#{Date.now()}" | |
@children = {} | |
@parent = null |
This file contains 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
class GameObject | |
constructor: -> | |
@x = 0 | |
@y = 0 | |
@behaviors = {} | |
andObject = @ | |
@move = (x, y) => | |
@x += x |
This file contains 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 normalize = function(path, delimiter) { | |
if (delimiter == null) { | |
delimiter = '/'; | |
} | |
var pathArr = path.split(delimiter); | |
var newPath = []; | |
for (var i = 0, j = pathArr.length; i < j; i++) { | |
(function(item) { |
This file contains 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() { | |
var modules = {}; | |
var require = function(name) { | |
var globals = Object.keys(window); | |
if (Object.keys(modules).length !== globals.length) { | |
globals.forEach(function(item) { | |
if (!Object.hasOwnProperty.call(modules, item)) { | |
modules[item] = window[item]; |
This file contains 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 propertyValue = function(obj, key, separator = '.') { | |
var keyArray = key.split(separator); | |
var result = obj; | |
for (var i = 0, j = keyArray.length; i < j; i++) { | |
(function(name) { | |
result = result[name]; | |
})(keyArray[i]); | |
} | |
This file contains 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(root) { | |
var modules = {}; | |
var cache = {}; | |
root.require = function(name) { | |
if (!Object.hasOwnProperty.call(cache, name)) { | |
var module = { | |
id: name, | |
}; |
This file contains 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 ReactMixin = function(...mixins) { | |
return function(Component) { | |
mixins.forEach(function(mixin) { | |
Object.keys(mixin).forEach(function(methodName) { | |
const methodValue = mixin[methodName]; | |
if (methodName === 'statics') { | |
Object.keys(mixin.statics).forEach(function(staticProp) { | |
const staticValue = mixin.statics[staticProp]; |
This file contains 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
// Originally, I wanted to a simple Node.js Event Emitter-style object in less than 150 characters, but it just wouldn't fit | |
/* | |
Couple of thoughts | |
* The name Emitter shouldn't be changed | |
* `var` is missing, so it's directly bound to `window` and we're saving characters (Yeah for using a JS bad practice to our advantage) | |
* While `e` as the property isn't really amazing, it's just there to use as little characters as possible | |
* Obviously, there is no checking if the events really exist | |
* With ES6, method shorthands and arrow functions it would be considerably less than 150 characters |
OlderNewer