1- # last-callback v1.0.0
1+ # last-callback v1.0.1
22
33## Description
44
5- Easly get last argument and call if it is a function.
6- You do not need to check last argument manually any more.
5+ Get and call last given argument if is a function. You do not need to check last argument manually any more.
6+ All you need to do is to pass arguments array to this little module, then call it, or bind with ` this ` context.
7+ Last-callback always return a function with build in validation. Last not callable argument will be omitted without throwing any exception.
78
8- All you need to do is to pass arguments array to this little module,
9- then call it, or bind with ` this ` context.
9+ last-callback is compatybile with ES5 and latest.
1010
11- It is compatybile with ES5 and above.
11+ [ ![ npm] ( https://img.shields.io/npm/l/last-callback.svg?maxAge=2592000 )] ( )
12+ [ ![ npm] ( https://img.shields.io/npm/dt/last-callback.svg?maxAge=2592000 )] ( )
13+ [ ![ node] ( https://img.shields.io/node/v/last-callback.svg?maxAge=2592000 )] ( )
14+ [ ![ Maintenance] ( https://img.shields.io/maintenance/yes/2016.svg?maxAge=2592000 )] ( )
15+ [ ![ coverage] ( https://img.shields.io/badge/coverage-100%25-brightgreen.svg )] ( )
1216
1317## Requirements
1418
@@ -28,7 +32,7 @@ last-callback respects: bind, call, and apply methods;
2832
2933### ES6 Style
3034
31- If you are using NodeJS >= 6.2 You should definitly use ES6 style with spread operators.
35+ If you are using ` NodeJS >= 6.2 ` You should definitly use __ ES6 style __ with spread operators.
3236
3337``` javascript
3438const lastCallback = require (' last-callback' );
@@ -46,7 +50,7 @@ myFunc('test value', function (param) {
4650
4751### ES5 Style
4852
49- If you are still using NodeJS < 6.2, i.e. NodeJS 4.4.7 LTS, you can use ES5 style .
53+ If you are still using ` NodeJS < 6.2.0 ` , i.e. ` NodeJS 4.4.7 LTS ` , you can use __ ES5 style __ .
5054
5155
5256``` javascript
@@ -69,11 +73,11 @@ myFunc('test value', function (param) {
6973var lastCallback = require (' last-callback' );
7074
7175function myFunc (param1 ) {
72- var callback = lastCallback .apply (null , arguments ); // no need to bind context here
76+ var callback = lastCallback .apply (null , arguments );
7377
7478 this .contextVariable = ' this is my context' ;
7579
76- callback .call (this , param1); // this is the place where you should bind context
80+ callback .call (this , param1); // bind context if you need it
7781}
7882
7983myFunc (' test value' , function (param ) {
9397 iterator = 1 ,
9498 limit = 5 ;
9599
96- function myFunc (number ) {
100+ function myFunc (iterator ) {
97101 let callback = lastCallback (... arguments );
98102
99- callback (number );
103+ callback (iterator );
100104}
101105
102- function recursiveCallabck (number ) {
103- if (number === limit) {
106+ function recursiveCallabck (iterator ) {
107+ if (iterator === limit) {
104108 return ;
105109 }
106110
107- console .log (number );
111+ console .log (iterator );
108112
109- number += 1 ;
110- recursiveCallabck (number );
113+ iterator += 1 ;
114+ recursiveCallabck (iterator );
111115}
112116
113- myFunc (number , recursiveCallabck);
117+ myFunc (iterator , recursiveCallabck);
114118// console log:
115119// 1
116120// 2
0 commit comments