npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

proto-objectsarray

v0.11.0

Published

General purpose Library to prototype the Array object to utilize analysing data stored as array of objects

Downloads

17

Readme

proto-objectsArray

General Purpose Library To Prototype The Array Object To Utilize Analysing Data Stored As Array Of Objects.

usage :

	var proto = require('proto-objectsarray');        //require the Library
    proto();                                          // load the Library
    var testArray=[{"fName":"Adam","age":22,"rank":3,"lName":"juma"},
                   {"fName":"salim","age":33,"rank":2,"lName":"juma"},
                   {"fName":"mohd","age":25,"rank":5,"lName":"rida"}];

Then for any Array of objects within your code you may use the functions as detailed in below examples.

� .seek("lName","juma","fname","Adam")
//returns {"fName":"Adam","age":22,"rank":3,"lName":"juma"}

In case more than one object is found it returns an array of the found objects. e.g.:

testArray.seek("lName","juma") 
// note that you may use one or two seek parameters only.

it returns :[{"fName":"Adam","age":22,"rank":3,"lName":"juma"},{"fName":"salim","age":33,"rank":2,"lName":"juma"}]

In case no objects where found it returns -1 if three arguments are used it will return the value of array of values for the third argument in the objects that meet the condition of the first two arguments e.g. :

 testArray.seek("lName","rida","fname") 
 //it will return "mohd" 
testArray.seek("lName","juma","fname") 
//it will return ["Adam","salim"] 

� .seekSlim()// same as .seek but for the first search condition you may search partially e.g.

testArray.seekSlim("lName","ju","fname","Adam") 
//it returns {"fName":"Adam","age":22,"rank":3,"lName":"juma"}
testArray.seekSlim("lName","ri","fname") 
//it returns "mohd"

� .seekA() same as .seek but forces the return of an Array even if one result is found e.g.

testArray.seekA("lName","juma","fname","Adam") 
//returns :[{"fName":"Adam","age":22,"rank":3,"lName":"juma"}]
//it returns [] if no results are found.

� .INDEX() same as seekA but returns the INDEX of the object in the array not the object and always returns an array or -1 e.g.:

testArray.INDEX("lName","juma") 
// it returns :[0,1]

� .maxOf() takes odd number of arguments (1,3 or 5) if one argument is provided it seeks the maximum value of this argument.e.g:

testArray.maxOf("rank") // returns 5;

if 3 or 5 arguments are provided the considered maximum value is the last argument and the others are equivalence conditions e.g.

testArray.maxOf("lName","juma","fName","Adam","age")
// returns 22

� .minOf() // same as maxOf but with the minimum value.

.rowOf(columnIndex,value) * It may be replaced by seekSlim()* Returns the row that has the same "value" in the property with index that matches "columnIndex" e.g:

testArray.rowOf(2,33) 
// returns {"fName":"salim","age":33,"rank":2,"lName":"juma"}
testArray.rowOf("age",33) 
//' returns {"fName":"salim","age":33,"rank":2,"lName":"juma"}
testArray.rowOf("fName","salim") 
//returns {"fName":"salim","age":33,"rank":2,"lName":"juma"}
testArray.rowOf("fName","sal") 
//returns {"fName":"salim","age":33,"rank":2,"lName":"juma"}

it returns an object if one item is found and an array if many and and empty array if none is found.

� .numSort() // Sorts and Array of objects following one Numerical property e.g:

testArray.numSort("age") 
// if no second argument is provided it sorts Ascending .

testArray.numSort("age","A") or testArray.numSort("age","D") the second arguments takes only two options : "A" for Ascending and "D" for Descending.