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

nv-facutil-fixed-cache-cursor

v1.0.2

Published

nv-facutil-fixed-cache-cursor ============================= - mini cache with cursor - same as https://www.npmjs.com/package/nv-facutil-cache-cursor - for size < 8 using, for performance - fst,ppprev, pprev, prev, current, next,nnext,nnnext,lst - forward

Downloads

3

Readme

nv-facutil-fixed-cache-cursor

  • mini cache with cursor, its just a array-of-size-8
  • same as https://www.npmjs.com/package/nv-facutil-cache-cursor
  • for size < 8 using, for performance
  • fst,ppprev, pprev, prev, current, next,nnext,nnnext,lst
  • forward ,backword, push,pop, push_and_forward ,pop_and_backward

install

  • npm install nv-facutil-fixed-cache-cursor

usage

const Cache = require("nv-facutil-fixed-cache-cursor");      

example

    var cache = new Cache()

    /*
    > cache
    Cache(8) [
      undefined, undefined,
      undefined, undefined,
      undefined, undefined,
      undefined, undefined
    ]
    */

    cache.push_and_forward(10)

    /*
    10
    > cache.curr_
    10
    > cache.cursor_
    0
    > cache.length_
    1
    > cache
    Cache(8) [
      10,        undefined,
      undefined, undefined,
      undefined, undefined,
      undefined, undefined
    ]
    >
    */

    cache.push(20)

    /*
    > cache
    Cache(8) [
      10,        20,
      undefined, undefined,
      undefined, undefined,
      undefined, undefined
    ]
    >
    > cache.curr_
    10
    > cache.cursor_
    0
    > cache.length_
    2
    >
    */

    cache.push(30)
    cache.push(40)

    /*
    > cache.cursor_
    0
    > cache.curr_
    10
    > cache.length_
    4
    > cache
    Cache(8) [
      10,        20,
      30,        40,
      undefined, undefined,
      undefined, undefined
    ]
    */

    cache.forward()
    /*

    20
    > cache.curr_
    20
    */

    cache.forward(2)

    /*
    40
    > cache.curr_
    40
    >
    */

    cache.forward()
    cache.forward()
    cache.forward()

    /*
    > cache.curr_
    40
    >
    */

    cache.backward()
    /*
    >
    30
    */

    cache.backward()
    /*
    20
    >
    > cache.curr_
    20
    >
    */


    cache.push(50)
    cache.push(60)
    cache.push(70)
    cache.push(80)

    /*
    > cache
    Cache(8) [
      10, 20, 30, 40,
      50, 60, 70, 80
    ]
    >
    > cache.curr_
    20
    >
    */

    cache.push(100)

    /*
    > cache
    Cache(8) [
      20, 30, 40,  50,
      60, 70, 80, 100
    ]
    > cache.curr_
    30
    >


    */

    cache.forward(6)

    /*

    100
    >
    */

    cache.forward()
    cache.forward()
    cache.forward()
    /*
    100
    >
    */

    cache.pop_and_backward()

    // different behavior from normal pop, it returned current not the popped,
    /*
    > cache.pop_and_backward()
    80
    > cache
    Cache(8) [ 20, 30, 40, 50, 60, 70, 80, undefined ]
    > cache.curr_
    80
    >

    */

    cache.pop_and_backward()
    cache.pop_and_backward()
    cache.pop_and_backward()
    cache.pop_and_backward()

    /*
    > cache.pop_and_backward()
    70
    > cache.pop_and_backward()
    60
    > cache.pop_and_backward()
    50
    > cache.pop_and_backward()
    40
    > cache
    Cache(8) [
      20,        30,
      40,        undefined,
      undefined, undefined,
      undefined, undefined
    ]
    > cache.curr_
    40
    > cache.length_
    3
    >

    */


    cache.pop_and_backward()
    cache.pop_and_backward()
    cache.pop_and_backward()
    /*
    null


    > cache
    Cache(8) [
      undefined, undefined,
      undefined, undefined,
      undefined, undefined,
      undefined, undefined
    ]
    >
    > cache.pop_and_backward()
    already empty
    null
    > cache.curr_
    null
    > cache.length_
    0
    >
    */

    cache.push_and_forward(11)
    cache.push_and_forward(12)
    cache.push_and_forward(13)
    cache.push(14)
    cache.push(15)
    cache.push(16)

    /*
    > cache
    Cache(8) [ 11, 12, 13, 14, 15, 16, undefined, undefined ]
    > cache.curr_
    13
    >

    */
    cache.forward()
    /*
    > cache.forward()
    14
    > cache
    Cache(8) [ 11, 12, 13, 14, 15, 16, undefined, undefined ]
    >

    */

    cache.push(17)
    /*
    > cache
    Cache(8) [ 11, 12, 13, 14, 15, 16, 17, undefined ]
    > cache.curr_
    14
    >

    */

getter : for token-cache using, most language lookahead(3) lookback(3) is enough

    cache.ppprev_
    cache.pprev_
    cache.prev_
    cache.curr_
    cache.next_
    cache.nnext_
    cache.nnnext_


    /*

    > cache.ppprev_
    11
    > cache.pprev_
    12
    > cache.prev_
    13
    > cache.curr_
    14
    > cache.next_
    15
    > cache.nnext_
    16
    > cache.nnnext_
    17
    >
    */

slice

    cache.slice_lt_cursor_
    cache.slice_le_cursor_
    cache.slice_ge_cursor_
    cache.slice_gt_cursor_

    /*
    > cache.slice_lt_cursor_
    [ 11, 12, 13 ]
    >
    > cache.slice_le_cursor_
    [ 11, 12, 13, 14 ]
    >
    > cache.slice_ge_cursor_
    [ 14, 15, 16, 17]
    >
    > cache.slice_gt_cursor_
    [ 15, 16, 17]
    >

    */

clear

    cache.clear()
    /*
    > cache
    Cache(8) [
      undefined, undefined,
      undefined, undefined,
      undefined, undefined,
      undefined, undefined
    ]
    >

    */

forbidden, for safe

    > cache.shift()
    Uncaught 'unreachable'
    > cache.splice()
    Uncaught 'unreachable'
    >
    > cache.unshift()
    Uncaught 'unreachable'
    >

METHODS

    cache.b                        cache.backward                 cache.can_backward_max_steps_
    cache.can_forward_max_steps_   cache.clear                    cache.constructor
    cache.curr_                    cache.cursor_                  cache.f
    cache.forward                  cache.fst_                     cache.is_cant_backward_one
    cache.is_cant_forward_one      cache.is_cursor_at_max         cache.is_cursor_at_min
    cache.is_empty                 cache.length_                  cache.lst_
    cache.max_cursor_              cache.min_cursor_              cache.next_
    cache.nnext_                   cache.nnnext_                  cache.pop
    cache.pop_and_backward         cache.pop_one                  cache.ppprev_
    cache.pprev_                   cache.prev_                    cache.push
    cache.push_and_forward         cache.push_index_              cache.safe_pop
    cache.shift                    cache.slice_ge_cursor_         cache.slice_gt_cursor_
    cache.slice_le_cursor_         cache.slice_lt_cursor_         cache.splice
    cache.unshift

APIS

  • Cache._push
  • Cache._copy

LICENSE

  • ISC