Nodejs Array Search search(search_func)

Here you can find the source of search(search_func)

Method Source Code

Array.prototype.search = function(search_func){
    for (var i= 0; i<this.length; i++){
        if (search_func(this[i]) == 0)
            return this[i]
    }//www. j a v  a2 s .c  o  m
    return null;
}

Related

  1. search(k)
    Array.prototype.search = function(k){
      var a = this;
      this.sort(a);
      var max=a.length-1,min=0,mid;
      while(min<=max){
        mid=(max+min)>>>1;
        if(k>a[mid])
          min = mid+1;
        else if(k<a[mid])
    ...
    
  2. search(key)
    Array.prototype.search = function(key) {
      'use strict';
      var max = this.length - 1;
      var min = 0;
      var count = 0;
      while (min <= max) {
        var mid = Math.floor((min + max) / 2);
        if (this[mid] === key) {
          return {
    ...
    
  3. search(key, value)
    Array.prototype.search = function (key, value) {
        return this.reduce(function (result, el) {
            if (result) return result;
            if (key) {
                if (typeof key === "function") {
                    if (key(el) === value) {
                        return el;
                } else {
    ...
    
  4. search(key, value)
    Array.prototype.search = function (key, value) {
        if (arguments.length == 1) {
            return this.filter(function (e) {
                return e == value;
            });
        if (arguments.length == 2) {
            var k = arguments[0];
            var value = arguments[1];
    ...
    
  5. search(n)
    Array.prototype.search = function(n) {
      var start = 0;
      var end = this.length - 1;
      var result = {count: 0, index: -1, length: this.length};
      while (start <= end) {
        mid = (start + end) / 2 >> 0;
        if (this[start] === n) {
          result.index = start;
          return result;
    ...
    
  6. search(v)
    Array.prototype.search = function(v){
      for (i=0;i<this.length;i++) {
        if (this[i]===v) return i;
    
  7. search(value)
    Array.prototype.search = function(value){
      var startIndex  = 0,
      stopIndex = this.length - 1,
      middle = Math.floor((stopIndex + startIndex)/2);
      var count = 0;
      while(this[middle] != value && startIndex < stopIndex){
        if (value < this[middle]){
          stopIndex = middle - 1;
        }else if (value > this[middle]){
    ...
    
  8. search(value)
    Array.prototype.search = function(value){
      var startIndex  = 0,
      stopIndex = this.length - 1,
      middle = Math.floor((stopIndex + startIndex)/2);
      var count = 0;
      while(this[middle] != value && startIndex < stopIndex){
        count+=1;
        if (value < this[middle]){
          stopIndex = middle - 1;
    ...
    
  9. searchById(id)
    Array.prototype.searchById = function(id){
      for(var i=0; i<this.length; i++){
        if(this[i].id === id){
          return this[i];
    };