Any TILs from your package managers library recently?

@lukeocodes 🕹👨‍💻 - Apr 23 '20 - - Dev Community

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

GitHub logo 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.

Dependency Status codecov

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'));
Enter fullscreen mode Exit fullscreen mode

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

GitHub logo bubenshchykov / ngrok

Expose your localhost to the web. Node wrapper for ngrok.

ngrok Tests TypeScript compatible npm npm

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.

alt ngrok.com

Usage

Local install

Install the package with npm:

npm install ngrok
Enter fullscreen mode Exit fullscreen mode

Then use ngrok.connect() to start ngrok and open a tunnel.

const ngrok = require('ngrok');
(async function() {
  const url = await ngrok.connect();
})();
Enter fullscreen mode Exit fullscreen mode

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.

So did you stumble upon any neat code this week?

. . . . . . . . . . . . . . . . . . . . . . . . . . .