Skip to content

JonathanGawrych/deepIndexOf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

deepIndexOf

Adds a prototype to Array that allows you to do indexOf for a object by value, rather than by reference. The normal indexOf code was taken from MDN's Array.indexOf.The object is checked by Angular's equals function, however instead of using angular.equals(). I pulled the function out of angular and removed all angular references, so it will work if you use AngularJS or not.

Note that because I pulled it from AngularJS, deepIndexOf will ignored any variable prefixed with a dollar sign, or functions on the object. deepIndexOf currently does not look for or handle recursive references. Attempted to use deepIndexOf on an Array containing an object that has a recursive reference will cause an infinite loop with the browser throwing some sort of stack limit exception.

It should be noted that deepIndexOf is much slower than it's indexOf counterpart. Always try to use indexOf instead.

About

deepIndexOf for arrays of objects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published