human-ids 1.0.10 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [1.0.12] - 2023-07-07
8
+
9
+ ### Fixed
10
+ - Fixed bug with undefined disctionaries
11
+ ## [1.0.11] - 2023-07-07
12
+
13
+ ### Fixed
14
+ - Fixed bug with custom dictionaries
7
15
  ## [1.0.10] - 2023-07-07
8
16
 
9
17
  ### Added
package/index.d.ts CHANGED
@@ -12,13 +12,13 @@ declare module 'human-ids' {
12
12
  completeWithZeros?: boolean;
13
13
  };
14
14
  dictionary?: {
15
- adjectives?: {
15
+ adjectives: {
16
16
  [key: string]: string[];
17
17
  };
18
- colors?: {
18
+ colors: {
19
19
  [key: string]: string[];
20
20
  };
21
- nouns?: {
21
+ nouns: {
22
22
  [key: string]: string[];
23
23
  }
24
24
  };
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const dictionaries = require('./dictionaries');
2
2
 
3
3
  const defaultSettings = {
4
- lang: 'en',
4
+ lang: 'es',
5
5
  adjective: true,
6
6
  color: true,
7
7
  noun: true,
@@ -16,7 +16,7 @@ const defaultSettings = {
16
16
  };
17
17
 
18
18
  function generateId(userSettings = {}) {
19
- const settings = Object.assign({}, defaultSettings, userSettings);
19
+ const settings = {...defaultSettings, ...userSettings};
20
20
  const lang = dictionaries[settings.lang] ? settings.lang : dictionaries[settings.lang?.split('-')[0]] ? settings.lang?.split('-')[0] : 'en';
21
21
  const useAdjective = settings.adjective || false;
22
22
  const useColor = settings.color || false;
@@ -40,15 +40,15 @@ function generateId(userSettings = {}) {
40
40
  }
41
41
 
42
42
  function getAdjectives() {
43
- return settings.dictionary && settings.dictionary.adjectives ? settings.dictionary.adjectives : {};
43
+ return settings.dictionary && settings.dictionary.adjectives ? settings.dictionary.adjectives : dictionaries[lang].adjectives;
44
44
  }
45
45
 
46
46
  function getColors() {
47
- return settings.dictionary && settings.dictionary.colors ? settings.dictionary.colors : {};
47
+ return settings.dictionary && settings.dictionary.colors ? settings.dictionary.colors : dictionaries[lang].colors;
48
48
  }
49
49
 
50
50
  function getNouns() {
51
- return settings.dictionary && settings.dictionary.nouns ? settings.dictionary.nouns : {};
51
+ return settings.dictionary && settings.dictionary.nouns ? settings.dictionary.nouns : dictionaries[lang].nouns;
52
52
  }
53
53
 
54
54
  const parts = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "human-ids",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "A library to generate human readable IDs",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -2,7 +2,7 @@ const generateId = require('../index');
2
2
 
3
3
  describe('generateId', () => {
4
4
  test('should return a unique ID', () => {
5
- const testLength = 1000000;
5
+ const testLength = 1000;
6
6
  const settings = {
7
7
  lang: 'en',
8
8
  adjective: true,