mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-28 05:58:38 +02:00
feat(utils): JSDoc for all APIs (#6980)
* feat(utils): JSDoc for all APIs * fix tests
This commit is contained in:
parent
b8d2a4e84d
commit
2eeb0e46a2
31 changed files with 637 additions and 255 deletions
|
@ -9,20 +9,21 @@ import {createHash} from 'crypto';
|
|||
import _ from 'lodash';
|
||||
import {shortName, isNameTooLong} from './pathUtils';
|
||||
|
||||
/** Thin wrapper around `crypto.createHash("md5")`. */
|
||||
export function md5Hash(str: string): string {
|
||||
return createHash('md5').update(str).digest('hex');
|
||||
}
|
||||
|
||||
/** Creates an MD5 hash and truncates it to the given length. */
|
||||
export function simpleHash(str: string, length: number): string {
|
||||
return md5Hash(str).substr(0, length);
|
||||
return md5Hash(str).substring(0, length);
|
||||
}
|
||||
|
||||
// Based on https://github.com/gatsbyjs/gatsby/pull/21518/files
|
||||
/**
|
||||
* Given an input string, convert to kebab-case and append a hash.
|
||||
* Avoid str collision.
|
||||
* Also removes part of the string if its larger than the allowed
|
||||
* filename per OS. Avoids ERRNAMETOOLONG error.
|
||||
* Given an input string, convert to kebab-case and append a hash, avoiding name
|
||||
* collision. Also removes part of the string if its larger than the allowed
|
||||
* filename per OS, avoiding `ERRNAMETOOLONG` error.
|
||||
*/
|
||||
export function docuHash(str: string): string {
|
||||
if (str === '/') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue