Added support for minor version parameters in bcrypt 2.0 (#25182)

* Updated for bcrypt 2.0

* Added missing @param declaration for minor
This commit is contained in:
dstapleton92 2018-04-28 01:26:44 -05:00 committed by Wesley Wigham
parent 1462bc999b
commit ab7694a033
2 changed files with 26 additions and 5 deletions

View File

@ -8,15 +8,24 @@ let error: Error;
str = bcrypt.genSaltSync();
str = bcrypt.genSaltSync(num);
str = bcrypt.genSaltSync(num, str);
bcrypt.genSalt(num, (err: Error, salt: string): void => { error = err; str = salt; })
.then(salt => str = salt)
.catch(err => error = err);
bcrypt.genSalt(num, str, (err: Error, salt: string): void => { error = err; str = salt; })
.then(salt => str = salt)
.catch(err => error = err);
bcrypt.genSalt(num)
.then(salt => str = salt)
.catch(err => error = err);
bcrypt.genSalt(num, str)
.then(salt => str = salt)
.catch(err => error = err);
bcrypt.genSalt((err: Error, salt: string): void => { error = err; str = salt; })
.then(salt => str = salt)
.catch(err => error = err);

View File

@ -1,20 +1,32 @@
// Type definitions for bcrypt 1.0
// Type definitions for bcrypt 2.0
// Project: https://www.npmjs.org/package/bcrypt
// Definitions by: Peter Harris <https://github.com/codeanimal>, Ayman Nedjmeddine <https://github.com/IOAyman>
// Definitions by: Peter Harris <https://github.com/codeanimal>
// Ayman Nedjmeddine <https://github.com/IOAyman>
// David Stapleton <https://github.com/dstapleton92>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* @param rounds The cost of processing the data. Default 10.
* @param rounds The cost of processing the data. Default 10.
* @param minor The minor version of bcrypt to use. Either 'a' or 'b'. Default 'b'.
*/
export declare function genSaltSync(rounds?: number): string;
export declare function genSaltSync(rounds?: number, minor?: string): string;
/**
* @param rounds The cost of processing the data. Default 10.
* @param callback A callback to be fire once the sald has been generated. Uses eio making it asynchronous.
* @return A promise to be either resolved with the generated salt or rejected with an Error
*/
export declare function genSalt(rounds: number, callback?: (err: Error, salt: string) => void): Promise<string>;
export declare function genSalt(rounds?: number, callback?: (err: Error, salt: string) => void): Promise<string>;
/**
* @param rounds The cost of processing the data. Default 10.
* @param minor The minor version of bcrypt to use. Either 'a' or 'b'. Default 'b'.
* @param callback A callback to be fire once the sald has been generated. Uses eio making it asynchronous.
* @return A promise to be either resolved with the generated salt or rejected with an Error
*/
export declare function genSalt(rounds?: number, minor?: string, callback?: (err: Error, salt: string) => void): Promise<string>;
/**
* @param callback A callback to be fire once the sald has been generated. Uses eio making it asynchronous.
* @return A promise to be either resolved with the generated salt or rejected with an Error