Git Product home page Git Product logo

manmaru.arrayutil's Introduction

MANMARU ARRAYUTIL JS

Inspired from CASA Lib / AS 2.0 (v.10/06/08) - Aaron Clinger, David Nelson

manmaru.arrayutil.js :
Javascript utilities for sorting, searching and manipulating Arrays.

equals(first, second) ->
Determines if two Arrays contain the same objects at the same index
@param first: First Array to compare to the {@code second}
@param second: Second Array to compare to the {@code first}
@return Returns {@code true} if Arrays are the same; otherwise {@code false}

addItemsAt(tarArray, items, index) ->
Modifies original Array by adding all the elements from another Array at a specified position
@param tarArray: Array to add elements to
@param items: Array of elements to add
@param index: Position where the elements should be added
@return Returns {@code true} if the Array was changed as a result of the call; otherwise {@code false}

removeDuplicates(inArray) ->
Creates new Array composed of only the non-identical elements of passed Array
@param inArray: Array to remove equivalent items
@return A new Array composed of only unique elements

removeItem(tarArray, item) ->
Modifies original Array by removing all items that are identical to the specified item
@param tarArray: Array to remove passed {@code item}
@param item: Element to remove
@return The amount of removed elements that matched {@code item}, if none found returns {@code 0}

removeItems(tarArray, items) ->
Removes only the specified items in an Array
@param tarArray: Array to remove specified items from
@param items: Array of elements to remove
@return Returns {@code true} if the Array was changed as a result of the call; otherwise {@code false}

retainItems(tarArray, items) ->
Retains only the specified items in an Array
@param tarArray: Array to remove non specified items from
@param items: Array of elements to keep
@return Returns {@code true} if the Array was changed as a result of the call; otherwise {@code false}

contains(inArray, item) ->
Finds out how many instances of {@code item} Array contains
@param inArray: Array to search for {@code item} in
@param item: Object to find
@return The amount of {@code item}'s found; if none were found returns {@code 0}

containsAny(inArray, items) ->
Determines if Array {@code inArray} contains any element of Array {@code items}
@param inArray: Array to search for {@code items} in
@param items: Array of elements to search for
@return Returns {@code true} if {@code inArray} contains any element of {@code items}; otherwise {@code false}

getIndexOfDifference(first, second, fromIndex) ->
Compares two Arrays and finds the first index where they differ
@param first: First Array to compare to the {@code second}
@param second: Second Array to compare to the {@code first}
@param fromIndex: The location in the Arrays from which to start searching for a difference
@return The first position/index where the Arrays differ; if Arrays are identical returns {@code -1}

randomize(inArray) ->
Creates new Array composed of passed Array's items in a random order
@param inArray: Array to create copy of, and randomize
@return A new Array composed of passed Array's items in a random order

getLowestValue(inArray) ->
Finds the lowest value in {@code inArray}
@param inArray: Array composed only of numbers
@return The lowest value in {@code inArray}

getHighestValue(inArray) ->
Finds the highest value in {@code inArray}
@param inArray: Array composed only of numbers
@return The highest value in {@code inArray}


How to use:
ArrayUtil.functionName("param");

Example of use :
var testArray = new Array("blue","blue","green","red");
console.log(ArrayUtil.contains(testArray,"blue"));
return -> 2

manmaru.arrayutil's People

Contributors

adrien-dufond avatar

Watchers

 avatar

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.