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

ltv-calculator

v0.1.0

Published

Simply LTV / ARPU / Average Duration calcurator

Downloads

4

Readme

LTV calculator

Simply calculator to get the following properties.

  • LTV
  • Average duration
  • ARPU (Average Revenue Per User)

LTV / 平均継続期間 / ARPU(Average Revenue Per User)を計算するライブラリです。

Motivation blog post: 計算式参考

ユーザの平均継続期間が「1/解約率」で求められることの数学的証明:https://migi.hatenablog.com/entry/churn-formula

API Docs

https://hideokamoto.github.io/ltv-calculator/

Usaage

ARPU

import LTVCalculator from 'ltv-calculator'
const client = new LTVCalculator()

// 売り上げが100単位・ユーザー数が10単位の時、ARPUは10単位
// Sales is 100 unit and user is 10, ARPU is 10 unit
const arpu = client.calcARPU(100, 10).getARPU()
expect(arpu).toEqual(10)

// ショートハンドル
// short handle
const arpu = client.getARPU(100, 10)
expect(arpu).toEqual(10)

Average Duration / 解約率からの平均継続期間の計算

1 / churn rate (1 / 解約率) = Average Duration (平均継続期間)

import LTVCalculator from 'ltv-calculator'
const client = new LTVCalculator()

// 解約率10%の時、平均継続期間は10単位 
// Churn rate is 10% -> Average duration is 10 unit
const averageDuration = client
  .calcAverageDurationByChurnRate(10)
  .getAverageDurationByChurnRate()
expect(averageDuration).toEqual(10)

// ショートハンドル版
const averageDuration = client
  .getAverageDurationByChurnRate(10)
expect(averageDuration).toEqual(10)

// 解約率10%の時、平均継続期間は10単位(単位を明示的に設定する)
// Churn rate is 10% -> Average duration is 10 unit
const averageDuration = client
  .calcAverageDurationByChurnRate(10, 'percentage')
  .getAverageDurationByChurnRate()
expect(averageDuration).toEqual(10)

// ショートハンドル版
const averageDuration = client
  .getAverageDurationByChurnRate(10, 'percentage')
expect(averageDuration).toEqual(10)

// 解約率0.1(10%)の時、平均継続期間は10単位(パーセントではなく数値でも指定できる)
// Churn rate is 0.1(10%) -> Average duration is 10 unit
const averageDuration = client
  .calcAverageDurationByChurnRate(0.1, 'number')
  .getAverageDurationByChurnRate()
expect(averageDuration).toEqual(10)

// ショートハンドル版
const averageDuration = client
  .getAverageDurationByChurnRate(0.1, 'number')
expect(averageDuration).toEqual(10)

LTVの計算

平均継続期間 * ARPUで計算する。

// 1: 売り上げが100単位・ユーザー数が10単位の時、ARPUは10単位
//    Sales is 100 unit and user is 10, ARPU is 10 unit
//
// 2: 解約率10%の時、平均継続期間は10単位 
//    Churn rate is 10% -> Average duration is 10 unit
//
// 3: LTV (平均継続期間 * ARPU)は 10 * 10 = 100単位
//    LTV (Average Duration * ARPU) is 10 * 10 = 100 unit
const arpu = client.calcARPU(100, 10)
    .calcAverageDurationByChurnRate(10)
    .getLTV()

expect(arpu).toEqual(100)

contribution

// clone
$ git clone [email protected]:hideokamoto/sequential-promise.git
$ cd sequential-promise

// setup
$ yarn

// Unit test
$ yarn test
or
$ yarn run test:watch

// Lint
$ yarn run lint
or
$ yarn run lint --fix

// Build
$ yarn run build

// Rebuild docs
$ yarn run doc