Skip to content

Instantly share code, notes, and snippets.

Joel Kemp mrjoelkemp

Block or report user

Report or block mrjoelkemp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mrjoelkemp
mrjoelkemp / go-defer.js
Last active Dec 22, 2017
Go-style defer without dependency injection
View go-defer.js
var deferrable = function (cb) {
function getFunctionBody(code) {
var functionDef = code.match(/\{(.|[\r\n])+\}/);
// Strip body of all useless chars
return functionDef[0].replace(/\{|\}/g, '')
}
var
// Grab the entire defer() block
@mrjoelkemp
mrjoelkemp / parseFunctionArguments.js
Created Sep 11, 2013
For every function on a given object, set up the function to auto-parse stringified arguments. Use case: In Flash to Javascript communication, this avoids the need to manually parse for every JS api endpoint.
View parseFunctionArguments.js
function parseFunctionArguments (obj) {
for (var method in obj) {
if (obj.hasOwnProperty(method) && typeof obj[method] === 'function') {
(function (method) {
var func = obj[method];
obj[method] = function () {
// Try to convert each string arg into an object literal
var converted = [].map.call(arguments, function (v) {
if (typeof v === 'string') {
You can’t perform that action at this time.