diff --git a/README.md b/README.md index a195fff..c9ea28c 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,13 @@ npm i @paunovic/random-words ```js import { initialize } from '@paunovic/random-words' -// Default language pack +// Initialization with default language pack +const RANDOM = initialize(); + +// Initialization with different language pack const RANDOM = initialize({ countryCode: 'rs' }) -// With variation +// Initialization with different language pack, including variation const RANDOM = initialize({ countryCode: 'rs', variation: 'cyrillic' }) ``` @@ -31,9 +34,11 @@ Currently available country codes and variations: | Country | Country code | Variation | | :------------ | :----------: | :--------: | | Serbia | `rs` | `cyrillic` | -| United States | `us` | | +| United States `*` | `us` | | | Spain | `es` | | +`*` Default language; if no `countryCode` parameter is passed to `initialize` method, english will be loaded as a default language. + ## Methods ```js diff --git a/lib/index.js b/lib/index.js index 7074a67..b773c78 100644 --- a/lib/index.js +++ b/lib/index.js @@ -16,9 +16,7 @@ import { randomNumber } from './helpers/general.js'; * */ -export const initialize = ({ countryCode, variation = 'default' }) => { - if (!countryCode) throw new Error('Missing parameter countryCode.'); - +export const initialize = ({ countryCode = 'us', variation = 'default' }) => { const WORDS = LANGUAGES[countryCode][variation]; /** diff --git a/package-lock.json b/package-lock.json index dfcdbcc..187eb31 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@paunovic/random-words", - "version": "1.2.0", + "version": "1.2.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@paunovic/random-words", - "version": "1.2.0", + "version": "1.2.1", "license": "MIT", "devDependencies": { "chai": "^4.3.6", diff --git a/package.json b/package.json index 1120684..8f7fee9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paunovic/random-words", - "version": "1.2.0", + "version": "1.2.1", "type": "module", "description": "Serving random words in any language has never been this easy.", "author": {