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 🙏

© 2026 – Pkg Stats / Ryan Hefner

typescript-collection-framework

v0.0.2

Published

A small framework with some helper methods for Javascript/Typescript.

Readme

typescript-collection-framework

A small framework with some helper methods for Javascript/Typescript.

Build

Run the following command once: npm install

Then run grunt to build the lib and run all tests.

You can also run grunt watch to build again if a file changes.

Usage

Just include the tcf.js in your code:<script type="text/javascript" src="tcf.js"></script>.

Then you can wrap an array var arrHelper = new tcf.ArrayHelper([1, 2, 3, 4, 5, 6]) or create a new one with no arguments var arrHelper = new tcf.ArrayHelper().

You always can access the native array with arrHelper.array`.

Access the first or last element

new tcf.ArrayHelper([1, 2, 3, 4, 5, 6]).first

Why optional ? Optional helps to prevent null pointers. So if you want to access you have to use the method getOrElse() with adefault value, or you use the doIfPresent() .

getOrElse()

You cannot just access the content of the optional. You have to pass a default value, which will be used if the optional is null.

new tcf.ArrayHelper([1, 2, 3, 4, 5, 6]).first.getOrElse(3); // will return 1

new tcf.ArrayHelper().first.getOrElse(3); // will return 3

isNull()

You can check if the optional has a value inside by calling isNull().

new tcf.ArrayHelper([1, 2, 3, 4, 5, 6]).first.isNull(); // will return false

new tcf.ArrayHelper().first.isNull() // will return true

doIfPresent()

If the content of the optional is not null, then the passed function with the content of the optional.

new tcf.ArrayHelper([1, 2, 3, 4, 5, 6]).last.doIfPresent(function(lastElement){
    lastElement // last element is 6
});

new tcf.ArrayHelper().last.doIfPresent(function(lastElement){
    lastElement // the function is not called
});

removeFirst()

Removes the first equal element from the array.

new tcf.ArrayHelper([ "hello", "world", "hello", "whats up" ]).removeFirst("hello"); 
// the array is now [ "world", "hello", "whats up" ]

removeLast()

Removes the last equal element from the array.

new tcf.ArrayHelper([ "hello", "world", "hello", "whats up" ]).removeLast("hello"); 
// the array is now [ "hello", "world", "whats up" ]

removeAll()

Removes all equal elements from the array.

new tcf.ArrayHelper([ "hello", "world", "hello", "whats up" ]).removeLast("hello"); 
// the array is now [ "world", "whats up" ]

findWhere()

Finds all element which have all the properties of the passed object.

var testArray = [
  {id:1, name:"test1", points:4},
  {id:2, name:"test2", points:2},
  {id:3, name:"test3", points:2},
  {id:4, name:"test4", points:1}
];
var arrHelper = tcf.ArrayHelper(testArray);
var foundValues = arrayHelper.findWhere({points : 2}); 
/*
Returns [{id:2, name:"test2", points:2}, {id:3, name:"test3", points:2}] wrapped in a array helper
*/

firstWhere()

Finds the first element which has all the properties of the passed object.

var testArray = [
            {id : 1, name : "User1"},
            {id : 2, name : "User2"},
            {id : 3, name : "User3"},
            {id : 4, name : "User4"},
            {id : 3, name : "User5"}
        ];
        
var arrHelper = tcf.ArrayHelper(testArray);
arrHelper.firstWhere({id:4}).doIfPresent(function(result){ 
    console.log("hello " + result.name); // prints "hello User4"
});

count()

Count all elements (array.length) or if you pass a element if counts all occurrences.

var testArray = [1, 2, 1, 3, 1, 4, 1, 5];
var arrHelper = tcf.ArrayHelper(testArray);
arrHelper.count(1); // will return 4

insertAtIndex()

You can insert elements to a specific position. The First argument is the position followed by elements to insert.

var array = [ 1, 5 ];
var arrayHelper = new tcf.ArrayHelper(array);
arrayHelper.insertAtIndex(1, 2, 3, 4);
// array is now [1,2,3,4,5]