Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cirolee/lorem-en
lorem text for english, compatible with browser and nodejs
https://github.com/cirolee/lorem-en
Last synced: 23 days ago
JSON representation
lorem text for english, compatible with browser and nodejs
- Host: GitHub
- URL: https://github.com/cirolee/lorem-en
- Owner: CiroLee
- Created: 2022-04-16T15:45:59.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-14T14:45:51.000Z (over 2 years ago)
- Last Synced: 2024-04-26T19:22:50.124Z (9 months ago)
- Language: TypeScript
- Size: 72.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lorem-en
lorem-en maybe the tiniest Javascript module to generate lorem English text. It's written by Typescript, compatible with browser and nodejs.
## Install
```shell
npm install lorem-en
```## Use
```typescript
// ESM
import LoremEn from 'lorem-en';
// CommonJS
const LoremEn = require('lorem-en');
``````typescript
const loremEn = new LoremEn();// e.g. return a random word
loremEn.word();
```## Params
```typescript
const loremEn = new LoremEn({
random: 10,
});// index.d.ts
interface ILoremEnConfig {
random: number; // base random number, default is 10
}
```## API
| Name | Description |
| -------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| letter(): string | Return a random letter |
| word(range?: number \| [IRange](./src/types.ts)): string | [range: Optional] Return a random word. When range is number, the word consists of range letters; range is a range array ([min, max]), and the number of words is randomly between [min, max]. When no parameter is passed, the number of words will be randomly determined based on the global parameter random |
| sentence(range?: number \| [IRange](./src/types.ts)) ) | [range: Optional] returns a random sentence. When range is number, the sentence consists of range words; range is a range array ([min, max]), and the number of words is randomly between [min, max]. When no parameters are passed, the number will be randomly determined based on the global parameter random |
| paragraph(range: number \| [IRange](./src/types.ts) ) | [range: Optional] Returns a random paragraph. When range is number, the paragraph consists of range sentences; range is a range array ([min, max]), and the number of sentences is randomly between [min, max]. When no parameters are passed, the number will be randomly determined based on the global parameter random |
| num(range: [IRange](./src/types.ts)): number | Returns a random number between [min,max], inclusive of min and max. Note: min and max can be any number (except Infinity and -Infinity), the absolute value of min and max will be compared during calculation, so the position of min and max is not important |
| randomArrayItem(arr: T[]): T | Randomly returns an element in an array |
| name(params: [INames](./src/types.ts)): string | Randomly returns common English names |