Comparing version 0.2.3-1 to 0.3.0
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.4.0 | ||
// Generated by CoffeeScript 1.6.3 | ||
var __hasProp = {}.hasOwnProperty, | ||
@@ -6,3 +6,3 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
module.exports = (function() { | ||
var ALIASES, CLEAN_THRESHOLD, INITIAL_THRESHOLD, IntervalTask, LinkedList, Task, TimeoutTask, Timer, alias, aliases, bindAll, key, taskFactoryFor, timer, validate; | ||
var ALIASES, CLEAN_THRESHOLD, INITIAL_THRESHOLD, IntervalTask, LinkedList, Task, TimeoutTask, Timer, alias, aliases, bindAll, key, taskFactoryFor, timer, validate, _ref, _ref1; | ||
INITIAL_THRESHOLD = 10; | ||
@@ -61,3 +61,2 @@ CLEAN_THRESHOLD = 1.10; | ||
Task = (function() { | ||
function Task(time, action) { | ||
@@ -104,2 +103,16 @@ this.id = null; | ||
Task.prototype.unref = function() { | ||
if (!(this.id && typeof this.id.unref === 'function')) { | ||
return; | ||
} | ||
return this.id.unref(); | ||
}; | ||
Task.prototype.ref = function() { | ||
if (!(this.id && typeof this.id.ref === 'function')) { | ||
return; | ||
} | ||
return this.id.ref(); | ||
}; | ||
Task.prototype._pause = function() { | ||
@@ -117,7 +130,7 @@ throw new Error('must be overridden'); | ||
IntervalTask = (function(_super) { | ||
__extends(IntervalTask, _super); | ||
function IntervalTask() { | ||
return IntervalTask.__super__.constructor.apply(this, arguments); | ||
_ref = IntervalTask.__super__.constructor.apply(this, arguments); | ||
return _ref; | ||
} | ||
@@ -153,7 +166,7 @@ | ||
TimeoutTask = (function(_super) { | ||
__extends(TimeoutTask, _super); | ||
function TimeoutTask() { | ||
return TimeoutTask.__super__.constructor.apply(this, arguments); | ||
_ref1 = TimeoutTask.__super__.constructor.apply(this, arguments); | ||
return _ref1; | ||
} | ||
@@ -183,4 +196,4 @@ | ||
return function(timeout, action) { | ||
var task, _ref; | ||
_ref = validate(timeout, action), timeout = _ref[0], action = _ref[1]; | ||
var task, _ref2; | ||
_ref2 = validate(timeout, action), timeout = _ref2[0], action = _ref2[1]; | ||
task = new Klass(timeout, action); | ||
@@ -196,3 +209,2 @@ this.tasks.push(task); | ||
Timer = (function() { | ||
Timer.prototype.paused = false; | ||
@@ -252,2 +264,22 @@ | ||
Timer.prototype.unref = function() { | ||
var _results; | ||
this.tasks.resetCursor(); | ||
_results = []; | ||
while (this.tasks.next()) { | ||
_results.push(this.tasks.current.unref()); | ||
} | ||
return _results; | ||
}; | ||
Timer.prototype.ref = function() { | ||
var _results; | ||
this.tasks.resetCursor(); | ||
_results = []; | ||
while (this.tasks.next()) { | ||
_results.push(this.tasks.current.ref()); | ||
} | ||
return _results; | ||
}; | ||
Timer.prototype._checkAndClean = function() { | ||
@@ -254,0 +286,0 @@ if (!(this.tasks.length > this._lastCleanedLength * CLEAN_THRESHOLD)) { |
{ | ||
"name": "timer-shim", | ||
"version": "0.2.3-1", | ||
"version": "0.3.0", | ||
"description": "Test-friendly timer function replacements.", | ||
@@ -23,9 +23,9 @@ "main": "index.js", | ||
"devDependencies": { | ||
"mocha-istanbul": "~0.1.0", | ||
"mocha": "~1.8.1", | ||
"istanbul": "~0.1.22", | ||
"coffee-script": "~1.4.0", | ||
"chai": "~1.3.0", | ||
"sinon": "~1.6.0", | ||
"mocha-subject": "~0.1.1" | ||
"mocha-istanbul": "~0.2.0", | ||
"mocha-subject": "~0.2.0", | ||
"coffee-script": "~1.6.3", | ||
"chai": "~1.7.2", | ||
"mocha": "~1.12.0", | ||
"sinon": "~1.7.3", | ||
"istanbul": "~0.1.43" | ||
}, | ||
@@ -32,0 +32,0 @@ "dependencies": { |
@@ -111,2 +111,10 @@ | ||
`timer.unref` | ||
Calls [`unref()`][2] if inside node.js environment. Effectively prevents all timers set so | ||
far to keep the process alive if they are the only thing waiting to run inside the event | ||
loop. Useful for cleaning up after timer tests. | ||
`timer.ref` | ||
Calls [`ref()`][3] if inside node.js environment. Reverses the effect of `unref()`. | ||
# OVERLOADS | ||
@@ -124,2 +132,8 @@ | ||
# REFS / UNREFS | ||
All timers are `ref()`-ed by default. See [node.js timers doc][0] for more information | ||
about `ref()` and `unref()`. For convenience `timer-shim` provides a top-level `unref()` | ||
method to `unref()` on all timers. | ||
# DEVELOPMENT | ||
@@ -154,3 +168,8 @@ | ||
Just open a GitHub issue or ping me [@chakrit](http://twitter.com/chakrit) on Twitter. | ||
Just open a GitHub issue or ping me [@chakrit][1] on Twitter. | ||
[0]: http://nodejs.org/api/timers.html | ||
[1]: http://twitter.com/chakrit | ||
[2]: http://nodejs.org/api/timers.html#timers_unref | ||
[3]: http://nodejs.org/api/timers.html#timers_ref | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32051
301
173