javascript - Understanding Nodejs documentation -
i on thinking, having trouble digesting nodejs documentation. new javascript , come java background.
my question not specific nodejs function overall understanding. below give example of trying understand...
when working statically typed language java clear types needed method calls. trivial example, if want sort array of int's can @ arrays.sort , see takes int[] (same other types well). can see returns void.
public static void sort(int[] a)
however javascript dynamic language there no types api calls. take example in crypto module
crypto.pbkdf2(password, salt, iterations, keylen, callback) asynchronous pbkdf2 applies pseudorandom function hmac-sha1 derive key of given length given password, salt , iterations. callback gets 2 arguments (err, derivedkey).
so without going out , finding example code, or looking @ nodejs source how know argument types of function? realized possible derive types looking @ name (ie callback function type) there other way?
for example documentation says callback gets 2 arguments err , derivedkey. type of derivedkey, type or err? missing documentation? how know if passing in right types?
note: know type of derivedkey , err don't need answers "derivedkey ...." question overall understanding of nodejs documentation coming statically typed language , not specific crypto.pdkdf2.
well pretty on thinking. you'll have guess of them if it's not explained explicitly. can guess iterations , keylen numbers rather strings. nodejs docs explain parameters explicitly when think can't guess, or have know additional it. in crypto.createcredentials(details)
explain details dictionary , keys need use. f.i. in case of err , derivedkey, since there no explicit info, have assumed both strings. if turns out not, console.log them in callback function see are.
documentation lot more clear if have written down types of parameters don't know if it's worth effort.
Comments
Post a Comment