Skip to content

Commit b67e55e

Browse files
authored
Merge pull request alphaolomi#10 from alphaolomi/update-patch
feat: update
2 parents 7a1b6db + c053c9f commit b67e55e

File tree

8 files changed

+45
-28
lines changed

8 files changed

+45
-28
lines changed
File renamed without changes.

.swahili.js.swp

-12 KB
Binary file not shown.

.test.js.swp

-12 KB
Binary file not shown.

docs/CHANGELOG.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Changelog
22

3-
All notable changes to `wazo` will be documented in this file.
3+
All notable changes to `swahili` will be documented in this file.
44

55
Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
66

7-
## NEXT - 2019-10-30
7+
## NEXT - 2021-05-30
88

99
### Added
1010
- Nothing
@@ -20,3 +20,16 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
2020

2121
### Security
2222
- Nothing
23+
24+
25+
## 1.1.0 - 2021-04-15
26+
27+
### Added
28+
- [#8](https://github.com/alphaolomi/swahili/pull/8) Add support for multiple random words, paragraphs. Thanks to [@astrojose](https://github.com/astrojose)
29+
30+
31+
## 1.0.0 - 2019-10-30
32+
33+
### Added
34+
- Add support for random words generation
35+
File renamed without changes.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
"version": "1.0.1-0",
44
"type":"module",
55
"description": "Generate random swahili words",
6-
"main": "random.js",
6+
"main": "swahili.js",
77
"scripts": {
8-
"test": "node --experimental-json-modules --no-warnings=ExperimentalWarning test.js"
8+
"test": "node --experimental-json-modules --no-warnings=ExperimentalWarning ./tests/words.js"
99
},
1010
"repository": {
1111
"type": "git",
1212
"url": "git+https://github.com/alphaolomi/swahili.git"
1313
},
1414
"keywords": [
15+
"kiswahili",
1516
"swahili",
1617
"words",
1718
"language",
@@ -20,7 +21,7 @@
2021
"algorithm"
2122
],
2223
"author": "Alpha Olomi <[email protected]>",
23-
"license": "ISC",
24+
"license": "BSD-2-Clause",
2425
"bugs": {
2526
"url": "https://github.com/alphaolomi/swahili/issues"
2627
},

swahili.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import list from "./words.json";
22

3-
//const length = Object.keys(list).length
4-
53
/**
64
* Generate an swahili of words
75
*
86
* @param Integer word_count
97
* @return Array|String
108
*/
119
class swahili {
10+
/**
11+
*
12+
* @param {*} word_count
13+
*/
1214
constructor(word_count = 1) {
13-
this.random = function() {
15+
this.random = function () {
1416
if (word_count == 1) {
1517
const word = list[Math.floor(Math.random() * list.length)];
1618
return word.sw;
@@ -23,26 +25,27 @@ class swahili {
2325
return words;
2426
}
2527
};
26-
27-
this.randomArray = function(){
28-
const words = [];
29-
for (let i = 1; i <= word_count; i++) {
30-
const word = list[Math.floor(Math.random() * list.length)];
31-
words.push(word.sw);
32-
}
33-
return words;
34-
}
35-
36-
// Generate paragraph from word_count random words
37-
this.paragraph = function(){
38-
let words = '';
39-
for (let i = 1; i <= word_count; i++) {
40-
const word = list[Math.floor(Math.random() * list.length)];
41-
words += word.sw + ' ';
42-
}
43-
return words.trim();
44-
}
4528

29+
this.randomArray = function () {
30+
const words = [];
31+
for (let i = 1; i <= word_count; i++) {
32+
const word = list[Math.floor(Math.random() * list.length)];
33+
words.push(word.sw);
34+
}
35+
return words;
36+
};
37+
38+
/**
39+
* Generate paragraph from word_count random words
40+
*/
41+
this.paragraph = function () {
42+
let words = "";
43+
for (let i = 1; i <= word_count; i++) {
44+
const word = list[Math.floor(Math.random() * list.length)];
45+
words += word.sw + " ";
46+
}
47+
return words.trim();
48+
};
4649
}
4750
}
4851

test.js renamed to tests/words.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import swahili from './swahili.js'
1+
import swahili from '../swahili.js'
22

33
let word = new swahili(10)
44

0 commit comments

Comments
 (0)