Comparing version 2.0.1 to 2.0.2
{ | ||
"name": "raf-schd", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "A simple scheduler based on requestAnimationFrame", | ||
"main": "lib/index.js", | ||
"files": [ | ||
"lib" | ||
], | ||
"scripts": { | ||
@@ -15,11 +18,12 @@ "build": "babel src -d lib", | ||
"devDependencies": { | ||
"babel-cli": "6.24.1", | ||
"babel-eslint": "7.2.3", | ||
"babel-cli": "6.26.0", | ||
"babel-eslint": "8.0.2", | ||
"babel-jest": "^21.2.0", | ||
"babel-preset-es2015": "6.24.1", | ||
"babel-preset-flow": "6.23.0", | ||
"eslint": "4.2.0", | ||
"eslint-plugin-jest": "20.0.3", | ||
"flow-bin": "0.49.1", | ||
"jest": "20.0.4", | ||
"prettier": "1.5.2", | ||
"eslint": "4.10.0", | ||
"eslint-plugin-jest": "21.2.0", | ||
"flow-bin": "0.58.0", | ||
"jest": "21.2.1", | ||
"prettier": "1.8.1", | ||
"raf-stub": "2.0.1" | ||
@@ -26,0 +30,0 @@ }, |
@@ -10,3 +10,3 @@ # raf-schd | ||
```js | ||
import rafScheduler from 'raf-schd'; | ||
import rafSchedule from 'raf-schd'; | ||
@@ -18,3 +18,3 @@ const expensiveFn = (arg) => { | ||
const schedule = rafScheduler(expensiveFn); | ||
const schedule = rafSchedule(expensiveFn); | ||
@@ -61,3 +61,3 @@ schedule('foo'); | ||
```js | ||
import rafScheduler from 'raf-schd'; | ||
import rafSchedule from 'raf-schd'; | ||
@@ -68,3 +68,3 @@ function doSomething(scroll_pos) { | ||
const scheduled = rafSchedule(doSomething); | ||
const schedule = rafSchedule(doSomething); | ||
@@ -81,3 +81,3 @@ window.addEventListener('scroll', function() { | ||
```js | ||
type rafScheduler = (fn: Function) => ResultFn | ||
type rafSchedule = (fn: Function) => ResultFn | ||
@@ -94,7 +94,7 @@ type ResultFn = (...arg: any[]) => number; | ||
```js | ||
import rafScheduler from 'raf-schd'; | ||
import rafSchedule from 'raf-schd'; | ||
const doSomething = () => {...}; | ||
const schedule = rafScheduler(doSomething); | ||
const schedule = rafSchedule(doSomething); | ||
@@ -123,2 +123,20 @@ schedule(1, 2); | ||
## Is this a `throttle`, `debounce` or something else? | ||
`raf-schd` is closer to `throttle` than it is `debounce`. It is not like `debounce` because it does not wait for a period of quiet before firing the function. | ||
Lets take a look at the characteristics of this library: | ||
**Similiarities to `throttle`** | ||
- It batches multiple calls into a single event | ||
- It only executes the wrapped function with the latest argument | ||
- It will not execute anything if the function is not invoked | ||
- One invokation of a scheduled function always results in at least one function call, unless canceled. This is `throttle` with tail calls enabled. | ||
**Differences to `throttle`** | ||
- Rather than throttling based on time (such as `200ms`, this library throttles based on `requestAnimationFrame`. This allows the browser to control how many frames to provide per second to optimise rendering. | ||
- Individual frames of `raf-schd` can be canceled using `cancelAnimationFrame` as it returns the frame id. | ||
## Testing your code | ||
@@ -143,3 +161,3 @@ | ||
```js | ||
import rafScheduler from 'raf-schd'; | ||
import rafSchedule from 'raf-schd'; | ||
``` | ||
@@ -152,6 +170,3 @@ | ||
```js | ||
const rafScheduler = require('raf-schd').default; | ||
const rafSchedule = require('raf-schd').default; | ||
``` | ||
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
164
6232
11
3
23
1