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

javascript-common

v0.0.5

Published

Things common in javascript code

Downloads

5

Readme

javascript-common

The code in this package is common to be used in some my projects. Although for my projects, it may be useful for you. Things that can be imported from this package:

noop

It's a function that does nothing (() => {}). This function is often used as the default value for a variable whose function type. Instead of maintaining many copies, it's better to keep one copy in memory.

noChange

This function returns the parameter that is passed into it, no change (p => p). Like noop, this function is often used as the default value for a variable whose function type. Instead of maintaining many copies, it's better to keep one copy in memory.

emptyString

This is an empty string (""). An empty string is often used as the default value of a string variable.

extendObject(target, proxy)

It extends the object target by adding to it the new members (properties/methods) from the object proxy. It's like Object.assign(target, proxy), but different from Object.assign, when there are some the same members among target and proxy, it doesn't remove those members from target and replace them with the same ones from proxy. The original members still exist in target. This function is simply invoke Object.setPrototypeOf(proxy, target). If it's so simple, why do we need the wrapper function? It's because we need a static type checking. The type of the returned value should be the type which is combination between target's type and proxy's type.

<T extends object, P extends object>(target: T, proxy: P) => T & P

proxyObject(target, proxy)

Similar to extendObject but it doesn't change the prototype of target. It utilizes a Proxy object. It's useful if target already has a prototype object.

proxyClass(Target, proxy)

Similar to proxyObject but the first parameter is not an instance object, it's a class of target object. This function will create the target instance: const target = new Target()