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

costoflife

v0.3.1

Published

The CostOf.Life Calculator

Downloads

2

Readme

CostOf.Life

Build Coverage Status dependency status Crates.io

This is the CostOf.Life library and command line client.

For a more general description about the project check website: thecostof.life

Installation

install it with cargo install costoflife

Examples

To add a single transaction use the command costoflife add:

|> costoflife add Netflix 7.99€ 100320 1m12x .movies .covid

See it in action:

asciicast

Transactions

The library interpret transactions and calculate for each transaction its per diem amount. For a longer explanation check the CostOf.life website.

A transaction as the properties:

  • Name: a descriptive name
  • Amount: the amount in monetary currency
  • Lifetime: a duration that the transaction applies to
  • Start date: the start date since when the lifetime should be computed
  • Tags: for grouping transactions

As a simple interface the library interprets strings into transactions, the format of the string is shown in the examples and the details are listed below.

Parsing rules

The library tokenize the input string and looks for the patterns listed below. Anything that cannot be recognized as a pattern it will set as the title of the transaction. The title is required

Amount

The monetary value of the transaction, required:

Amount ::= Natural ( '.' Digit Digit? )? "€" 

Natural ::= NaturalDigit Digit*
NaturalDigit ::= #'[1-9]'
Digit ::= "0" | NaturalDigit 

Currently the only available currency is

Examples:

  • 10€
  • 10000.99€

Lifetime

The duration of transaction, optional, defaults to 1d.

Lifetime ::= Duration Repeat?

Duration ::= Natural TimeUnit
Repeat ::= Natural "x"
TimeUnit ::= "d" | "w" | "m" | "y"

where the TimeUnit is:

  • d days
  • w weeks
  • m months
  • y years

Examples:

  • 1m12x => one month for 12 times, for example for monthly expenses like monthly subscriptions (Netflix, etc)
  • 12m => twelve months for 1 time, same as 1y
  • 1w52x => one week 52 times, for example weekly groceries expenses for all the year

💡 the number of repeats they influence the total amount of the transaction: 10€ 1m12x will result of a transaction of total amount of 120€ while 12m1x will result in a single transaction of 10€ over 12 months

Start date

The transaction start date, optional, defaults to the current date, it uses the little endian format (day, month, year).

Date ::= Day Month Year

Month ::= "1" #'[0-2]' | "0" NaturalDigit
Day ::= '0' #'[1-9]' | #'[1-2]' Digit | '3' #'[0-1]'
Year ::= Digit Digit

Natural ::= NaturalDigit Digit*
NaturalDigit ::= #'[1-9]'
Digit ::= "0" | NaturalDigit 

Examples:

  • 030521 => March the 3rd, 2021
  • 312122 => December the 31st, 2022

Tags

To label transactions, optional. For convenience it uses the hashtag format.

HashTag ::=  ('#' | '.')  Word

EOL ::= '\r'? '\n' 
Word ::= AlphaNum+ [ (' ' | '\t')+ | EOL ]
AlphaNum  ::= #'[A-Za-z0-9_-]'

Examples:

  • #lifestile
  • .whatever

Appendix

Here the full grammar


Tx ::= ( Amount | Lifetime | StartDate | HashTag ) ( SEP ( Amount | Lifetime | StartDate | HashTag )  )+ EOL

EOL ::= '\r'? '\n' 
SEP ::= (' ' | '\t')+

Lifetime ::= Duration Repeat?

Duration ::= Natural TimeUnit
Repeat ::= Natural "x"
TimeUnit ::= "d" | "w" | "m" | "y"

StartDate ::= Day Month Year

Month ::= "1" #'[0-2]' | "0" NaturalDigit
Day ::= '0' #'[1-9]' | #'[1-2]' Digit | '3' #'[0-1]'
Year ::= Digit Digit

Amount ::= Natural ( '.' Digit Digit? )? "€" 

Natural ::= NaturalDigit Digit*
NaturalDigit ::= #'[1-9]'
Digit ::= "0" | NaturalDigit 
Int ::= "+" | "-" Digit+

HashTag ::=  ('#' | '.')  Word

Word ::= AlphaNum+
AlphaNum  ::= #'[A-Za-z0-9_-]'

Made by adgb

Techincal Setup

  1. Install rust
  2. Install cargo-edit: cargo install cargo-edit. Cargo edit is used to manage dependencies.
  3. Install cargo-bump: cargo install cargo-bump. Cargo bump is used to bump release versions.