npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

Iโ€™ve always been into building performant and accessible sites, but lately Iโ€™ve been taking it extremely seriously. So much so that Iโ€™ve been building a tool to help me optimize and monitor the sites that I build to make sure that Iโ€™m making an attempt to offer the best experience to those who visit them. If youโ€™re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, ๐Ÿ‘‹, Iโ€™m Ryan Hefnerย  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If youโ€™re interested in other things Iโ€™m working on, follow me on Twitter or check out the open source projects Iโ€™ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soonโ€“ish.

Open Software & Tools

This site wouldnโ€™t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you ๐Ÿ™

ยฉ 2024 โ€“ย Pkg Stats / Ryan Hefner

@codeb/pleasejs

v1.0.1

Published

๐Ÿ™Œ Please.js is the polite way of building a javascript util library for any project.

Downloads

3

Readme

๐Ÿ™Œ Please.js

the polite way of building a javascript util library for your project

Does this sound familiar?

You are building some helper functions for your project, you want to eventually combine it under one name... and now you spend hours thinking about what to call your util library.

Yes

This is your problem no more.

Enter: ๐Ÿ™Œ Please.js

Please tell me more Sir!

Create a polite API for whatever you want to build.

You have a function to move an element from a to b? What about this API:

// Politely ask to move something
please.move(element);

You have a function to hide a textbox? What about this API:

// Politely ask to hide content
please.hideTheTextbox('.thisone');

You have a function to have HBO remake the horrible last season of Game of Thrones? What about this API?

// Hey HBO, are you listening?
please.remakeThatNonsens();

Doesn't that all look like a super polite API?

Please, I want that now!

Luckily this all can be yours now, so let me show you how!

Installation and how to use

Add it to your project

npm install @codeb/pleasejs

After that -- import please where your utility functions live.

// ./please.js

import Please from '@codeb/pleasejs';

// create your new polite please instance
const please = new Please();

//Let's teach it a new method
please.learn('sayHello', (name) => {
  console.log(`Hello ${name}`);
});

Now this function is made available to you on the please instance. You could call it like this:

please.sayHello('Wonder Woman');
// -> logs 'Hello Wonder Woman'

What a polite wayway to add new methods. You can add all the methods you want now. So let's see how to make it available in your project:

Expose please to my project

At the end of your own please.js file you just want to export it, so the rest of your project can politely do things.

export default please;

Import it and use it!

// ./some-file.js

import please from './please.js';

please.sayHello('Batman');

That's it.

Exciting

One more thing

There's one little thing that I would recommend to do though.

As you've seen it's easy to add new methods to please, but this also means you could add new methods wherever you have access to the instance. As this is potentially annoying and might put all the awesome code you want to use in too many places, please got your back.

  • learn will always warn you if you if there already is method defined with that name.
please.learn('sayHello', () => {});
// -> Throws Error 'Method sayHello is already defined'
  • Also, you can freeze your instance to avoid accidental additions and make sure your codebase is polite AND clean.
// Prevent adding any new methods by freezing the API into place
please.freeze();

All together

Here's all the code from above put together clean and simple.

import Please from '@codeb/pleasejs';

const please = new Please();

please.learn('sayHello', (name) => {
  console.log(`Hello ${name}`);
});

please.freeze();

export default please;

It was never easier to write a polite utility library.

Thank you


๐Ÿ™Œ Please.js is brought to you by @codebryo