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

nd-reflect-promise

v1.0.2

Published

nd-reflect-promise ======================= - reflect style Promise - only work in nodejs - for test sig-slot feature in nvlang

Downloads

6

Readme

nd-reflect-promise

  • reflect style Promise
  • only work in nodejs
  • for test sig-slot feature in nvlang

install

  • npm install nd-reflect-promise

usage

  const { 
    creat_one,
creat_many,
rtrn,
thrw
  }   = require("nd-reflect-promise");

example

creat_one

var p = creat_one();
/*
> p
Promise {
  <pending>,
  [Symbol(async_id_symbol)]: 38,
  [Symbol(trigger_async_id_symbol)]: 5
}
> 
*/

resolve

	rtrn(p,200)      
                  // rename <resolve> to <rtrn> IS for api-compatible-with-nvlang
                  // <resolve> in nvlang IS used by dag-excutor'multi-cast-notify
	/*
	> p
	Promise {
	  200,
	  [Symbol(async_id_symbol)]: 38,
	  [Symbol(trigger_async_id_symbol)]: 5
	}
	> 
	*/

reject

	var p = creat_one();

	/*
	> p
	Promise {
	  <pending>,
	  [Symbol(async_id_symbol)]: 362,
	  [Symbol(trigger_async_id_symbol)]: 5
	}
	> 
	*/

	thrw(p,404);
                        // rename <reject> to <thrw> IS for api-compatible-with-nvlang
                        // <reject> in nvlang IS used by dag-excutor'multi-cast-notify
	/*
	> Uncaught 404
	> 
	> p
	Promise {
	  <rejected> 404,
	  [Symbol(async_id_symbol)]: 362,
	  [Symbol(trigger_async_id_symbol)]: 5
	}
	> 
	*/

creat_many

      var ps = creat_many(10000000);

compare mem-usage with pure js layer defer methods

			/*----------------------------------
			var rss_si = process.memoryUsage().rss;
			var ps     = creat_many(10000000);
			var rss_ei = process.memoryUsage().rss;

			console.log("reflect style cost:",rss_ei-rss_si);



			//stop exit to observe mem
			var net = require('net');
			var server = net.createServer(function(connection) {
			});
			server.listen(8080, function() { });
			------------------------------------------------*/

			TEST# node low-mem.js 
			reflect style cost: 685867008

			   PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                                            
			  11394 root      20   0 1664076 714120  35932 S   0.0   4.4   0:06.88 node     // 16G*0.044 = 700M



			/*----------------------------------
			var rss_si = process.memoryUsage().rss;

			var ary_of_t3 = [];

			for(let i=0;i<10000000;++i) {
			   let RS;
			   let RJ;
			   var P = new Promise(
			      (rs,rj) => {
				      RS = rs;
					  RJ = rj;
				  }
			   )
			   ary_of_t3.push(P,RS,RJ)
			}

			var rss_ei = process.memoryUsage().rss;

			/*
			%DebugPrint(ary_of_t3[0]);
			%DebugPrint(ary_of_t3[1]);
			%DebugPrint(ary_of_t3[2]);
			*/
			console.log("js style cost:",rss_ei-rss_si);

			//stop exit to observe mem
			var net = require('net');
			var server = net.createServer(function(connection) {});
			server.listen(8080, function() { });

			console.log(ary_of_t3.length)
			------------------------------------------------*/

			/*
			/TEST# node hig-mem.js 
			js style cost: 2880438272

			   PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                                            
			  11428 root      20   0 3778364   2.7g  38964 S   0.0  17.4   0:18.88 node      // 16G*0.174 = 2850.816M

			*/

METHODS

APIS

     creat_one(               ): Promise
     rtrn     (p:Promise,v:Any): Void                  // first-param p MUST be Promise, IF not, crash
     thrw     (p:Promise,v:Any): Void                  // first-param p MUST be Promise, IF not, crash

     creat_many(cnt:<uint32_t>): Array<Promise>        // cnt MUST be uint32 AND cant be 0, IF not, crash 

LICENSE

  • ISC