Comparing version 0.2.2 to 0.2.3
{ | ||
"name": "hutil", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Hola Utilities", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,2 +6,3 @@ // LICENSE_CODE ZON ISC | ||
var is_node = typeof module=='object' && module.exports && module.children; | ||
var is_rn = typeof navigator=='object' && navigator.product=='ReactNative'; | ||
var is_ff_addon = typeof module=='object' && module.uri | ||
@@ -13,2 +14,8 @@ && !module.uri.indexOf('resource://'); | ||
define = require('./require_node.js').define(module, '../'); | ||
else if (is_rn) | ||
{ | ||
define = require('./require_node.js').define(module, '../', | ||
require('/util/events.js'), require('/util/array.js'), | ||
require('/util/util.js')); | ||
} | ||
else | ||
@@ -20,6 +27,5 @@ define = self.define; | ||
}; | ||
assert = function(){}; // XXX romank: add proper assert | ||
// XXX romank: use zerr.js | ||
// XXX bahaa: require bext/pub/zerr.js for extensions | ||
if (!is_ff_addon && self.hola && self.hola.zerr) | ||
if (!is_ff_addon && !is_rn && self.hola && self.hola.zerr) | ||
zerr = self.hola.zerr; | ||
@@ -45,2 +51,6 @@ else | ||
} | ||
// XXX odin: normally this would only be run for !is_node, but 'who' unittests | ||
// loads a stubbed assert | ||
if (typeof assert!='function') | ||
assert = function(){}; // XXX romank: add proper assert | ||
// XXX yuval: /util/events.js -> events when node 6 (support prependListener) | ||
@@ -60,6 +70,10 @@ // is here | ||
E.events = new events(); | ||
var cb_pre, cb_post, longcb_ms, perf_enable; | ||
var cb_pre, cb_post, cb_ctx, longcb_ms, perf_enable; | ||
E.perf_stat = {}; | ||
// XXX romang: hack to import in react native | ||
if (is_rn) | ||
E.etask = E; | ||
function _cb_pre(et){ return {start: Date.now()}; } | ||
function _cb_post(et, ctx){ | ||
ctx = ctx||cb_ctx; | ||
var ms = Date.now()-ctx.start; | ||
@@ -84,5 +98,6 @@ if (longcb_ms && ms>longcb_ms) | ||
cb_post = _cb_post; | ||
cb_ctx = {start: Date.now()}; | ||
} | ||
else | ||
cb_pre = cb_post = undefined; | ||
cb_pre = cb_post = cb_ctx = undefined; | ||
} | ||
@@ -288,3 +303,3 @@ E.longcb = function(ms){ | ||
while (this.then_waiting.length) | ||
this.then_waiting.pop()(); | ||
this.then_waiting.shift()(); | ||
}; | ||
@@ -562,4 +577,3 @@ E.prototype._next = function(rv){ | ||
E.prototype.finally = function(cb){ | ||
this.prependListener('finally', cb); | ||
}; | ||
this.prependListener('finally', cb); }; | ||
E.prototype.goto_fn = function(name){ | ||
@@ -646,3 +660,5 @@ return this.goto.bind(this, name); }; | ||
wait_retval.completed = true; | ||
this._next_run(E._res2rv(res)); | ||
// inline _next_run to reduce stack depth | ||
if (!this._next(E._res2rv(res))) | ||
this._run(); | ||
}; | ||
@@ -1419,2 +1435,4 @@ E.prototype.continue_fn = function(){ | ||
} | ||
var is_generator = typeof states=='function' && | ||
states.constructor.name=='GeneratorFunction'; | ||
return function(){ | ||
@@ -1425,3 +1443,5 @@ var _opt = assign({}, opt); | ||
_opt.state0_args.unshift(this); | ||
return etask(_opt, states); | ||
if (is_generator) | ||
return E._generator(null, states, _opt); | ||
return new Etask(_opt, states); | ||
}; | ||
@@ -1437,3 +1457,3 @@ } | ||
var done; | ||
return etask(opt, [function(){ | ||
return new Etask(opt, [function(){ | ||
this.generator = gen = gen||ctor.apply(this, opt.state0_args||[]); | ||
@@ -1440,0 +1460,0 @@ this.generator_ctor = ctor; |
@@ -23,3 +23,2 @@ // LICENSE_CODE ZON ISC | ||
var cluster = require('cluster'); | ||
var fs = require('fs'); | ||
var version = require('./version.js').version; | ||
@@ -65,3 +64,3 @@ } | ||
try { return JSON.stringify(o, replacer, space)||''; } | ||
catch(err){ return '[circular]'; } | ||
catch(e){ return '[circular]'; } | ||
}; | ||
@@ -95,4 +94,5 @@ | ||
opt = opt||{}; | ||
var ms = (opt.rate_limit && opt.rate_limit.ms)||date.ms.HOUR; | ||
var count = (opt.rate_limit && opt.rate_limit.count)||10; | ||
var _rate_limit = opt.rate_limit||{}; | ||
var ms = _rate_limit.ms||date.ms.HOUR, count = _rate_limit.count||10; | ||
var disable_drop_count = _rate_limit.disable_drop_count; | ||
var rl_hash = perr_orig.rl_hash = perr_orig.rl_hash||{}; | ||
@@ -106,3 +106,3 @@ var rl = rl_hash[id] = rl_hash[id]||{}; | ||
{ | ||
if (info && typeof info!='string') | ||
if (!disable_drop_count && info && typeof info!='string') | ||
info.w = perr_dropped[id]; | ||
@@ -256,2 +256,13 @@ perr_dropped[id] = null; | ||
} | ||
// workaround for process.zon override issue | ||
if (process.zon && process.zon.main) | ||
{ | ||
// XXX mikhail: expose contsants via zutil module | ||
var LCRIT = 2; | ||
var LCONSOLE = 0x100; | ||
var emb_zutil = process.binding('zutil'); | ||
emb_zutil.zerr(LCRIT|LCONSOLE, 'perr node_zexit '+E.e2s(args)); | ||
process.exit(1); | ||
} | ||
var conf = require('./conf.js'); | ||
var zcounter_file = require('./zcounter_file.js'); | ||
@@ -261,3 +272,3 @@ zcounter_file.inc('server_zexit'); | ||
write_zexit_log({id: 'server_zexit', info: ''+args, ts: date.to_sql(), | ||
backtrace: stack, version: version}); | ||
backtrace: stack, version: version, app: conf.app}); | ||
E.flush(); | ||
@@ -264,0 +275,0 @@ debugger; |
288235
9280
16