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

ferramenta

v1.3.2

Published

NodeJS/Typescript collection of utility functions

Downloads

337

Readme

Ferramenta Library

Release & Publish Tests Typescript License Version

Zero dependencies Node.js/Typescript library of utility functions, and their CLI wrappers.

Contains functions for:

  • JSON parsing
  • Lightweight UUID generation
  • Extracting method name within a class
  • Matching wildcard strings
  • Generating and validating Luhn numbers
  • Checking for circular references in objects
  • CRC16 calculation
  • Detecting runtime environment
  • Matching arrays
  • Casting values to specific types
  • Hashing passwords to store in the database (no bcrypt dependency)
  • Encoding and decoding base32 strings

Installation

NPM Registry link: https://www.npmjs.com/package/ferramenta

NPM:

npm i ferramenta

Yarn:

yarn add ferramenta

Functions Reference

Functions reference is available at reference website: ferramenta.xorde.io.

Command Line Reference

CLI Wrappers

get-json-value

This script will parse json file and return value of the property defined by path separated by '.'

Usage: get-json-value

Arguments:

  • filename: any JSON file, example: package.json
  • path: a property key path within JSON file, example: parent.child.value

Examples:

# package.json contains: {"version":"1.0.0"}
% get-json-value package.json version
> 1.0.0

# package.json contains: {"scripts":{"build":"npm run build-script"}}
% get-json-value package.json scripts.build
> npm run build-script

set-json-value

This script will parse json file and return value of the property defined by path separated by '.'

Usage: set-json-value.js [options[,options]]

Arguments:

  • filename: any JSON file, example: package.json
  • path: a property key path within JSON file, example: parent.child.value
  • options:
    • tabs: format output JSON with tabs, otherwise output will be a string JSON without formatting
    • no-except: if conversion fails, do not exit with error, just use string value
    • number: convert value to number (by default, if fails exit with error)
    • object: convert value to object (by default, if fails exit with error)
    • boolean: convert value to boolean, only 'true' or '1' converts to true
    • delete: removes value and its key, provided value argument is ignored and can be anything
    • null: sets null as value, provided value argument is ignored and can be anything

Example:

% set-json-value.js package.json version 1.2.3 tabs
> Complete

% set-json-value.js package.json scripts.test 'jest --no-cache' tabs
> Complete

luhn-calculate

This script will calculate Luhn checksum for a given number.

Usage: luhn-calculate

Arguments:

  • number: a number to calculate checksum for

Example:

% luhn-calculate 123456789
> 7

uuid-generate

This script will generate UUID v4.

Usage: uuid-generate

Example:

% uuid-generate
> 3b9c6c7e-0b0b-4e1a-8b0a-0b0b0b0b0b0b

Contributing

Documentation

Documentation is generated automatically using TypeDoc.

This approach is used to avoid maintaining documentation in two places: in code and in README.md.

To build documentation locally, run:

npm run docs:build

Patching documentation

Due to current limitation of Cloudflare where our documentation is hosted, we cannot use functions directory to store HTML files related to functions reference (see https://github.com/cloudflare/wrangler2/issues/2240). Instead, we use funcs directory. To do that we patch TypeDoc output HTML files replacing all references to functions with funcs.

To patch documentation, run:

npm run docs:patch

As soon as this issue is resolved, we will remove this patching step.