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 🙏

© 2026 – Pkg Stats / Ryan Hefner

nv-facutil-generator

v1.0.6

Published

nv-facutil-generator =============== - nv-facutil-generator

Readme

nv-facutil-generator

  • nv-facutil-generator
  • generator with .prev ,history cache

install

  • npm install nv-facutil-generator

usage

example

notify style async generator

const {creat_async_noti_gen} = require("nv-facutil-generator");

var anoti = creat_async_noti_gen();
> anoti
Object [AsyncGenerator] {
  type: { resolve: 0, reject: 1 },
  noti: [Function: noti]
}
>



var p = (async () => {
    for await (let v of anoti) { 
        console.log(v)
    }
})();


> anoti.noti(100)
> 100

> anoti.noti(999,anoti.type.resolve)
> 999


> anoti.noti('some-error',anoti.type.reject)
undefined
> Uncaught 'some-error'
>

shift unshift

const {
    syncg_unshift,
    syncg_push,
    syncg_prextend,
    syncg_extend,
    asyncg_unshift,
    asyncg_push,
    asyncg_prextend,
    asyncg_extend,
} = require("nv-facutil-generator")

async function* agen0() {
  var i = 0;
  while (i < 3) {
    yield i++;
  }
}

async function* agen1() {
  var i = 3;
  while (i < 5) {
    yield i++;
  }
}

async function* agen2() {
  var i = 5;
  while (i < 8) {
    yield i++;
  }
}

async function* agen3() {
  var i = 8;
  while (i < 10) {
    yield i++;
  }
}

async function* agen4() {
  var i = 10;
  while (i < 12) {
    yield i++;
  }
}

async function * asyncg_push(sg,g) {
    yield * sg;
    yield * g;
}


async function * asyncg_unshift(sg,g) {
    yield * g;
    yield * sg;
}



(async function() {
    var sg = agen2()
    sg = asyncg_prextend(sg,[agen0(),agen1()])
    sg = asyncg_extend(sg,[agen3(),agen4()])
    for await (num of sg) {
      console.log(num);
    }
})();

/*
> 0
1
2
3
4
5
6
7
8
9
10
11

*/


> var g = sync_cirarr_from_fst([1,2,3,4])
> g.next()
{ value: 1, done: false }
> g.next()
{ value: 2, done: false }
> g.next()
{ value: 3, done: false }
> g.next()
{ value: 4, done: false }
> g.next()
{ value: 1, done: false }
> g.next()
{ value: 2, done: false }
> g.next()
{ value: 3, done: false }
> g.next()
{ value: 4, done: false }
>

> var g = sync_cirarr_from_lst([1,2,3,4])
undefined
> g.next()
{ value: 4, done: false }
> g.next()
{ value: 3, done: false }
> g.next()
{ value: 2, done: false }
> g.next()
{ value: 1, done: false }
> g.next()
{ value: 4, done: false }
> g.next()
{ value: 3, done: false }
> g.next()
{ value: 2, done: false }
> g.next()
{ value: 1, done: false }
>

prev

const {SyncGen,is_prev_end} = require("nv-facutil-generator")

function *gen(arr) {for(let i=0;i<arr.length;i++) {yield(arr[i])}}
var g0 = new SyncGen(gen,[1,2,3,4,5])
g0.history_size = 2

> g0
{
  circular: false,
  history_size: 2,
  history: [],
  his_cursor: -1,
  inuse: 'false <used when .next(force=false),default .next(true)>'
}
> g0.next()
{ value: 1, done: false }
> g0.next()
{ value: 2, done: false }
> g0.next()
{ value: 3, done: false }
> g0.prev()
{ value: 2, done: false }
> g0.prev()
{ value: Symbol(empty), done: false }
> g0

> g0.prev()
{ value: Symbol(empty), done: false }
> g0


> g0.next()
{ value: 2, done: false }
> g0.next()
{ value: 3, done: false }
> g0.next()
{ value: 4, done: false }
> g0.next()
{ value: 5, done: false }
> g0.next()
{ value: undefined, done: true }
> g0

> g0.next()
{ value: undefined, done: true }
>

> g0.prev()
{ value: 5, done: false }
> g0.next()
{ value: undefined, done: true }
> g0.next()
{ value: undefined, done: true }
> g0.prev()
{ value: 5, done: false }
> g0.prev()
{ value: 4, done: false }
> g0.prev()
{ value: Symbol(empty), done: false }
> g0.next()
{ value: 4, done: false }
>


function *gen(arr) {for(let i=0;i<arr.length;i++) {yield(arr[i])}}
var g0 = new SyncGen(gen,[1,2,3,4,5])
g0.history_size = 2
g0.circular = true
> g0
{
  circular: true,
  history_size: 2,
  history: [],
  his_cursor: -1,
  inuse: 'false <used when .next(force=false),default .next(true)>'
}
> g0.next
g0.next

> g0.next()
{ value: 1, done: false }
> g0.next()
{ value: 2, done: false }
> g0.next()
{ value: 3, done: false }
> g0.next()
{ value: 4, done: false }
> g0.next()
{ value: 5, done: false }
> g0.next()
{ value: 1, done: false }
> g0
{
  circular: true,
  history_size: 2,
  history: [ { value: 5, done: false }, { value: 1, done: false } ],
  his_cursor: 1,
  inuse: 'false <used when .next(force=false),default .next(true)>'
}
> g0.prev()
{ value: 5, done: false }
> g0.next()
{ value: 1, done: false }
> g0.next()
{ value: 2, done: false }
> g0.next()
{ value: 3, done: false }
> g0.next()
{ value: 4, done: false }
> g0.next()
{ value: 5, done: false }
> g0.next()
{ value: 1, done: false }
> g0.next()
{ value: 2, done: false }
> g0.next()
{ value: 3, done: false }
> g0.prev()
{ value: 2, done: false }
> g0.next()
{ value: 3, done: false }
>
> g0.prev()
{ value: 2, done: false }
> g0.prev()
{ value: Symbol(empty), done: false }
> g0.prev()
{ value: Symbol(empty), done: false }
>
>
> is_prev_end(g0.prev())
true
>

###METHODS

g0.args                  g0.circular              g0.constructor           g0.gen                   g0.his_cursor
g0.history               g0.history_size          g0.inuse                 g0.is_prev_end           g0.launch
g0.next                  g0.prev                  g0.reset

sync_combo

const {SyncGen,is_prev_end,sync_combo} = require("nv-facutil-generator")
function *gen(arr) {for(let r of arr) { yield(r)}}

var g0 = new SyncGen(gen,[1,2,3])
var g1 = new SyncGen(gen,['A','B'])
var g2 = new SyncGen(gen,[100,200,300])

var gs = [g0,g1,g2]

var g = sync_combo(gs)

> Array.from(g)
[
  [ 1, 'A', 100 ], [ 1, 'A', 200 ],
  [ 1, 'A', 300 ], [ 1, 'B', 100 ],
  [ 1, 'B', 200 ], [ 1, 'B', 300 ],
  [ 2, 'A', 100 ], [ 2, 'A', 200 ],
  [ 2, 'A', 300 ], [ 2, 'B', 100 ],
  [ 2, 'B', 200 ], [ 2, 'B', 300 ],
  [ 3, 'A', 100 ], [ 3, 'A', 200 ],
  [ 3, 'A', 300 ], [ 3, 'B', 100 ],
  [ 3, 'B', 200 ], [ 3, 'B', 300 ]
]
>
> var g = sync_combo(gs)
> g.next()
{ value: [ 1, 'A', 100 ], done: false }
> g.next()
{ value: [ 1, 'A', 200 ], done: false }
> g.next()
{ value: [ 1, 'A', 300 ], done: false }
> g.next()
{ value: [ 1, 'B', 100 ], done: false }
>

wrq

const {sync_cirarr_from_fst} = require("nv-facutil-generator")
function *gen(arr) {for(let r of arr) { yield(r)}}

var g0 = sync_cirarr_from_fst([10])
var g1 = sync_cirarr_from_fst([20])
var g2 = sync_cirarr_from_fst([30])

var gs = [
    {g:g0,weight:1},
    {g:g1,weight:2},
    {g:g2,weight:3},
]


> var g =  sync_wrq(gs)
>
> g.next()
{ value: [ 10, 20, 20, 30, 30, 30 ], done: false }
> g.next()
{ value: [ 10, 20, 20, 30, 30, 30 ], done: false }
> g.next()
{ value: [ 10, 20, 20, 30, 30, 30 ], done: false }
> g.next()
{ value: [ 10, 20, 20, 30, 30, 30 ], done: false }
>

rwq

const {sync_cirarr_from_fst} = require("nv-facutil-generator")
function *gen(arr) {for(let r of arr) { yield(r)}}

var g0 = sync_cirarr_from_fst([10,100,1000])
var g1 = sync_cirarr_from_fst([20,2,2.2])
var g2 = sync_cirarr_from_fst([30])

var gs = [
    {g:g0,weight:1},
    {g:g1,weight:2},
    {g:g2,weight:3},
]



> var g = sync_rwq(gs)
undefined
> g.next()
{ value: [ 10, 20, 30, 2, 30, 30 ], done: false }
> g.next()
{ value: [ 100, 2.2, 30, 20, 30, 30 ], done: false }
> g.next()
{ value: [ 1000, 2, 30, 2.2, 30, 30 ], done: false }
> g.next()
{ value: [ 10, 20, 30, 2, 30, 30 ], done: false }
> g.next()
{ value: [ 100, 2.2, 30, 20, 30, 30 ], done: false }
> g.next()
{ value: [ 1000, 2, 30, 2.2, 30, 30 ], done: false }
> g.next()
{ value: [ 10, 20, 30, 2, 30, 30 ], done: false }
> g.next()
{ value: [ 100, 2.2, 30, 20, 30, 30 ], done: false }
>

G

> var g = G.ary([12,13,14])
> g
{ v: 12, i: 0 }
> g.next_
{ v: 13, i: 1 }
> g.next_
{ v: 14, i: 2 }
> g.next_
{ v: 12, i: 0 }
> g.next_
{ v: 13, i: 1 }
> g.prev_
{ v: 12, i: 0 }
> g.prev_
{ v: 14, i: 2 }
> g.prev_
{ v: 13, i: 1 }
>
> g.



g.$regis_fst_to_lst_trans    g.$regis_is_fst              g.$regis_is_lst
g.$regis_lst_to_fst_trans    g.$regis_next                g.$regis_prev
g.$unregis_fst_to_lst_trans  g.$unregis_lst_to_fst_trans  g.ary_
g.constructor                g.curr_                      g.db_
g.next_                      g.prev_


G.ary                   G.ary_fst_to_lst_trans  G.ary_is_fst            G.ary_is_lst
G.ary_lst_to_fst_trans  G.ary_next              G.ary_prev              G.empty

API

  • function is_sync_gfunc(f)
  • function is_async_gfunc(f)
  • function is_sync_generator(g)
  • function is_async_generator(g)
  • function * syncg_push(sg,g)
  • function * syncg_unshift(sg,g)
  • function * syncg_prextend(sg,garr)
  • function * syncg_extend(sg,garr)
  • async function * asyncg_push(ag,g)
  • async function * asyncg_unshift(ag,g)
  • async function * asyncg_prextend(ag,garr)
  • async function * asyncg_extend(ag,garr)
  • function * sync_cirarr_from_fst(arr)
  • function * sync_cirarr_from_lst(arr)
  • function * sync_combo(sgs)
  • function * sync_wrq(gs)
  • function * sync_rwq(gs)

LICENSE

  • ISC