File tree 5 files changed +41
-8
lines changed
5 files changed +41
-8
lines changed Original file line number Diff line number Diff line change 1
1
# ide
2
2
.komodotools
3
+ .vscode
3
4
* .komodoproject
4
5
5
6
.gitignore
Original file line number Diff line number Diff line change @@ -254,6 +254,8 @@ var _src_deco_debounce;
254
254
var module = { exports : exports } ;
255
255
"use strict" ;
256
256
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
257
+ var requestFn = typeof requestAnimationFrame === 'undefined' ? setImmediate : requestAnimationFrame ;
258
+ var clearRequest = typeof requestAnimationFrame === 'undefined' ? clearImmediate : cancelAnimationFrame ;
257
259
/**
258
260
*
259
261
* @param timeout ms to wait before calling inner fn
@@ -277,9 +279,9 @@ function deco_debounce(timeout) {
277
279
}
278
280
var self = this ;
279
281
if ( frame_1 !== 0 ) {
280
- cancelAnimationFrame ( frame_1 ) ;
282
+ clearRequest ( frame_1 ) ;
281
283
}
282
- frame_1 = requestAnimationFrame ( function ( ) {
284
+ frame_1 = requestFn ( function ( ) {
283
285
frame_1 = 0 ;
284
286
fn . apply ( self , args ) ;
285
287
} ) ;
Original file line number Diff line number Diff line change 5
5
"name" : " Alexander Kit" ,
6
6
"email" : " alex.kit@atmajs.com"
7
7
},
8
- "version" : " 0.2.68 " ,
8
+ "version" : " 0.2.69 " ,
9
9
"main" : " ./lib/memd.js" ,
10
10
"types" : " ./lib/memd.d.ts" ,
11
11
"repository" : {
Original file line number Diff line number Diff line change 3
3
4
4
[ ![ Build Status] ( https://travis-ci.org/atmajs/Ruta.png?branch=master )] ( https://travis-ci.org/tenbits/memd )
5
5
[ ![ NPM version] ( https://badge.fury.io/js/memd.svg )] ( http://badge.fury.io/js/memd )
6
- [ ![ Bower version] ( https://badge.fury.io/bo/memd.svg )] ( http://badge.fury.io/bo/memd )
7
6
8
-
9
- Object Cache. Memoize, debounce, throttle and queue methods.
7
+ * Memoize, debounce, throttle and queue methods
8
+ * Object Cache
10
9
11
10
``` typescript
12
11
@@ -52,5 +51,34 @@ const cache = new Cache(<ICacheOpts> { maxAge: 60 });
52
51
53
52
```
54
53
54
+ ### ` memoize `
55
+
56
+ ``` ts
57
+ .memoize (opts ?: ICacheOpts )
58
+ ```
59
+
60
+ ### ` debounce `
61
+
62
+ When ` ms ` is ` 0 ` or ` undefined ` then ` requestAnimationFrame ` or ` setImmediate ` is used.
63
+
64
+ ``` ts
65
+ .memoize (ms : number = 0 )
66
+ ```
67
+
68
+ ### ` throttle `
69
+
70
+ ``` ts
71
+ .throttle (ms : number , shouldCallLater ?: boolean )
72
+ ```
73
+
74
+ ### ` queued `
75
+
76
+ Calls method only when the previous promise is resolved. Use ` trimQueue: true ` to ensure the queue consists of max 1 listener.
77
+
78
+ ``` ts
79
+ async .queued (opts : { trimQueue?: boolean })
80
+ ```
81
+
55
82
----
56
83
_ Atma.js Project_
84
+
Original file line number Diff line number Diff line change
1
+ const requestFn : any = typeof requestAnimationFrame === 'undefined' ? setImmediate : requestAnimationFrame ;
2
+ const clearRequest : any = typeof requestAnimationFrame === 'undefined' ? clearImmediate : cancelAnimationFrame ;
1
3
/**
2
4
*
3
5
* @param timeout ms to wait before calling inner fn
@@ -17,9 +19,9 @@ export function deco_debounce (timeout?: number) {
17
19
descriptor . value = function ( ...args ) {
18
20
const self = this ;
19
21
if ( frame !== 0 ) {
20
- cancelAnimationFrame ( frame ) ;
22
+ clearRequest ( frame ) ;
21
23
}
22
- frame = requestAnimationFrame ( function ( ) {
24
+ frame = requestFn ( function ( ) {
23
25
frame = 0 ;
24
26
fn . apply ( self , args ) ;
25
27
} ) ;
You can’t perform that action at this time.
0 commit comments