1.0.0 • Published 2 years ago

nv-file-vline v1.0.0

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

nv-file-vline

  • each char is a seperate node

install

  • npm install nv-file-vline

usage

  const vline = require("nv-file-vline")

example

    const vline = require("nv-file-vline")
    var store = vline(100000)



    var page = store.page()
    page.init_from_file("./txt");

    /*
    [
      Line [-rw-r--r--  1 root root 1859 May 11 07:08 char.js] {},
      Line [-rw-r--r--  1 root root  415 May 11 07:09 err.js] {},
      Line [-rw-r--r--  1 root root  261 May 11 07:03 index.js] {},
      Line [-rw-r--r--  1 root root 1846 May 11 07:10 line.js] {},
      Line [drwxr-xr-x 41 root root 4096 May 11 04:59 node_modules] {},
      Line [-rw-r--r--  1 root root  175 May 11 06:07 package.json] {},
      Line [-rw-r--r--  1 root root 2297 May 11 07:17 page.js] {},
      Line {},
      Line {}
    ]

    */

    page.show()
    /*
    {
      '0': '-rw-r--r--  1 root root 1859 May 11 07:08 char.js',
      '1': '-rw-r--r--  1 root root  415 May 11 07:09 err.js',
      '2': '-rw-r--r--  1 root root  261 May 11 07:03 index.js',
      '3': '-rw-r--r--  1 root root 1846 May 11 07:10 line.js',
      '4': 'drwxr-xr-x 41 root root 4096 May 11 04:59 node_modules',
      '5': '-rw-r--r--  1 root root  175 May 11 06:07 package.json',
      '6': '-rw-r--r--  1 root root 2297 May 11 07:17 page.js',
      '7': '',
      '8': ''
    }
    >
    */


    page.insert_after(6,["xyz","edf","999"])

    /*
    > page
    Page [{
      "0": "-rw-r--r--  1 root root 1859 May 11 07:08 char.js",
      "1": "-rw-r--r--  1 root root  415 May 11 07:09 err.js",
      "2": "-rw-r--r--  1 root root  261 May 11 07:03 index.js",
      "3": "-rw-r--r--  1 root root 1846 May 11 07:10 line.js",
      "4": "drwxr-xr-x 41 root root 4096 May 11 04:59 node_modules",
      "5": "-rw-r--r--  1 root root  175 May 11 06:07 package.json",
      "6": "-rw-r--r--  1 root root 2297 May 11 07:17 page.js",
      "7": "xyz",
      "8": "edf",
      "9": "999",
      "10": "",
      "11": ""
    }] {}
    >
    */

    var line = page.line(3)

    /*
    > line
    Line [-rw-r--r--  1 root root 1846 May 11 07:10 line.js] {}
    >
    */

    /*
    > line.show()
    {
      '0': '-',
      '1': 'r',
      '2': 'w',
      '3': '-',
      '4': 'r',
      '5': '-',
      '6': '-',
      '7': 'r',
      '8': '-',
      '9': '-',
      '10': ' ',
      '11': ' ',
      '12': '1',
      '13': ' ',
      '14': 'r',
      '15': 'o',
      '16': 'o',
      '17': 't',
      '18': ' ',
      '19': 'r',
      '20': 'o',
      '21': 'o',
      '22': 't',
      '23': ' ',
      '24': '1',
      '25': '8',
      '26': '4',
      '27': '6',
      '28': ' ',
      '29': 'M',
      '30': 'a',
      '31': 'y',
      '32': ' ',
      '33': '1',
      '34': '1',
      '35': ' ',
      '36': '0',
      '37': '7',
      '38': ':',
      '39': '1',
      '40': '0',
      '41': ' ',
      '42': 'l',
      '43': 'i',
      '44': 'n',
      '45': 'e',
      '46': '.',
      '47': 'j',
      '48': 's'
    }
    >
    */

    line.slice(9,15)
    /*
    [
      Char [-] {},
      Char [ ] {},
      Char [ ] {},
      Char [1] {},
      Char [ ] {},
      Char [r] {}
    ]
    >
    */


    var char = line.char(3)

    /*
    > char
    Char [-] {}
    > char.char_
    '-'
    > char.code_
    45
    >

    */


    char.init("x")
    /*
    > 
    Char [x] {}
    >
    > line
    Line [-rwxr--r--  1 root root 1846 May 11 07:10 line.js] {}
    >
    > page.show()
    {
      '0': '-rw-r--r--  1 root root 1859 May 11 07:08 char.js',
      '1': '-rw-r--r--  1 root root  415 May 11 07:09 err.js',
      '2': '-rw-r--r--  1 root root  261 May 11 07:03 index.js',
      '3': '-rwxr--r--  1 root root 1846 May 11 07:10 line.js',
      '4': 'drwxr-xr-x 41 root root 4096 May 11 04:59 node_modules',
      '5': '-rw-r--r--  1 root root  175 May 11 06:07 package.json',
      '6': '-rw-r--r--  1 root root 2297 May 11 07:17 page.js',
      '7': 'xyz',
      '8': 'edf',
      '9': '999',
      '10': '',
      '11': ''
    }
    >

    */


    > var p1 = page.clone()
    undefined
    > p1
    Page [{
      "0": "-rw-r--r--  1 root root 1859 May 11 07:08 char.js",
      "1": "-rw-r--r--  1 root root  415 May 11 07:09 err.js",
      "2": "-rw-r--r--  1 root root  261 May 11 07:03 index.js",
      "3": "-rw-r--r--  1 root root 1846 May 11 07:10 line.js",
      "4": "drwxr-xr-x 41 root root 4096 May 11 04:59 node_modules",
      "5": "-rw-r--r--  1 root root  175 May 11 06:07 package.json",
      "6": "-rw-r--r--  1 root root 2297 May 11 07:17 page.js",
      "7": "",
      "8": ""
    }] {}
    >
    > p1.page_
    '-rw-r--r--  1 root root 1859 May 11 07:08 char.js\n' +
      '-rw-r--r--  1 root root  415 May 11 07:09 err.js\n' +
      '-rw-r--r--  1 root root  261 May 11 07:03 index.js\n' +
      '-rw-r--r--  1 root root 1846 May 11 07:10 line.js\n' +
      'drwxr-xr-x 41 root root 4096 May 11 04:59 node_modules\n' +
      '-rw-r--r--  1 root root  175 May 11 06:07 package.json\n' +
      '-rw-r--r--  1 root root 2297 May 11 07:17 page.js\n' +
      '\n'
    >

APIS

  • vline(max_size=100000) // page_node + line_node + char_node <= max_size

METHODS

page

page.append                                  page.char_nds_                               page.clone                                   page.constructor                             page.erase
page.init                                    page.init_from_file                          page.insert_after                            page.insert_before                           page.line
page.line_sp_                                page.page_                                   page.prepend                                 page.rm_line                                 page.rm_slice
page.show                                    page.slice

line

line.add_after                               line.add_before                              line.append                                  line.char                                    line.char_nds_
line.clone                                   line.constructor                             line.erase                                   line.init                                    line.line_
line.prepend                                 line.rm_char                                 line.rm_slice                                line.show                                    line.slice

char

char.add_after                               char.add_before                              char.char_                                   char.code_                                   char.constructor
char.erase                                   char.init                                    char.line_                                   char.line_sp_                                char.page_

LICENSE

  • ISC