Skip to content

Commit

Permalink
Move module docs to .d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Feb 22, 2025
1 parent a0a1c85 commit d4fb377
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
12 changes: 12 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/**
* A tiny, secure, URL-friendly, unique string ID generator for JavaScript
* with hardware random generator.
*
* ```js
* import { nanoid } from 'nanoid'
* model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
* ```
*
* @module
*/

/**
* Generate secure URL-friendly unique ID.
*
Expand Down
12 changes: 0 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
/**
* A tiny, secure, URL-friendly, unique string ID generator for JavaScript
* with hardware random generator.
*
* ```js
* import { nanoid } from 'nanoid'
* model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
* ```
*
* @module
*/

import { webcrypto as crypto } from 'node:crypto'

import { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'
Expand Down
13 changes: 13 additions & 0 deletions non-secure/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
* By default, Nano ID uses hardware random bytes generation for security
* and low collision probability. If you are not so concerned with security,
* you can use it for environments without hardware random generators.
*
* ```js
* import { nanoid } from 'nanoid/non-secure'
* const id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqLJ"
* ```
*
* @module
*/

/**
* Generate URL-friendly unique ID. This method uses the non-secure
* predictable random generator with bigger collision probability.
Expand Down
13 changes: 0 additions & 13 deletions non-secure/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
/* @ts-self-types="./index.d.ts" */

/**
* By default, Nano ID uses hardware random bytes generation for security
* and low collision probability. If you are not so concerned with security,
* you can use it for environments without hardware random generators.
*
* ```js
* import { nanoid } from 'nanoid/non-secure'
* const id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqLJ"
* ```
*
* @module
*/

// This alphabet uses `A-Za-z0-9_-` symbols.
// The order of characters is optimized for better gzip and brotli compression.
// References to the same file (works both for gzip and brotli):
Expand Down

0 comments on commit d4fb377

Please sign in to comment.