Giter Site home page Giter Site logo

bindexof's Introduction

THIS PACKAGE HAS BEEN DEPRECATED

bindexOf

Build Status

summary

Find the index of a buffer inside another Buffer, runs pretty well for small buffers or searches that the searchValue is found near the beginning, returns the first occurrence of the specified value, starting the search at fromIndex, returns -1 if the value is not found.

Case-sensitivity: The bindexOf is case sensitive.

Benchmark: run npm run bench1 && npm run bench2 to see some results.

node v0.10.*

app

bindexOf(buffer, searchBuffer[, fromIndex]])

fromIndex The location to start the search from. It can be any integer between 0 and the length of the buffer. The default value is 0.

example

var bindexOf = require('bindexof');


var buffer = new Buffer('Node.js is a platform built on Chrome\'s JavaScript ' +
               'runtime for easily building fast, scalable network ' + 
               'applications.platform');
            
            
var buffer_to_find = new Buffer('easily');


var find = bindexOf(buffer, buffer_to_find);

console.log(find); // index 63

bindexof's People

Contributors

joaquimserafim avatar

Watchers

 avatar  avatar  avatar

bindexof's Issues

Incorrect result after partial match

This algorithm returns incorrect result if search pattern is partially matched before reaching a full match.
It fails the following test case:

const assert = require("assert").strict;
const bindexOf = require("bindexof");
const a = Buffer.from([0x01, 0x01, 0x02]);
const b = Buffer.from([0x01, 0x02]);
assert.equal(1, bindexOf(a, b));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.