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

obj-logger

v1.0.0

Published

This module can display all the information about accessing the user object

Downloads

2

Readme

Objects' logger

Do you know how console.log is actually working? If to it in parameters to transfer one object, here that will occur:
1)First, the console.log will try to find the mysterious field Symbol(util.inspect.custom) in the object. Unfortunately, I could not find information about what would happen if this field was found.
2)Then, there will be an attempt to find the mysterious field № 2 inspect in the object
3 - 4) 3 and 4 step of accessing the object will receive an array of all internal fields of the object. Of course, there are many other actions between all these steps, such as filtering the elements of intermediate arrays for their belonging to a certain type, etc. I describe actions with direct access to the object.
The next steps will be to obtain descriptor-objects for each field from the array received in one of the previous steps. Then, there will be an attempt to get the value of the constructor field. After that, the prototype of the user object will be obtained, which is rather strange, since the сonsole.log does not output fields from the prototype chain. Then there will be an attempt to find the Symbol(Symbol.iterator) field. And the last step will be to retrieve the descriptor-objects for each field that has an enumerable: foul. Agree, rather confusing work. And what if I pass the function to the console.log? Or several objects? Or a lot of different types of data? In addition, many functions can interact with the object, except for the console.log, such as Object.getPrototupeOf etc. Then it will be very difficult to foresee everything that the console.log will do. Especially it is felt by those who write heterogeneous interceptors for objects. It is difficult to intercept all calls, because you do not know what they can be in the built-in functions. This module will come to your aid. It logs all calls to objects, and also outputs all the parameters with which these calls are made

How you can use it:

First of all, you need to install this module:

npm install obj-logger

Then, require module in program, where are that module, which you can log:

const Logger = require('obj-logger');

The module returns one function, which is a factory that, on the basis of the provided object, creates a similar object, but has already become a logged. Therefore, it makes sense to overwrite the old object, instead of creating a new one:

let obj = {
  field: 'value',
}
obj = Logger(obj);

Now the object became logged
All functions that will somehow interact with the object will be immediately escaped to the terminal, as well as their arguments will be displayed, and the result given to them