Comparing version 2.0.0 to 3.0.0
@@ -1,11 +0,11 @@ | ||
// https://d3js.org/d3-timer/ v2.0.0 Copyright 2020 Mike Bostock | ||
// https://d3js.org/d3-timer/ v3.0.0 Copyright 2021 Mike Bostock | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = global || self, factory(global.d3 = global.d3 || {})); | ||
}(this, function (exports) { 'use strict'; | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {})); | ||
}(this, (function (exports) { 'use strict'; | ||
var frame = 0, // is an animation frame pending? | ||
timeout = 0, // is a timeout pending? | ||
interval = 0, // are any timers active? | ||
timeout$1 = 0, // is a timeout pending? | ||
interval$1 = 0, // are any timers active? | ||
pokeDelay = 1000, // how frequently we check for clock skew | ||
@@ -68,3 +68,3 @@ taskHead, | ||
while (t) { | ||
if ((e = clockNow - t._time) >= 0) t._call.call(null, e); | ||
if ((e = clockNow - t._time) >= 0) t._call.call(undefined, e); | ||
t = t._next; | ||
@@ -77,3 +77,3 @@ } | ||
clockNow = (clockLast = clock.now()) + clockSkew; | ||
frame = timeout = 0; | ||
frame = timeout$1 = 0; | ||
try { | ||
@@ -110,9 +110,9 @@ timerFlush(); | ||
if (frame) return; // Soonest alarm already set, or will be. | ||
if (timeout) timeout = clearTimeout(timeout); | ||
if (timeout$1) timeout$1 = clearTimeout(timeout$1); | ||
var delay = time - clockNow; // Strictly less than if we recomputed clockNow. | ||
if (delay > 24) { | ||
if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew); | ||
if (interval) interval = clearInterval(interval); | ||
if (time < Infinity) timeout$1 = setTimeout(wake, time - clock.now() - clockSkew); | ||
if (interval$1) interval$1 = clearInterval(interval$1); | ||
} else { | ||
if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay); | ||
if (!interval$1) clockLast = clock.now(), interval$1 = setInterval(poke, pokeDelay); | ||
frame = 1, setFrame(wake); | ||
@@ -122,3 +122,3 @@ } | ||
function timeout$1(callback, delay, time) { | ||
function timeout(callback, delay, time) { | ||
var t = new Timer; | ||
@@ -133,3 +133,3 @@ delay = delay == null ? 0 : +delay; | ||
function interval$1(callback, delay, time) { | ||
function interval(callback, delay, time) { | ||
var t = new Timer, total = delay; | ||
@@ -150,5 +150,5 @@ if (delay == null) return t.restart(callback, delay, time), t; | ||
exports.interval = interval$1; | ||
exports.interval = interval; | ||
exports.now = now; | ||
exports.timeout = timeout$1; | ||
exports.timeout = timeout; | ||
exports.timer = timer; | ||
@@ -159,2 +159,2 @@ exports.timerFlush = timerFlush; | ||
})); | ||
}))); |
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-timer/ v2.0.0 Copyright 2020 Mike Bostock | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t=t||self).d3=t.d3||{})}(this,function(t){"use strict";var n,e,o=0,r=0,i=0,u=1e3,l=0,a=0,c=0,s="object"==typeof performance&&performance.now?performance:Date,f="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function _(){return a||(f(m),a=s.now()+c)}function m(){a=0}function p(){this._call=this._time=this._next=null}function w(t,n,e){var o=new p;return o.restart(t,n,e),o}function d(){_(),++o;for(var t,e=n;e;)(t=a-e._time)>=0&&e._call.call(null,t),e=e._next;--o}function h(){a=(l=s.now())+c,o=r=0;try{d()}finally{o=0,function(){var t,o,r=n,i=1/0;for(;r;)r._call?(i>r._time&&(i=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:n=o);e=t,v(i)}(),a=0}}function y(){var t=s.now(),n=t-l;n>u&&(c-=n,l=t)}function v(t){o||(r&&(r=clearTimeout(r)),t-a>24?(t<1/0&&(r=setTimeout(h,t-s.now()-c)),i&&(i=clearInterval(i))):(i||(l=s.now(),i=setInterval(y,u)),o=1,f(h)))}p.prototype=w.prototype={constructor:p,restart:function(t,o,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?_():+r)+(null==o?0:+o),this._next||e===this||(e?e._next=this:n=this,e=this),this._call=t,this._time=r,v()},stop:function(){this._call&&(this._call=null,this._time=1/0,v())}},t.interval=function(t,n,e){var o=new p,r=n;return null==n?(o.restart(t,n,e),o):(o._restart=o.restart,o.restart=function(t,n,e){n=+n,e=null==e?_():+e,o._restart(function i(u){u+=r,o._restart(i,r+=n,e),t(u)},n,e)},o.restart(t,n,e),o)},t.now=_,t.timeout=function(t,n,e){var o=new p;return n=null==n?0:+n,o.restart(e=>{o.stop(),t(e+n)},n,e),o},t.timer=w,t.timerFlush=d,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
// https://d3js.org/d3-timer/ v3.0.0 Copyright 2021 Mike Bostock | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).d3=t.d3||{})}(this,(function(t){"use strict";var n,e,o=0,i=0,r=0,l=0,u=0,a=0,s="object"==typeof performance&&performance.now?performance:Date,c="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function f(){return u||(c(_),u=s.now()+a)}function _(){u=0}function m(){this._call=this._time=this._next=null}function p(t,n,e){var o=new m;return o.restart(t,n,e),o}function w(){f(),++o;for(var t,e=n;e;)(t=u-e._time)>=0&&e._call.call(void 0,t),e=e._next;--o}function d(){u=(l=s.now())+a,o=i=0;try{w()}finally{o=0,function(){var t,o,i=n,r=1/0;for(;i;)i._call?(r>i._time&&(r=i._time),t=i,i=i._next):(o=i._next,i._next=null,i=t?t._next=o:n=o);e=t,y(r)}(),u=0}}function h(){var t=s.now(),n=t-l;n>1e3&&(a-=n,l=t)}function y(t){o||(i&&(i=clearTimeout(i)),t-u>24?(t<1/0&&(i=setTimeout(d,t-s.now()-a)),r&&(r=clearInterval(r))):(r||(l=s.now(),r=setInterval(h,1e3)),o=1,c(d)))}m.prototype=p.prototype={constructor:m,restart:function(t,o,i){if("function"!=typeof t)throw new TypeError("callback is not a function");i=(null==i?f():+i)+(null==o?0:+o),this._next||e===this||(e?e._next=this:n=this,e=this),this._call=t,this._time=i,y()},stop:function(){this._call&&(this._call=null,this._time=1/0,y())}},t.interval=function(t,n,e){var o=new m,i=n;return null==n?(o.restart(t,n,e),o):(o._restart=o.restart,o.restart=function(t,n,e){n=+n,e=null==e?f():+e,o._restart((function r(l){l+=i,o._restart(r,i+=n,e),t(l)}),n,e)},o.restart(t,n,e),o)},t.now=f,t.timeout=function(t,n,e){var o=new m;return n=null==n?0:+n,o.restart((e=>{o.stop(),t(e+n)}),n,e),o},t.timer=p,t.timerFlush=w,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "d3-timer", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "An efficient queue capable of managing thousands of concurrent animations.", | ||
"homepage": "https://d3js.org/d3-timer/", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/d3/d3-timer.git" | ||
}, | ||
"keywords": [ | ||
@@ -15,4 +20,3 @@ "d3", | ||
], | ||
"homepage": "https://d3js.org/d3-timer/", | ||
"license": "BSD-3-Clause", | ||
"license": "ISC", | ||
"author": { | ||
@@ -22,10 +26,3 @@ "name": "Mike Bostock", | ||
}, | ||
"main": "dist/d3-timer.js", | ||
"unpkg": "dist/d3-timer.min.js", | ||
"jsdelivr": "dist/d3-timer.min.js", | ||
"module": "src/index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/d3/d3-timer.git" | ||
}, | ||
"type": "module", | ||
"files": [ | ||
@@ -35,15 +32,25 @@ "dist/**/*.js", | ||
], | ||
"scripts": { | ||
"pretest": "rollup -c", | ||
"test": "tape 'test/**/*-test.js' && eslint src", | ||
"prepublishOnly": "rm -rf dist && yarn test", | ||
"postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd - && zip -j dist/${npm_package_name}.zip -- LICENSE README.md dist/${npm_package_name}.js dist/${npm_package_name}.min.js" | ||
"module": "src/index.js", | ||
"main": "src/index.js", | ||
"jsdelivr": "dist/d3-timer.min.js", | ||
"unpkg": "dist/d3-timer.min.js", | ||
"exports": { | ||
"umd": "./dist/d3-timer.min.js", | ||
"default": "./src/index.js" | ||
}, | ||
"sideEffects": false, | ||
"devDependencies": { | ||
"eslint": "6", | ||
"rollup": "1", | ||
"rollup-plugin-terser": "5", | ||
"tape": "4" | ||
"eslint": "7", | ||
"mocha": "8", | ||
"rollup": "2", | ||
"rollup-plugin-terser": "7" | ||
}, | ||
"scripts": { | ||
"test": "mocha 'test/**/*-test.js' && eslint src test", | ||
"prepublishOnly": "rm -rf dist && yarn test && rollup -c", | ||
"postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd -" | ||
}, | ||
"engines": { | ||
"node": ">=12" | ||
} | ||
} |
@@ -7,9 +7,21 @@ # d3-timer | ||
If you use NPM, `npm install d3-timer`. Otherwise, download the [latest release](https://github.com/d3/d3-timer/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-timer.v2.min.js) or as part of [D3](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported: | ||
If you use npm, `npm install d3-timer`. You can also download the [latest release on GitHub](https://github.com/d3/d3-timer/releases/latest). For vanilla HTML in modern browsers, import d3-timer from Skypack: | ||
```html | ||
<script src="https://d3js.org/d3-timer.v2.min.js"></script> | ||
<script type="module"> | ||
import {timer} from "https://cdn.skypack.dev/d3-timer@3"; | ||
const t = timer(callback); | ||
</script> | ||
``` | ||
For legacy environments, you can load d3-timer’s UMD bundle from an npm-based CDN such as jsDelivr; a `d3` global is exported: | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/d3-timer@3"></script> | ||
<script> | ||
var timer = d3.timer(callback); | ||
const timer = d3.timer(callback); | ||
@@ -32,3 +44,3 @@ </script> | ||
```js | ||
var t = d3.timer(function(elapsed) { | ||
const t = d3.timer((elapsed) => { | ||
console.log(elapsed); | ||
@@ -35,0 +47,0 @@ if (elapsed > 200) t.stop(); |
@@ -61,3 +61,3 @@ var frame = 0, // is an animation frame pending? | ||
while (t) { | ||
if ((e = clockNow - t._time) >= 0) t._call.call(null, e); | ||
if ((e = clockNow - t._time) >= 0) t._call.call(undefined, e); | ||
t = t._next; | ||
@@ -64,0 +64,0 @@ } |
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
283
88
Yes
18395