1.0.1 • Published 2 years ago

nv-facutil-simple-lru v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

nv-facutil-simple-lru

  • a 1000000-fixed-size-Array
  • for test find method of small-scale-data between(500000 - 1000000), USELESS
  • only 3 method find / get /set

install

  • npm install nv-facutil-simple-lru

usage

example

    var Lru = require("nv-facutil-simple-lru")
    var lru = new Lru()

    lru.set(0,{a:100,b:200})

    lru.set(3,{a:100,b:300})

    lru.set(5,{a:100,b:400})

    /*
    > lru.use_history_
    [
       5,  3,  0,  1,  2,  4,  6,  7,  8,  9, 10, 11,
      12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
      24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
      36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
      48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
      60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
      72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
      84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
      96, 97, 98, 99,
      ... 999900 more items
    ]
    >

    */

    > lru.get(6)
    /*
    > lru.use_history_
    [
       6,  5,  3,  0,  1,  2,  4,  7,  8,  9, 10, 11,
      12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
      24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
      36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
      48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
      60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
      72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
      84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
      96, 97, 98, 99,
      ... 999900 more items
    ]
    >
    */

    > lru.find((r,i)=>r?.b===300)
    { a: 100, b: 300 }
    >

    /*
    > lru
    Lru(1000000) [
      { a: 100, b: 200 }, undefined,          undefined, { a: 100, b: 300 },
      undefined,          { a: 100, b: 400 }, undefined, undefined,
      undefined,          undefined,          undefined, undefined,
      undefined,          undefined,          undefined, undefined,
      ... 999900 more items
    ]
    >
    */

LICENSE

  • ISC