mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 20:21:46 +00:00
add comments & tests
This commit is contained in:
@@ -6,6 +6,8 @@ import randomBrowser = require('nanoid/random-browser');
|
||||
import url = require('nanoid/url');
|
||||
import nanoidAsync = require('nanoid/async');
|
||||
import nanoidAsyncBrowser = require('nanoid/async-browser');
|
||||
import nanoidNonSecure = require('nanoid/non-secure');
|
||||
import generateNonSecure = require('nanoid/non-secure/generate');
|
||||
|
||||
const _random = (size: number) => [1, 2, 3, 4];
|
||||
|
||||
@@ -22,5 +24,9 @@ nanoidAsync(null, (error, id) => {
|
||||
});
|
||||
nanoidAsyncBrowser().then((id) => console.log(id));
|
||||
nanoidAsyncBrowser(10).then((id) => console.log(id));
|
||||
nanoidNonSecure();
|
||||
nanoidNonSecure(10);
|
||||
generateNonSecure('0123456789абвгдеё', 5);
|
||||
generateNonSecure('0123456789абвгдеё');
|
||||
|
||||
console.log(url);
|
||||
|
||||
+16
@@ -1,3 +1,19 @@
|
||||
/**
|
||||
* Generate URL-friendly unique ID. This method use non-secure predictable
|
||||
* random generator.
|
||||
*
|
||||
* By default, ID will have 21 symbols to have a collision probability similar
|
||||
* to UUID v4.
|
||||
*
|
||||
* @param alphabet Symbols to be used in ID.
|
||||
* @param [size=21] The number of symbols in ID.
|
||||
*
|
||||
* @return Random string.
|
||||
*
|
||||
* @example
|
||||
* const nanoid = require('nanoid/non-secure')
|
||||
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
|
||||
*/
|
||||
declare function generate(alphabet: string, size?: number): string;
|
||||
|
||||
export = generate;
|
||||
|
||||
Vendored
+15
@@ -1,3 +1,18 @@
|
||||
/**
|
||||
* Generate URL-friendly unique ID. This method use non-secure predictable
|
||||
* random generator.
|
||||
*
|
||||
* By default, ID will have 21 symbols to have a collision probability similar
|
||||
* to UUID v4.
|
||||
*
|
||||
* @param [size=21] The number of symbols in ID.
|
||||
*
|
||||
* @return Random string.
|
||||
*
|
||||
* @example
|
||||
* const nanoid = require('nanoid/non-secure')
|
||||
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
|
||||
*/
|
||||
declare function nanoid(size?: number): string;
|
||||
|
||||
export = nanoid;
|
||||
|
||||
Reference in New Issue
Block a user