README.md (1570B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2020 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # nextTick 22 23 > Add a callback to the "next tick queue". 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var nextTick = require( '@stdlib/utils/next-tick' ); 31 ``` 32 33 #### nextTick( clbk\[, ...args] ) 34 35 Adds a callback to the "next tick queue". 36 37 ```javascript 38 function beep() { 39 console.log( 'boop' ); 40 } 41 42 nextTick( beep ); 43 ``` 44 45 </section> 46 47 <!-- /.usage --> 48 49 <section class="notes"> 50 51 ## Notes 52 53 - The queue is fully drained after the current operation on the JavaScript stack runs to completion and before the event loop is allowed to continue. 54 - Creating an infinite loop is possible if `nextTick` is called recursively. 55 56 </section> 57 58 <section class="examples"> 59 60 ## Examples 61 62 <!-- eslint no-undef: "error" --> 63 64 ```javascript 65 var nextTick = require( '@stdlib/utils/next-tick' ); 66 67 function beep( x, y, z ) { 68 console.log( 'boop: %d %d %d', x, y, z ); 69 } 70 71 nextTick( beep, 1, 2, 3 ); 72 ``` 73 74 </section> 75 76 <!-- /.examples --> 77 78 <section class="links"> 79 80 </section> 81 82 <!-- /.links -->