random-fruits-name

Generate the names of random fruits.

Usage no npm install needed!

<script type="module">
  import randomFruitsName from 'https://cdn.skypack.dev/random-fruits-name';
</script>

README

Random Fruits name

Random Fruits name logo

Build Status

Generate the names of random fruits.

The name of fruits refers to this page. Wikijunior:Fruit Alphabet/Complete

Install

npm install random-fruits-name
# or
yarn 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 */}
    </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

Languages Supported

Languages Code Lang
English en
Spanish es
Japanese ja
Portuguese pt
Dutch nl
French fr
German de
Czech cs

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.

Licence

MIT

Author

Yuki Shindo