@antv/data-wizard
Version:
A js/ts library for data processing
186 lines (185 loc) • 4.38 kB
TypeScript
import { TextDB } from './database';
import { BasicRandom, Interval } from './basic-random';
/**
* Generator for string
* @public
*/
export declare class TextRandom extends BasicRandom {
database: TextDB;
/**
* Return a random char
*
* @param options -
*/
character(options?: CharacterOptions): string;
/**
* Return a random string
*
* @param options - the params
*
* @public
*/
string(options?: StringOptions): string;
/**
* Return a random syllable
* @param options - the params
* @internal
*/
syllable(options?: SyllableOptions): string;
/**
* return a random word
* @param options - the params
*/
word(options?: WordOptions): string;
/**
* return a random sentence
* @param options - the params
*/
sentence(options?: SentenceOptions): string;
/**
* return a random paragraph
* @param options - the params
*/
paragraph(options?: ParagraphOptions): string;
/**
* return a random english name
*
* @param options - the params
*/
name(options?: Person): string;
/**
* return a random english surname
*/
surname(): string;
/**
* return a random english given name
* @param options - the params
*/
givenName(options?: Person): string;
/**
* return a random phone number
* @param options - the params
*/
phone(options?: PhoneOptions): string;
/**
* return a random Chinese character
*/
cCharacter(options?: CCharacterOptions): string;
/**
* return a random Chinese word
* @param options - the params
*/
cWord(options?: CWordOption): string;
/**
* return a random Chinese sentence
* @param options - the params
*/
cSentence(options?: Interval): string;
/**
* return a random Chinese paragraph
* @param options - the params
*/
cParagraph(options?: Interval): string;
/**
* return a random Chinese name
* @param options - the params
*/
cName(options?: Person): string;
/**
* return a random Chinese surname
* @param options - the params
*/
cSurname(): string;
/**
* return a random Chinese given name
*/
cGivenName(options?: CFirstNameOptions): string;
/**
* return a random Chinese zodiac
* @param options - the params
*
* @example
* ```javascript
* const R = new TextRandom();
* const cZodiacCn = R.cZodiac(); // '鼠', '牛', '虎'...
* const cZodiacEn = R.cZodiac({ locale: 'en-US' }); // 'Rat','OX','Tiger'...
* ```
*/
cZodiac(options?: CZodiacOptions): string;
}
/**
* @public
*/
export interface CharacterOptions {
pool?: string;
numeric?: boolean;
symbols?: boolean;
lower?: boolean;
upper?: boolean;
}
/**
* @public
*/
export interface StringOptions extends CharacterOptions {
length?: number;
}
/**
* @public
*/
export interface SyllableOptions {
capitalize?: boolean;
length?: number;
}
/**
* @public
*/
export interface WordOptions {
syllables?: number;
/** capitalize first letter */
capitalize?: boolean;
/** the length of word */
length?: number;
}
/** @public */
export interface SentenceOptions {
/** the counts of word */
words?: number;
punctuation?: boolean | string;
}
/** @public */
export interface ParagraphOptions {
/** the counts of sentence in the paragraph */
sentence?: number;
}
/** @public */
export interface Person {
/** 性别 */
gender?: 'male' | 'female';
}
/** @public */
export interface CFirstNameOptions extends Person {
length?: number;
}
/** @public */
export interface CCharacterOptions {
pool?: string;
}
/** @public */
export interface CWordOption extends CCharacterOptions {
length?: number;
}
/** @public */
export interface PhoneOptions {
/** true: mobile numbers; false: landline numbers */
mobile?: boolean;
/** true: add '-' to format phone numbers */
formatted?: boolean;
/** true: add '*' to avoid generating real phone numbers */
asterisk?: boolean;
/** only the first three digits can be specified, otherwise it is invalid */
startNum?: string;
}
/** @public */
export interface CZodiacOptions {
locale?: 'en-US' | 'zh-CN';
}