I want to hear about any absolute GEMS (ruby devs need not smirk) from your package manager libraries.
Today, I found THESE! (not just one!)
Randexp
fent / randexp.js
Create random strings that match a given regular expression.
randexp.js
randexp will generate a random string that matches a given RegExp Javascript object.
Usage
const RandExp = require('randexp');
// supports grouping and piping
new RandExp(/hello+ (world|to you)/).gen();
// => hellooooooooooooooooooo world
// sets and ranges and references
new RandExp(/<([a-z]\w{0,20})>foo<\1>/).gen();
// => <m5xhdg>foo<m5xhdg>
// wildcard
new RandExp(/random stuff: .+/).gen();
// => random stuff: l3m;Hf9XYbI [YPaxV>U*4-_F!WXQh9>;rH3i l!8.zoh?[utt1OWFQrE ^~8zEQm]~tK
// ignore case
new RandExp(/xxx xtreme dragon warrior xxx/i).gen();
// => xxx xtReME dRAGON warRiOR xXX
// dynamic regexp shortcut
new RandExp('(sun|mon|tue|wednes|thurs|fri|satur)day', 'i');
// is the same as
new RandExp(new RegExp('(sun|mon|tue|wednes|thurs|fri|satur)day', 'i'));
If you're onlyβ¦
I'm writing a Slack bot that reacts to a word in a message. It listens for a message and matches it with a regex, responding appropriately.
This library will allow me to write tests that match, without hard coding a message.
Ngrok
bubenshchykov / ngrok
Expose your localhost to the web. Node wrapper for ngrok.
This project is the Node.js wrapper for the ngrok client. Version 5 of this project uses ngrok client version 3. For ngrok client version 2, check out version 4.
- Usage
- How it works
- ngrok binary update
- Using with nodemon
- Contributors
- Upgrading to version 5
- Upgrading to version 4
Usage
Local install
Install the package with npm:
npm install ngrok
Then use ngrok.connect()
to start ngrok and open a tunnel.
const ngrok = require('ngrok');
(async function() {
const url = await ngrok.connect();
})();
This module uses node>=10.19.0
with async/await. For a callback-basedβ¦
Ngrok's npm package can be run as a module! I was so amazed I wrote it up as a little hello-world guide this morning.
The Ultimate `npm run dev`
@lukeocodes πΉπ¨βπ» γ» Apr 23 '20
So did you stumble upon any neat code this week?
Top comments (0)