1.3.0 • Published 5 months ago

ferramenta v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

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
  • 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

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.

1.3.0

5 months ago

1.2.8

6 months ago

1.2.7

6 months ago

1.2.6

7 months ago

1.2.5

7 months ago

1.2.4

7 months ago

1.2.3

7 months ago

1.2.9

6 months ago

1.2.10

6 months ago

1.2.2

8 months ago

1.2.0

9 months ago

1.2.1

9 months ago

1.1.0

12 months ago

1.0.26

12 months ago

1.0.25

12 months ago

1.0.19

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.22

1 year ago

1.0.20

1 year ago

1.0.15

1 year ago

1.0.24

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.0

2 years ago