Skip to content

Instantly share code, notes, and snippets.

View palkerecsenyi's full-sized avatar

Pal Kerecsenyi palkerecsenyi

View GitHub Profile
@nybblr
nybblr / 1-easy.js
Last active July 13, 2022 03:40
3 examples of using Async Generators and Async Iteration in JavaScript!
// Create a Promise that resolves after ms time
var timer = function(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
// Repeatedly generate a number starting
// from 0 after a random amount of time
var source = async function*() {
@joecliff
joecliff / cryptojs_wordarray.js
Last active March 16, 2023 20:32
cryptojs WordArray usage
/**
* cryptojs use WordArray (CryptoJS.lib.WordArray) as parameter/result frequently.
* A WordArray object represents an array of 32-bit words. When you pass a string,
* it's automatically converted to a WordArray encoded as UTF-8.
*/
var CryptoJS = require("crypto-js");
// convert String to WordArray
var wordArray = CryptoJS.enc.Utf8.parse('Hello, World!');