randexp.js (GitHub: fent / randexp.js, License: MIT, npm: randexp) by Roly Fentanes is a library for creating random strings based on a regular expression. The resulting string will match the expression provided:
require('randexp'); /hello+ (world|to you)/.gen // => hellooooooooooooooooooo world
A more useful example might be generating a random date:
new RegExp((January|February|March|April|May|June|July|August|September|October|November|December) ([1-9]|[0-9]|3), (19|20)[0-9][0-9]).gen // March 4, 2038
This could be a useful way to generate test data in unit tests.
The way the
RegExp object is modified by this library goes against the grain a little bit, and using a getter to return values seems a little bit odd, so I’ve asked the author about the API design through GitHub.
ECMAScript 5 Presentation
I don’t usually post slides, because without the corresponding talk they’re usually too hard to follow. ECMAScript 5 by Damian Wielgosik is a 150 slide presentation that introduces ECMAScript 5, and is relatively easy to follow if you don’t mind pressing the right arrow key 150 times.
The majority of the slides are concerned with new methods on
Object, and some patterns that make use of these new methods are explained. Other areas covered include
Array.prototype methods, and strict mode.
Particles: Online Editor for Sparks.js
Press the “code” button to show the code used to generate the particle system. The code can be edited, and the changes will be displayed in real time. To share the results, press the “export” button.
A wide range of effects can be created with Sparks.js. There are examples available at jabtunes.com/labs/arabesque/.