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

soliditool

v1.0.0

Published

This Solidity library holds functions that you can use to simplify your smart contracts. For example no more writing loops for extracting indexes from arrays, and you can easily compare strings!

Readme

Soliditool— Solidity utils library

This library holds pre-made functions to make your life easier when coding your smart contract.

Overview

This library can help you keep your code cleaner and avoid rewriting code.

Functions in the library

Those are the functions available in this library:

compareStrings()

Function to compare 2 strings. Use the compareStrings function with 2 parameters, it will compare them and return a bool value.

For example:

compareStrings("blue", "red") will return false.
    function compareStrings(string memory firstString, string memory secondString) internal pure returns (bool) {
        return keccak256(bytes(firstString)) == keccak256(bytes(secondString));
    }

pseudoRandom

Function to generate a pseudo-random number.

WARNING: This function does not return a real random value; this function is to be used for testing ONLY and not in production where a real random number is needed.

    function pseudoRandom() public view returns (uint) {
        bytes32 blockHash = blockhash(block.number - 1);
        return uint(keccak256(abi.encodePacked(block.timestamp, uint(blockHash))));
    }

findString

Function to find the index matching a string in an array. This function takes a string as a parameter and loops through an array of strings. It then returns the index of the matching string (if it exists), or the 420 code if it does not exist.

    function findString(string[] memory array, string memory _string) internal pure returns (uint) {
        for (uint i = 0; i < array.length; i++) {
            string memory stringToFind = array[i];
            bool exists = Utils.compareStrings(stringToFind, _string);
            if (exists == true) {
                return i;
            }
        }
        return uint(420);
    }

findUint

Function to find the index matching a uint in an array. This function takes a uint as a parameter and loops through an array of units. It then returns the index of the matching unit (if it exists) or the 90909090 code if it does not exist.

    function findUint(uint[] memory array, uint _number) internal pure returns (uint) {
        for (uint i = 0; i < array.length; i++) {
            uint uintToFind = array[i];
            if (_number == uintToFind) {
                return i;
            }
        }
        return uint(90909090);
    }

findInt

Function to find the index matching an int in an array. This function takes an int as a parameter and loops through an array of ints. It then returns the index of the matching int (if it exists) or the 90909090 code if it does not exist.

    function findInt(int[] memory array, int _number) internal pure returns (uint) {
        for (uint i = 0; i < array.length; i++) {
            int intToFind = array[i];
            if (_number == intToFind) {
                return i;
            }
        }
        return uint(90909090);
    }

Getting started

Download the Soliditool package into your project by running:

npm install soliditool

Then import it into your smart contract adding this import statement at the top:

import "soliditool/contracts/Utils.sol";

Here is an example:

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "soliditool/contracts/Utils.sol";

contract TryUtils {

    string[] public colors = ["blue", "yellow", "red"];
    uint[] public numbers = [1,4,7];
    int[] public moreNumbers = [-3,99,-5343];

    address public owner;

    function compareStrings(string memory firstString, string memory secondString) public pure returns(bool) {
        return Utils.compareStrings(firstString, secondString);
    }
}