random-fruits-name
v1.10.1
Published
Generate the names of random fruits.
Downloads
1,045
Maintainers
Readme
Random Fruits name
Generate the names of random fruits.
The name of fruits refers to this page. Wikijunior:Fruit Alphabet/Complete
Install
# npm
npm install random-fruits-name
# yarn
yarn add random-fruits-name
# pnpm
pnpm add random-fruits-name
Usage
React
import React from 'react'
import getRandomFruitsName from 'random-fruits-name'
function App() {
return (
<div>
<p>{getRandomFruitsName()}</p> {/* Apple - English is default language */}
<p>{getRandomFruitsName('en')}</p> {/* Apple */}
<p>{getRandomFruitsName('es')}</p> {/* Manzana */}
<p>{getRandomFruitsName('ja')}</p> {/* りんご */}
<p>{getRandomFruitsName('pt')}</p> {/* Maça */}
<p>{getRandomFruitsName('nl')}</p> {/* Appel */}
<p>{getRandomFruitsName('fr')}</p> {/* Pomme */}
<p>{getRandomFruitsName('de')}</p> {/* Apfel */}
<p>{getRandomFruitsName('cs')}</p> {/* Jablko */}
<p>{getRandomFruitsName('bn')}</p> {/* আপেল */}
</div>
)
}
export default App
Node.js
const getRandomFruitsName = require('random-fruits-name')
console.log(getRandomFruitsName()) // Apple - English is default language
console.log(getRandomFruitsName('en')) // Apple
console.log(getRandomFruitsName('es')) // Manzana
console.log(getRandomFruitsName('ja')) // りんご
console.log(getRandomFruitsName('pt')) // Maça
console.log(getRandomFruitsName('nl')) // Appel
console.log(getRandomFruitsName('fr')) // Pomme
console.log(getRandomFruitsName('de')) // Apfel
console.log(getRandomFruitsName('cs')) // Jablko
console.log(getRandomFruitsName('bn')) // আপেল
Deno
import getRandomFruitsName from "https://esm.sh/random-fruits-name";
console.log(getRandomFruitsName()); // Apple - English is default language
console.log(getRandomFruitsName("en")); // Apple
console.log(getRandomFruitsName("es")); // Manzana
console.log(getRandomFruitsName("ja")); // りんご
console.log(getRandomFruitsName("pt")); // Maça
console.log(getRandomFruitsName("nl")); // Appel
console.log(getRandomFruitsName("fr")); // Pomme
console.log(getRandomFruitsName("de")); // Apfel
console.log(getRandomFruitsName("cs")); // Jablko
console.log(getRandomFruitsName("bn")); // আপেল
Bun
# install
bun add random-fruits-name
import getRandomFruitsName from "random-fruits-name";
console.log(getRandomFruitsName()); // Apple - English is default language
console.log(getRandomFruitsName("en")); // Apple
console.log(getRandomFruitsName("es")); // Manzana
console.log(getRandomFruitsName("ja")); // りんご
console.log(getRandomFruitsName("pt")); // Maça
console.log(getRandomFruitsName("nl")); // Appel
console.log(getRandomFruitsName("fr")); // Pomme
console.log(getRandomFruitsName("de")); // Apfel
console.log(getRandomFruitsName("cs")); // Jablko
console.log(getRandomFruitsName("bn")); // আপেল
Languages Supported
| Languages | Code Lang | | ---------- | --------- | | English | en | | Spanish | es | | Japanese | ja | | Portuguese | pt | | Dutch | nl | | French | fr | | German | de | | Czech | cs | | Bengali | bn |
we are using ISO-639-1 codes as code for differents languages
you can make a Pull Request and add the language you want
Option
It is possible to specify opttion as the second argument.
Note that in this case, the language must be specified as the first argument.
getRandomFruitsName(lang, option)
Currently, there is an option called maxWords
.
getRandomFruitsName('en', { maxWords: 1 })
Which will ensure it will only return one word fruit name.
Development
Please check out the How to Contribute.
Test
npm run test
Code format
npm run fmt
Contributors
Thanks to all contributors!
Made with contributors-img.