Skip to content

Commit

Permalink
added fnwrap in set() (fixes #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgentle committed Nov 20, 2011
1 parent 6a161e4 commit beced75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion shim.coffee
Expand Up @@ -14,7 +14,12 @@ fnwrap = (target) -> -> target.apply this, arguments

mkwrap = (src, pass=[], special={}) ->
obj =
set: (key, val, cb=->) -> cb src[key] = val
set: (key, val, cb=->) ->

#Fnwrap so PhantomJS doesn't segfault when it tries to call the callback
val = fnwrap val if typeof val is "function"
cb src[key] = val

get: (key, cb) -> cb src[key]

for k in pass
Expand Down
1 change: 1 addition & 0 deletions shim.js
Expand Up @@ -1595,6 +1595,7 @@ require.define("/shim.coffee", function (require, module, exports, __dirname, __
obj = {
set: function(key, val, cb) {
if (cb == null) cb = function() {};
if (typeof val === "function") val = fnwrap(val);
return cb(src[key] = val);
},
get: function(key, cb) {
Expand Down

0 comments on commit beced75

Please sign in to comment.