Repository: plexis-js/plexis
Pull request #51 (2019-10-22 19:47:33)

feat(repeat): add repeat feature


Patch:
diff --git a/package.json b/package.json
index bee4cfc..0148546 100644
--- a/package.json
+++ b/package.json
@@ -57,4 +57,4 @@
       "git add"
     ]
   }
-}
\ No newline at end of file
+}
diff --git a/packages/repeat/README.md b/packages/repeat/README.md
new file mode 100644
index 0000000..da61b02
--- /dev/null
+++ b/packages/repeat/README.md
@@ -0,0 +1,34 @@
+# `@plexis/repeat`
+
+Repeats the input text number of times.
+
+**Installation**
+`npm i @plexis/repeat`
+
+**Usage**
+
+```javascript
+import repeat from '@plexis/repeat';
+
+repeat('ABCD');
+// => true
+
+repeat('Apollo11', 2);
+// => 'Apollo11Apollo11'
+
+repeat('x', 2);
+// => 'xx'
+
+repeat('x', 2, '+');
+// => 'x+x'
+
+repeat('xx', 2, '_');
+// => 'xx_xx'
+```
+
+**Aliases**
+
+```javascript
+import repeat from '@plexis/repeat';
+import {repeat, multiply} from 'plexis';
+```
diff --git a/packages/repeat/package.json b/packages/repeat/package.json
new file mode 100644
index 0000000..ec319ca
--- /dev/null
+++ b/packages/repeat/package.json
@@ -0,0 +1,26 @@
+{
+  "name": "@plexis/repeat",
+  "version": "0.0.14",
+  "main": "dist/index.js",
+  "module": "dist/index.esm.js",
+  "jsnext:main": "./src/index.js",
+  "files": [
+    "dist",
+    "src"
+  ],
+  "authors": [
+    "Lazar Vasic <lazav94@gmail.com>"
+  ],
+  "license": "MIT",
+  "keywords": [
+    "utility",
+    "function"
+  ],
+  "repository": {
+    "type": "git",
+    "url": "git+https://github.com/plexis-js/plexis.git"
+  },
+  "publishConfig": {
+    "access": "public"
+  }
+}
diff --git a/packages/repeat/src/index.js b/packages/repeat/src/index.js
new file mode 100644
index 0000000..b44e542
--- /dev/null
+++ b/packages/repeat/src/index.js
@@ -0,0 +1,17 @@
+/**
+ * Repeats the input text number of times.
+ * @param {String} [text] The input text.
+ * @returns {Integer} times How many times shall we repeat the text, default to 1
+ * @param {String} glue The glue for the output, default to ''
+ * @returns {String} The repeated string;
+ */
+
+const repeat = (text, times = 1, glue = '') => {
+  let result = `${text}${glue}`.repeat(times);
+  if (glue) {
+    return result.slice(0, result.length - 1);
+  }
+  return result;
+};
+
+export default repeat;
diff --git a/packages/startsWith/.npmignore b/packages/startsWith/.npmignore
new file mode 100644
index 0000000..552cf85
--- /dev/null
+++ b/packages/startsWith/.npmignore
@@ -0,0 +1,17 @@
+.DS_Store
+*.test.js
+.prettierrc
+.github
+.template
+.package-template
+.nyc_output
+.circleci
+.commitlintrc.js
+coverage
+coverage.lcov
+docs
+babel.config.js
+test
+CONTRIBUTING.md
+CODE_OF_CONDUCT.md
+LICENCE
\ No newline at end of file
diff --git a/packages/startsWith/package.json b/packages/startsWith/package.json
index 1ddecf4..e85b9d5 100644
--- a/packages/startsWith/package.json
+++ b/packages/startsWith/package.json
@@ -4,10 +4,6 @@
   "main": "dist/index.js",
   "module": "dist/index.esm.js",
   "jsnext:main": "./src/index.js",
-  "files": [
-    "dist",
-    "src"
-  ],
   "author": "Brandon Skinner <brandon.m.skinner@gmail.com>",
   "license": "MIT",
   "keywords": [
@@ -24,4 +20,4 @@
   "publishConfig": {
     "access": "public"
   }
-}
\ No newline at end of file
+}
diff --git a/packages/toChicago/.npmignore b/packages/toChicago/.npmignore
new file mode 100644
index 0000000..552cf85
--- /dev/null
+++ b/packages/toChicago/.npmignore
@@ -0,0 +1,17 @@
+.DS_Store
+*.test.js
+.prettierrc
+.github
+.template
+.package-template
+.nyc_output
+.circleci
+.commitlintrc.js
+coverage
+coverage.lcov
+docs
+babel.config.js
+test
+CONTRIBUTING.md
+CODE_OF_CONDUCT.md
+LICENCE
\ No newline at end of file
diff --git a/packages/toChicago/package.json b/packages/toChicago/package.json
index 343158b..a0e7087 100644
--- a/packages/toChicago/package.json
+++ b/packages/toChicago/package.json
@@ -7,10 +7,6 @@
   "authors": [
     "Nguyễn Tuấn Dũng <ntddebugger@gmail.com>"
   ],
-  "files": [
-    "dist",
-    "src"
-  ],
   "license": "MIT",
   "keywords": [
     "utility",
@@ -25,4 +21,4 @@
   "publishConfig": {
     "access": "public"
   }
-}
\ No newline at end of file
+}


Test patch:
diff --git a/packages/repeat/test/index.js b/packages/repeat/test/index.js
new file mode 100644
index 0000000..d86136f
--- /dev/null
+++ b/packages/repeat/test/index.js
@@ -0,0 +1,21 @@
+import repeat from '../src';
+
+it('repeat text with repeat param and default glue', () => {
+  const result = repeat('ABCD');
+  expect(result).toBe('ABCD');
+});
+
+it('repeat text with repeat param and default glue', () => {
+  const result = repeat('Apollo11', 2);
+  expect(result).toBe('Apollo11Apollo11');
+});
+
+it('repeat text with repeat param and glue', () => {
+  const result = repeat('x', 2, '+');
+  expect(result).toBe('x+x');
+});
+
+it('repeat text with repeat param and glue', () => {
+  const result = repeat('xx', 2, '_');
+  expect(result).toBe('xx_xx');
+});