summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbdus <abdus@abdus.net>2020-12-02 19:43:13 +0530
committerAbdus <abdus@abdus.net>2020-12-02 19:43:13 +0530
commit243c3ea0b98b262005bd49583b2b474c6739ac86 (patch)
tree4b4f5c31a50f6ad633549e1348d17316994bf554
parentbd61c8daf972760137a1a1400649ec4c0fdb0978 (diff)
downloadabdus.net-243c3ea0b98b262005bd49583b2b474c6739ac86.tar.bz2
abdus.net-243c3ea0b98b262005bd49583b2b474c6739ac86.zip
add gpg public key
-rw-r--r--content/posts/generator-func-in-javascript.md32
-rw-r--r--static/keys/pub.gpg.txt41
2 files changed, 72 insertions, 1 deletions
diff --git a/content/posts/generator-func-in-javascript.md b/content/posts/generator-func-in-javascript.md
index 465c946..0a13ac2 100644
--- a/content/posts/generator-func-in-javascript.md
+++ b/content/posts/generator-func-in-javascript.md
@@ -75,10 +75,40 @@ Interesting thing is that, `next()` may accpet a value if passed. Passed value
will be returned as `yield` expression. For example, `name = yield name`.
Whatever is passed to `next()` method, will be stored in variable `name`.
-**Arguments passed to first invocation of `next()` will be in-effective.**
+> Arguments passed to first invocation of `next()` will be ignored.
### `Iterator.return()` Method
Assume that, for some reason, you need to complete executing the whole generator
function immediately. In such cases, do we have a viable option? Yes! it's
called [`return()`](#)
+
+## Examples
+
+Just as the title says, I am going to provide a few useful real-world usecases
+for generator functions.
+
+### 1. Generating Unique ID
+
+Unique IDs are [important]() at multiple scenerios. It gets tricky to generate
+those. Most of the time we depend upon external libraries.
+
+To generate an unique ID, either we could simply write a number generator using
+Generator Functions. Or we could convert them to some sort of strings. Both ways
+works good.
+
+Below is an example to generate unique strings.
+
+```javascript
+function* GenerateUniqueID() {
+ let i = 0;
+ while(true) {
+ const str = btoa(i);
+ i++;
+ yield str;
+ }
+}
+```
+
+What this would do? It will simply create a Base64 representation of a given
+number.
diff --git a/static/keys/pub.gpg.txt b/static/keys/pub.gpg.txt
new file mode 100644
index 0000000..bdaabdb
--- /dev/null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