{"_id":"4d","_rev":"7-eb130256d86951d07c4c7ee1ad43add6","name":"4d","time":{"modified":"2022-06-12T14:07:47.141Z","created":"2016-10-22T07:35:47.193Z","0.0.2":"2016-10-22T07:35:47.193Z","0.0.3":"2016-10-22T07:41:51.251Z","0.0.4":"2016-10-23T07:22:06.276Z","0.0.5":"2016-11-05T13:34:01.191Z"},"maintainers":[{"name":"envidia","email":"j8@protonmail.ch"}],"dist-tags":{"latest":"0.0.5"},"description":"Performance Timing Functions for UI Development","readme":"\n<p align=\"center\">\n<img style=\"text-align: center;\" src=\"http://imageshack.com/a/img922/4690/kapZA1.png\">\n</p>\n### Performance Timing Functions for UI Development\n\n# 4d\n\n#### 4d is a set of efficient timing functions. Click below for documentation.\n\n- [cancel](https://github.com/envidia/4d/#cancel)\n- [debounce](https://github.com/julienetie/volve/blob/master/README.md)\n- [interval](https://github.com/julienetie/set-animation-interval/blob/master/README.md)\n- [once](https://github.com/julienetie/run-once/blob/master/README.md)\n- [request](https://github.com/envidia/4d/#request)\n- [requestNative](https://github.com/julienetie/request-frame/blob/master/README.md)\n- [throttle](https://github.com/julienetie/volve/blob/master/README.md)\n- [timeout](https://github.com/julienetie/set-animation-frame)\n- [windowResize](https://github.com/julienetie/resizilla/blob/master/README.md)\n\n## Why?\n- Better performance for modern browsers and mobile devices.\n- Features a comprehensive fix for legacy compatibility issues with RAF.\n- Avoids setTimeout and setInterval unlike the majority of JavaScript timing functions.\n- Prioritise timing for browsers and mobile devices over node.\n- Limit function calls, set FPS, delay and loop to the next frame to be rendered.\n- Features a comprehensive windowResize method that resolves mobile issues.\n- Features a media queries detection API with built in custom events (Coming soon)\n- Ability to mock jittery/ random function calls e.g. emulate bad performance. (coming soon)\n- Less than **2kb gzip size** _(will never exceed a 4kb gzip size)_\n\n\n\n## Aim\n- 4d is a tiny powerhouse, and will remain tiny.\n- 4d aims to improve common timing requirements in a clean, lightweight and modular way.\n- 4d aims to provide a better feature implementations than alternatives.\n\n_(4d === fourth dimension === t)_\n\n## Compatibility\n4d Is at least compatible with IE8 +\n\n\n\n## Support\n- CommonJS ... \n\n`require('4d')`\n\n- AMD ... \n\n`define(['$4d'] , function ($4d) {...`\n\n- ES6 ... \n\n`import {debounce, throttle, timeout } from '4d'`\n\n- IIFE ... \n\n`src=\"4d.js'`\n\n## Demo\n- [Most 4d functions will only work in browser environments, not Node or the Dev Tools console]\n\n[Click here to see the demo]()\n\n# The 4d API\n\n## cancel()\n\n#### _Syntax_:\n`cancel(requestID)`\n\n#### _Parameters_:\n- requestID: The ID value returned by the call to window.requestAnimationFrame() that requested the callback.\n\n#### _In place of_:\n`window.cancelAnimationFrame()`\n\n#### _Summary_:\nThe most comprehensive polyfill for **cancelAnimationFrame**. _cancel()_ avoids mutation of the native object to prevent overriding of cancelAnimationFrame implementations that may be used within other libraries.\n\n_cancel()_ cancels an animation frame request previously scheduled through a call to request() or window.requestAnimationFrame().\n\n\n\n#### _Usage_:\n\n```javascript\nimport { cancel } from '4d'\n\n// id === some requestAnimationFrame ID.\n\ncancel(id)\n```\nSee [more](https://github.com/julienetie/request-frame).  \n\n#### _Browser Support_: \n- Internet Explorer 5+\n- See [more](https://github.com/julienetie/request-frame#browsers-tested--passing)\n\n#### _Core library_:\n[Request Frame](https://github.com/julienetie/request-frame).\n\n_______________\n_______________\n\n## request()\n\n#### _Syntax_:\n`request(callback[DOMHighResTimeStamp])`\n\n#### _Parameters_:\n- callback: A parameter specifying a function to call when it's time to update your animation for the next repaint. The callback has one single argument, a DOMHighResTimeStamp, which indicates the current time (the time returned from Performance.now() ) for when requestAnimationFrame starts to fire callbacks.\n\n#### _In place of_:\n`window.requestAnimationFrame(callback[DOMHighResTimeStamp])`\n\n#### _Summary_:\nThe most comprehensive polyfill for **requestAnimationFrame**. _request()_ avoids mutation of the native object to prevent overriding of requestAnimationFrame implementations that may be used within other libraries.\n\n_request()_ tells the browser that you wish to perform an animation and requests that the browser call a specified function to update an animation before the next repaint. The method takes as an argument a callback to be invoked before the repaint.\n\n#### _Usage_:\n\n```javascript\nimport { request } from '4d'\n\n// Animate.\nconst animate = (highResTimestamp) => {\n  request(animate);\n  // Animate something...\n}\n\n// Start the animation on the next available frame.\nrequest(animate);\n```\n\nSee [more](https://github.com/julienetie/request-frame).  \n\n#### _Browser Support_: \n- Internet Explorer 5+\n- See [more](https://github.com/julienetie/request-frame#browsers-tested--passing)\n\n#### _Core library_:\n[Request Frame](https://github.com/julienetie/request-frame).\n\n_______________\n_______________\n\n[MIT](https://github.com/envidia/4d/blob/master/LICENSE)\n\nCopyright (c) 2016 Julien Etienne\n","versions":{"0.0.3":{"name":"4d","version":"0.0.3","description":"Performance Timing Functions for UI Development","main":"dist/4d.js","jsnext:main":"dist/4d.es.js","scripts":{"bump":"gulp bump","header":"gulp","build":"rollup -c rollup/rollup.config.umd.js && rollup -c rollup/rollup.config.es.js","watch":"rollup -c rollup/rollup.config.umd.js --watch","test":"http-server ./ -p 9999","play":"wzrd  play.js | wtch | garnish"},"repository":{"type":"git","url":"git+https://github.com/envidia/4d.git"},"keywords":["requestAnimationFrame","webkitRequestAnimationFrame","mozRequestAnimationFrame","cancelAnimationFrame","mozCancelAnimationFrame","webkitCancelAnimationFrame","webkitCancelRequestAnimationFrame","setTimeout","setInterval","cancelTimeout","timing functions","requestAnimationFrame polyfill","polyfill","animation timing","animation timestamp"],"author":{"name":"Envidia"},"license":"MIT","bugs":{"url":"https://github.com/envidia/4d/issues"},"homepage":"https://github.com/envidia/request-frame","devDependencies":{"babel-cli":"*","babel-preset-es2015":"*","babel-preset-es2015-rollup":"^1.2.0","browserify":"^13.1.0","chai":"*","gulp":"^3.9.1","gulp-bump":"*","gulp-concat":"*","gulp-es-next":"*","gulp-header":"*","gulp-rename":"*","http-server":"*","js-size":"^2.0.0","requirejs":"*","rollup":"*","rollup-plugin-babel":"*","rollup-plugin-node-resolve":"^2.0.0","rollup-watch":"*"},"dependencies":{"request-frame":"^1.5.3","resizilla":"^0.6.2","run-once":"^1.0.0","set-animation-frame":"^0.1.1","set-animation-interval":"^0.0.2","volve":"^0.0.2"},"gitHead":"0d24817c8237e363442c0c2a3a637e79a5fdabe0","_id":"4d@0.0.3","_shasum":"4732c0de2d7a83b611bedfb3fb51666862529646","_from":".","_npmVersion":"3.10.7","_nodeVersion":"6.4.0","_npmUser":{"name":"envidia","email":"j8@protonmail.ch"},"dist":{"shasum":"4732c0de2d7a83b611bedfb3fb51666862529646","tarball":"https://registry.npmjs.org/4d/-/4d-0.0.3.tgz","integrity":"sha512-rKGbVmWITfv/USptHoGzOtiI75TM5zVwbT9dEHm37GOJburiGtZvmcXVIJXTSFBdJ+RLhRUg9ZNuuO2GgD/Psg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDJ5JVuubgx5hAQB44w8tT1WSDIvsAnfaWCfu7DCrDKXAiAssb4plVhOgSkY/HCpXjoN5Um/HrJ1mYgAvyQzbUzL3Q=="}]},"maintainers":[{"name":"envidia","email":"j8@protonmail.ch"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/4d-0.0.3.tgz_1477122109929_0.8247727307025343"}},"0.0.4":{"name":"4d","version":"0.0.4","description":"Performance Timing Functions for UI Development","main":"dist/4d.js","jsnext:main":"dist/4d.es.js","scripts":{"bump":"gulp bump","header":"gulp","build":"rollup -c rollup/rollup.config.umd.js && rollup -c rollup/rollup.config.es.js","watch":"rollup -c rollup/rollup.config.umd.js --watch","test":"http-server ./ -p 9999","play":"wzrd  play.js | wtch | garnish"},"repository":{"type":"git","url":"git+https://github.com/envidia/4d.git"},"keywords":["requestAnimationFrame","webkitRequestAnimationFrame","mozRequestAnimationFrame","cancelAnimationFrame","mozCancelAnimationFrame","webkitCancelAnimationFrame","webkitCancelRequestAnimationFrame","setTimeout","setInterval","cancelTimeout","timing functions","requestAnimationFrame polyfill","polyfill","animation timing","animation timestamp"],"author":{"name":"Envidia"},"license":"MIT","bugs":{"url":"https://github.com/envidia/4d/issues"},"homepage":"https://github.com/envidia/request-frame","devDependencies":{"babel-cli":"*","babel-preset-es2015":"*","babel-preset-es2015-rollup":"^1.2.0","browserify":"^13.1.0","chai":"*","gulp":"^3.9.1","gulp-bump":"*","gulp-concat":"*","gulp-es-next":"*","gulp-header":"*","gulp-rename":"*","http-server":"*","js-size":"^2.0.0","requirejs":"*","rollup":"*","rollup-plugin-babel":"*","rollup-plugin-node-resolve":"^2.0.0","rollup-watch":"*"},"dependencies":{"request-frame":"^1.5.3","resizilla":"^0.6.2","run-once":"^1.0.0","set-animation-frame":"^0.1.1","set-animation-interval":"^0.0.2","volve":"^0.0.2"},"gitHead":"b2dca8ec0a8c2f7b32b0e98a315e3adff1e998f3","_id":"4d@0.0.4","_shasum":"d60a331b636d0f82176cdcb6cb7ddb9a39a09b70","_from":".","_npmVersion":"3.10.7","_nodeVersion":"6.4.0","_npmUser":{"name":"envidia","email":"j8@protonmail.ch"},"dist":{"shasum":"d60a331b636d0f82176cdcb6cb7ddb9a39a09b70","tarball":"https://registry.npmjs.org/4d/-/4d-0.0.4.tgz","integrity":"sha512-y5Dso1e6nxvrhLdC1ioyADxtaUryNZhZNrtD1QD+Wtw4jz718EJZ2rAcNmBrTvYm/YJz7oSgj4HBDS9Ins2aRw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCbLZVV7iCu6wZlQSFTspANQ6W9KcPoSyhDns2gch47SwIhALBWboUNdW8exS43yA+cyFJhI5wA84d++af7kjuOxQZ3"}]},"maintainers":[{"name":"envidia","email":"j8@protonmail.ch"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/4d-0.0.4.tgz_1477207324593_0.3599366582930088"}},"0.0.5":{"name":"4d","version":"0.0.5","description":"Performance Timing Functions for UI Development","main":"dist/4d.js","jsnext:main":"dist/4d.es.js","scripts":{"bump":"gulp bump","header":"gulp","build":"rollup -c rollup/rollup.config.umd.js && rollup -c rollup/rollup.config.es.js","watch":"rollup -c rollup/rollup.config.umd.js --watch","test":"http-server ./ -p 9999","play":"wzrd  play.js | wtch | garnish"},"repository":{"type":"git","url":"git+https://github.com/envidia/4d.git"},"keywords":["requestAnimationFrame","webkitRequestAnimationFrame","mozRequestAnimationFrame","cancelAnimationFrame","mozCancelAnimationFrame","webkitCancelAnimationFrame","webkitCancelRequestAnimationFrame","setTimeout","setInterval","cancelTimeout","timing functions","requestAnimationFrame polyfill","polyfill","animation timing","animation timestamp"],"author":{"name":"Envidia"},"license":"MIT","bugs":{"url":"https://github.com/envidia/4d/issues"},"homepage":"https://github.com/envidia/request-frame","devDependencies":{"babel-cli":"*","babel-preset-es2015":"*","babel-preset-es2015-rollup":"^1.2.0","browserify":"^13.1.0","chai":"*","http-server":"*","rollup":"*","rollup-plugin-babel":"*","rollup-plugin-node-resolve":"^2.0.0","rollup-watch":"*"},"dependencies":{"request-frame":"^*","resizilla":"^*","run-once":"^*","set-animation-frame":"^*","set-animation-interval":"^*","volve":"^*"},"gitHead":"a5b2888a827547ec8f90fc95af4ce1b53c17cf56","_id":"4d@0.0.5","_shasum":"9db2e652f5a361ac29592df462e10a5c87689284","_from":".","_npmVersion":"3.10.7","_nodeVersion":"6.4.0","_npmUser":{"name":"envidia","email":"j8@protonmail.ch"},"dist":{"shasum":"9db2e652f5a361ac29592df462e10a5c87689284","tarball":"https://registry.npmjs.org/4d/-/4d-0.0.5.tgz","integrity":"sha512-y/sL9pt7AXN7gV6hgSYzkH4IF5X7Zfwumf3d3ywILX8p2vyR9MI1xMOIp/7L5tHbeN2sVUC5ywTaokUpaemEqA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCX3J+Ln1sSnGdrShkBFX99pMjanxuTIroOgczZqNZOIgIhAKhGaqksn30ygYCdy2GegVNMxm4kcVknF01svAPMDoqP"}]},"maintainers":[{"name":"envidia","email":"j8@protonmail.ch"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/4d-0.0.5.tgz_1478352840669_0.9979224628768861"}}},"homepage":"https://github.com/envidia/request-frame","keywords":["requestAnimationFrame","webkitRequestAnimationFrame","mozRequestAnimationFrame","cancelAnimationFrame","mozCancelAnimationFrame","webkitCancelAnimationFrame","webkitCancelRequestAnimationFrame","setTimeout","setInterval","cancelTimeout","timing functions","requestAnimationFrame polyfill","polyfill","animation timing","animation timestamp"],"repository":{"type":"git","url":"git+https://github.com/envidia/4d.git"},"author":{"name":"Envidia"},"bugs":{"url":"https://github.com/envidia/4d/issues"},"license":"MIT","readmeFilename":"README.md"}